blob: aeca0e18c5f117eef9b6e133317296ac64a29364 [file] [log] [blame]
Harald Weltea0895f92018-03-08 11:51:23 +01001SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sysinfo
Harald Welteadd12df2017-12-12 15:51:39 +01002
Neels Hofmeyrfaa379f2018-03-02 00:09:46 +01003PARALLEL_MAKE ?= -j8
Harald Welteadd12df2017-12-12 15:51:39 +01004
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
Stefan Sperling61c11e92018-03-20 18:25:26 +010023# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010024.PHONY: deps-update
25deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010026 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010027
Harald Welteadd12df2017-12-12 15:51:39 +010028compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
29clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
30all: $(foreach dir,$(SUBDIRS),$(dir)/all)
31
32define DIR_Makefile_template
33$(1)/Makefile:
34 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
35endef
36
37define DIR_compile_template
38.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010039$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010040 $(MAKE) -C $(1) compile
41endef
42
43define DIR_clean_template
44.PHONY: $(1)/clean
45$(1)/clean: $(1)/Makefile
46 $(MAKE) -C $(1) clean
47 (cd $(1) && ../rmlinks.sh && rm Makefile)
48endef
49
50define DIR_all_template
51$(1): $(1)/all
52.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +010053$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010054 $(MAKE) -C $(1) compile
55 $(MAKE) $(PARALLEL_MAKE) -C $(1)
56endef
57
58$(foreach dir,$(SUBDIRS), \
59 $(eval $(call DIR_Makefile_template,$(dir))) \
60 $(eval $(call DIR_compile_template,$(dir))) \
61 $(eval $(call DIR_clean_template,$(dir))) \
62 $(eval $(call DIR_all_template,$(dir))) \
63 )