-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (70 loc) · 2.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# LiXS: Lightweight XenStore
# Basic configuration
verbose ?= n
config ?= config.mk
ifeq (,$(filter $(MAKECMDGOALS),configure clean distclean))
-include $(config)
endif
# Define binaries and objects
LIXS_APP := app/lixs
LIXS_LIB :=
LIXS_LIB += app/lixs_conf.o
CATCH_APP := test/run-catch
CATCH_LIB := $(patsubst %.cc, %.o, $(shell find test/catch/ -name "*.cc"))
LIBLIXS :=
LIBLIXS += $(patsubst %.c, %.o, $(shell find lib/ -name "*.c"))
LIBLIXS += $(patsubst %.cc, %.o, $(shell find lib/ -name "*.cc"))
# Default build and linking flags
ifneq ($(CONFIG_XEN_USR_ROOT),)
CFLAGS += -I $(CONFIG_XEN_USR_ROOT)/usr/local/include
CXXFLAGS += -I $(CONFIG_XEN_USR_ROOT)/usr/local/include
endif
CFLAGS += -Iinc -Wall -MD -MP -g -O3 -std=gnu11
CXXFLAGS += -Iinc -Wall -MD -MP -g -O3 -std=gnu++11
ifneq ($(CONFIG_XEN_USR_ROOT),)
LDFLAGS += -L $(CONFIG_XEN_USR_ROOT)/usr/local/lib
LDFLAGS += -Wl,-rpath-link,$(CONFIG_XEN_USR_ROOT)/usr/local/lib
endif
LDFLAGS += -lxenctrl -lxenstore
# Configuration macros
CCFLAGS += -DLOGGER_MAX_LEVEL=LOGGER_MAX_LEVEL_$(CONFIG_LOGGER_MAX_LEVEL)
CXXFLAGS += -DLOGGER_MAX_LEVEL=LOGGER_MAX_LEVEL_$(CONFIG_LOGGER_MAX_LEVEL)
# On Xen 4.7 the libxc API changed being split into multiple libs. Defining the
# following macros gives access to the old API. Lets not change the used API
# for now, to keep compatibility with older version of Xen.
CFLAGS += -DXC_WANT_COMPAT_EVTCHN_API
CFLAGS += -DXC_WANT_COMPAT_GNTTAB_API
CFLAGS += -DXC_WANT_COMPAT_MAP_FOREIGN_API
CXXFLAGS += -DXC_WANT_COMPAT_EVTCHN_API
CXXFLAGS += -DXC_WANT_COMPAT_GNTTAB_API
CXXFLAGS += -DXC_WANT_COMPAT_MAP_FOREIGN_API
# Build targets
all: $(LIXS_APP)
tests: $(CATCH_APP)
configure: $(config)
install: $(LIXS_APP)
$(call cmd, "INSTALL", $(LIXS_APP), cp -f, $(LIXS_APP) /usr/local/sbin/lixs)
clean:
$(call cmd, "CLEAN", "*.o", rm -rf, $(shell find -name "*.o"))
$(call cmd, "CLEAN", "*.d", rm -rf, $(shell find -name "*.d"))
distclean: clean
$(call cmd, "CLEAN", $(LIXS_APP) , rm -f, $(LIXS_APP))
$(call cmd, "CLEAN", $(CATCH_APP), rm -f, $(CATCH_APP))
$(call cmd, "CLEAN", config.mk, rm -f, config.mk)
.PHONY: all tests configure install clean distclean
# Include default rules
include rules.mk
# Build rules for binaries
$(LIXS_APP): % : %.o $(LIXS_LIB) $(LIBLIXS)
$(call cxxlink, $^, $@)
$(CATCH_APP): % : %.o $(CATCH_LIB) $(LIBLIXS)
$(call cxxlink, $^, $@)
# Build rules for configuration
config.mk: config.mk.in
$(call cmd, "CONFIG", $@, cp, $^ $@)
# Include auto-generated dependency information
-include $(LIXS_APP:%=%.d)
-include $(LIXS_LIB:%.o=%.d)
-include $(CATCH_APP:%=%.d)
-include $(CATCH_LIB:%.o=%.d)
-include $(LIBLIXS:%.o=%.d)