Makefile 4.56 KB
Newer Older
Jeroen Vreeken's avatar
Jeroen Vreeken committed
1
.PHONY: clean all rel_mktemp_dir console help
2

3
4
include build.mk

5
6
CONTROLLER_REL_TAR:=$(CURDIR)/controller_$(shell date +%Y%m%d%H%M).tar.gz
CONSOLE_REL_TAR:=$(CURDIR)/console_$(shell date +%Y%m%d%H%M).tar.gz
Jeroen Vreeken's avatar
Jeroen Vreeken committed
7

Jeroen Vreeken's avatar
Jeroen Vreeken committed
8
all: common controller console
Jeroen Vreeken's avatar
Jeroen Vreeken committed
9

10
11
12
13
14
15
16
17
18
19
20
help:
	@echo "Available build rules"; \
	echo  "---------------------"; \
	echo "   console             Build all executables for the console"; \
	echo "   controller          Build the controller executables"; \
	echo "   all                 Build both controller and console"; \
	echo "   release_console     Build a release tar file for the console"; \
	echo "   release_controller  Build a release tar file for the controller"; \
	echo "   release             Build both controller and console release"; \
	echo "   clean               Clean for both controller and console"; \
	echo ""; \
Jeroen Vreeken's avatar
Jeroen Vreeken committed
21
22
23
	echo "   HOST=<prefix>       Cross compile for <prefix>.";\
	echo "                       e.g.: HOST=arm-linux-gnueabihf"; \
	echo ""; \
24
25
26
27
28
29
30
31
32
33
34
	echo "Building a release"; \
	echo "------------------"; \
	echo "Simply running \"make release\" will build both the console and"; \
	echo "controller. They are stored in individual tar files, in the root"; \
	echo "of the dt_ctrl directory."; \
	echo "The releases are built in a temporary work directory from a clean"; \
	echo "git checkout. A release to be used for production must always"; \
	echo "be built from a version which is already committed to the"; \
	echo "golden repository (on eris.camras.nl)."


35
libnova/libnova.h: lib/libnova.la
Jeroen Vreeken's avatar
Jeroen Vreeken committed
36
37
38
libnova.la: lib/libnova.la
lib/libnova.la:
	cd libnova-0.13.0 ; ./configure -enable-static -disable-shared --prefix=${CURDIR} $(CONF_HOST); make; make install
39

