blob: e017129259191bc64b9f5dc0c7818317b8956d83 [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
17default: all
18
19compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
20clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
21all: $(foreach dir,$(SUBDIRS),$(dir)/all)
22
23define DIR_Makefile_template
24$(1)/Makefile:
25 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
26endef
27
28define DIR_compile_template
29.PHONY: $(1)/compile
30$(1)/compile: $(1)/Makefile
31 $(MAKE) -C $(1) compile
32endef
33
34define DIR_clean_template
35.PHONY: $(1)/clean
36$(1)/clean: $(1)/Makefile
37 $(MAKE) -C $(1) clean
38 (cd $(1) && ../rmlinks.sh && rm Makefile)
39endef
40
41define DIR_all_template
42$(1): $(1)/all
43.PHONY: $(1)/all
44$(1)/all: $(1)/Makefile
45 $(MAKE) -C $(1) compile
46 $(MAKE) $(PARALLEL_MAKE) -C $(1)
47endef
48
49$(foreach dir,$(SUBDIRS), \
50 $(eval $(call DIR_Makefile_template,$(dir))) \
51 $(eval $(call DIR_compile_template,$(dir))) \
52 $(eval $(call DIR_clean_template,$(dir))) \
53 $(eval $(call DIR_all_template,$(dir))) \
54 )