blob: 0defc3148dd609388f03424248c8cbac6f039050 [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
Harald Welte6bef5dd2018-02-15 18:31:22 +010023.PHONY: deps-update
24deps-update:
25 $(MAKE) -C deps update
26
Harald Welteadd12df2017-12-12 15:51:39 +010027compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
28clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
29all: $(foreach dir,$(SUBDIRS),$(dir)/all)
30
31define DIR_Makefile_template
32$(1)/Makefile:
33 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
34endef
35
36define DIR_compile_template
37.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010038$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010039 $(MAKE) -C $(1) compile
40endef
41
42define DIR_clean_template
43.PHONY: $(1)/clean
44$(1)/clean: $(1)/Makefile
45 $(MAKE) -C $(1) clean
46 (cd $(1) && ../rmlinks.sh && rm Makefile)
47endef
48
49define DIR_all_template
50$(1): $(1)/all
51.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +010052$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010053 $(MAKE) -C $(1) compile
54 $(MAKE) $(PARALLEL_MAKE) -C $(1)
55endef
56
57$(foreach dir,$(SUBDIRS), \
58 $(eval $(call DIR_Makefile_template,$(dir))) \
59 $(eval $(call DIR_compile_template,$(dir))) \
60 $(eval $(call DIR_clean_template,$(dir))) \
61 $(eval $(call DIR_all_template,$(dir))) \
62 )