40
clean: subdirs_CLEAN
Jeroen Vreeken's avatar
Jeroen Vreeken committed
41
	rm -rf lib/*
42
	rm -rf include/libnova
Jeroen Vreeken's avatar
Jeroen Vreeken committed
43
44
	cd libnova-0.13.0 ; make clean || true

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Rules for building a release

rel_mktemp_dir:
	$(eval REL_BUILD_DIR:=$(shell mktemp -d /tmp/dt_ctrl_XXXXXX))
	@echo "****** Building code in dir: $(REL_BUILD_DIR)"

rel_clone_dir: rel_mktemp_dir
	@echo "****** Creating clean checkout of source"; \
	git clone . $(REL_BUILD_DIR) >/dev/null; \
	echo "       Done"

rel_utils: rel_clone_dir
	@echo "****** Building common/utils"; \
	$(MAKE) -C $(REL_BUILD_DIR)/common/utils >/dev/null; \
	echo "       Done"

rel_trace: rel_utils
	@echo "****** Building common/trace"; \
	$(MAKE) -C $(REL_BUILD_DIR)/common/trace >/dev/null; \
	echo "       Done"

66
67
68
69
70
rel_command: rel_utils
	@echo "****** Building common/command"; \
	$(MAKE) -C $(REL_BUILD_DIR)/common/command >/dev/null; \
	echo "       Done"

71
72
73
74
rel_log:
	@echo "****** Building common/log"; \
	$(MAKE) -C $(REL_BUILD_DIR)/common/log >/dev/null; \
	echo "       Done"
75

76
rel_ctrl: rel_trace rel_log rel_command
77
78
79
80
81
82
83
	@echo "****** Building controller"; \
	$(MAKE) -C $(REL_BUILD_DIR)/controller >/dev/null; \
	echo "       Done"


rel_libnova: rel_clone_dir
	@echo "****** Building libnova"; \
Jeroen Vreeken's avatar
Jeroen Vreeken committed
84
	(cd $(REL_BUILD_DIR)/libnova-0.13.0 ; ./configure -enable-static -disable-shared --prefix=$(REL_BUILD_DIR) $(CONF_HOST); make; make install) >/dev/null; \
85
86
87
	echo "       Done"


88
rel_cons: rel_trace rel_libnova rel_log rel_command
89
90
91
92
93
94
95
96
97
98
99
100
101
	@echo "****** Building console"; \
	$(MAKE) -C $(REL_BUILD_DIR)/console >/dev/null; \
	echo "       Done"


$(CONSOLE_REL_TAR): rel_cons
	@tar -C $(REL_BUILD_DIR)/release -zhcf $@ console
	@echo "****** Created console release file $@"


$(CONTROLLER_REL_TAR): rel_ctrl
	@tar -C $(REL_BUILD_DIR)/release -zhcf $@ controller
	@echo "****** Created controller release file $@"
Jeroen Vreeken's avatar
Jeroen Vreeken committed
102

103
104
105
release: $(CONSOLE_REL_TAR) $(CONTROLLER_REL_TAR)
release_console: $(CONSOLE_REL_TAR)
release_controller: $(CONTROLLER_REL_TAR)
106
107
108
109
110
111
112
113
114
115
116
117
118

DIR := .
SRCS :=
TARGETS := 
CLEAN :=

define SUBDIR
ifeq ($(DIR),.)
  DIR := $1
else
  DIR := $(DIR)/$1
endif

119
120
121
$(DIR)_TMPTARGETS:=$(value TARGETS)
TARGETS:=

122
123
include $(DIR)/$1/build.mk

124
targets_$$(DIR): $$(TARGETS)
Jeroen Vreeken's avatar
Jeroen Vreeken committed
125
$$(TARGETS): $(DIR)/$1/build.mk
126
127
128

TARGETS:= $$($(DIR)_TMPTARGETS) $$(TARGETS)

129
130
131
DIR := $(DIR)
endef

132

Jeroen Vreeken's avatar
Jeroen Vreeken committed
133
134
135
CFLAGS := -pthread -Icommon -Icommon/include -Icontroller -Iconsole/console -Iinclude
LDFLAGS := -pthread -Lcommon/lib -Lcontroller/lib -Lconsole/console/lib -Llib -Wl,--as-needed
VPATH += common/lib controller/lib console/console/lib lib
136
VPATH += include
Jeroen Vreeken's avatar
Jeroen Vreeken committed
137

138

Jeroen Vreeken's avatar
Jeroen Vreeken committed
139
TARGETS:=
140
$(eval $(call SUBDIR,common))
Jeroen Vreeken's avatar
Jeroen Vreeken committed
141
142
143
common: $(TARGETS)

TARGETS:=
Jeroen Vreeken's avatar
Jeroen Vreeken committed
144
$(eval $(call SUBDIR,controller))
Jeroen Vreeken's avatar
Jeroen Vreeken committed
145
146
147
148
149
controller: $(TARGETS)

TARGETS:=
$(eval $(call SUBDIR,console))
console: $(TARGETS)
150
151
152



Jeroen Vreeken's avatar
Jeroen Vreeken committed
153
154
155
156
157
158
SRCS_TMP:=$(SRCS:.il=.il2c.d)
DEPS:=$(SRCS_TMP:.c=.d)
DEPSLIBS:=$(foreach DEP,$(DEPS),$(dir $(DEP)).libs/$(notdir $(DEP)))
-include $(DEPS) $(DEPSLIBS)

CLEAN += $(DEPS) $(DEPSLIBS)
159

Jeroen Vreeken's avatar
Jeroen Vreeken committed
160
SRCS_IL = $(filter %.il,$(SRCS))
Jeroen Vreeken's avatar
Jeroen Vreeken committed
161
$(SRCS_IL): $(IL2C)
Jeroen Vreeken's avatar
Jeroen Vreeken committed
162
163


164
subdirs_CLEAN:
Jeroen Vreeken's avatar
Jeroen Vreeken committed
165
	$(foreach CLEANITEM,$(CLEAN), rm -rf $(CLEANITEM);)
166