blob: 074e15160793e0dd78b2201e6d1b73bf8e88722a [file] [log] [blame]
Stefan Sperlingc307e682018-06-14 15:15:46 +02001SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu sccp selftest sgsn sip sysinfo
Harald Welteadd12df2017-12-12 15:51:39 +01002
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +02003NPROC=$(shell nproc 2>/dev/null)
4ifeq ($(NPROC),)
5NPROC=1
6endif
7PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +01008
9# This master makefile allows you to do things like
10# make clean (remove all generated binary, c++ and symlinks)
11# make compile (compile ttcn3 into c++)
12# make all (compile c++ into executable)
13#
14# as well as per-subdirectory targets like
15#
16# make bsc/clean
17# make bsc/compile
18# make bsc/all
19# make bsc (equivalent to bsc/all)
20
Harald Welte68079822017-12-12 16:30:53 +010021default: deps all
22
23.PHONY: deps
24deps:
25 $(MAKE) -C deps
Harald Welteadd12df2017-12-12 15:51:39 +010026
Stefan Sperling61c11e92018-03-20 18:25:26 +010027# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010028.PHONY: deps-update
29deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010030 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010031
Harald Welteadd12df2017-12-12 15:51:39 +010032compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
33clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
34all: $(foreach dir,$(SUBDIRS),$(dir)/all)
35
36define DIR_Makefile_template
37$(1)/Makefile:
38 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
39endef
40
41define DIR_compile_template
42.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010043$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010044 $(MAKE) -C $(1) compile
45endef
46
47define DIR_clean_template
48.PHONY: $(1)/clean
49$(1)/clean: $(1)/Makefile
50 $(MAKE) -C $(1) clean
51 (cd $(1) && ../rmlinks.sh && rm Makefile)
52endef
53
54define DIR_all_template
55$(1): $(1)/all
56.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +010057$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010058 $(MAKE) -C $(1) compile
59 $(MAKE) $(PARALLEL_MAKE) -C $(1)
60endef
61
62$(foreach dir,$(SUBDIRS), \
63 $(eval $(call DIR_Makefile_template,$(dir))) \
64 $(eval $(call DIR_compile_template,$(dir))) \
65 $(eval $(call DIR_clean_template,$(dir))) \
66 $(eval $(call DIR_all_template,$(dir))) \
67 )