blob: 80211defd8c3a3f81ffb9541d679080de48f9fc5 [file] [log] [blame]
Harald Welteadd12df2017-12-12 15:51:39 +01001SUBDIRS=bsc bsc-nat ggsn_tests gprs_gb lapdm mgw msc_tests selftest sysinfo
2
3PARALLEL_MAKE:=-j4
4
5# This master makefile allows you to do things like
6# make clean (remove all generated binary, c++ and symlinks)
7# make compile (compile ttcn3 into c++)
8# make all (compile c++ into executable)
9#
10# as well as per-subdirectory targets like
11#
12# make bsc/clean
13# make bsc/compile
14# make bsc/all
15# make bsc (equivalent to bsc/all)
16
Harald Welte68079822017-12-12 16:30:53 +010017default: deps all
18
19.PHONY: deps
20deps:
21 $(MAKE) -C deps
Harald Welteadd12df2017-12-12 15:51:39 +010022
23compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
24clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
25all: $(foreach dir,$(SUBDIRS),$(dir)/all)
26
27define DIR_Makefile_template
28$(1)/Makefile:
29 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
30endef
31
32define DIR_compile_template
33.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010034$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010035 $(MAKE) -C $(1) compile
36endef
37
38define DIR_clean_template
39.PHONY: $(1)/clean
40$(1)/clean: $(1)/Makefile
41 $(MAKE) -C $(1) clean
42 (cd $(1) && ../rmlinks.sh && rm Makefile)
43endef
44
45define DIR_all_template
46$(1): $(1)/all
47.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +010048$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010049 $(MAKE) -C $(1) compile
50 $(MAKE) $(PARALLEL_MAKE) -C $(1)
51endef
52
53$(foreach dir,$(SUBDIRS), \
54 $(eval $(call DIR_Makefile_template,$(dir))) \
55 $(eval $(call DIR_compile_template,$(dir))) \
56 $(eval $(call DIR_clean_template,$(dir))) \
57 $(eval $(call DIR_all_template,$(dir))) \
58 )