Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 1 | SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu sccp selftest sgsn sip sysinfo |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 2 | |
Stefan Sperling | b0ad3d8 | 2018-06-25 15:19:17 +0200 | [diff] [blame] | 3 | NPROC=$(shell nproc 2>/dev/null) |
| 4 | ifeq ($(NPROC),) |
| 5 | NPROC=1 |
| 6 | endif |
| 7 | PARALLEL_MAKE ?= -j$(NPROC) |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 8 | |
| 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 Welte | 6807982 | 2017-12-12 16:30:53 +0100 | [diff] [blame] | 21 | default: deps all |
| 22 | |
| 23 | .PHONY: deps |
| 24 | deps: |
| 25 | $(MAKE) -C deps |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 26 | |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 27 | # deps-update target for backwards compat; now does the same as 'make deps' |
Harald Welte | 6bef5dd | 2018-02-15 18:31:22 +0100 | [diff] [blame] | 28 | .PHONY: deps-update |
| 29 | deps-update: |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 30 | $(MAKE) -C deps |
Harald Welte | 6bef5dd | 2018-02-15 18:31:22 +0100 | [diff] [blame] | 31 | |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 32 | compile: $(foreach dir,$(SUBDIRS),$(dir)/compile) |
| 33 | clean: $(foreach dir,$(SUBDIRS),$(dir)/clean) |
| 34 | all: $(foreach dir,$(SUBDIRS),$(dir)/all) |
| 35 | |
| 36 | define DIR_Makefile_template |
| 37 | $(1)/Makefile: |
| 38 | (cd $(1) && ./gen_links.sh && ./regen_makefile.sh) |
| 39 | endef |
| 40 | |
| 41 | define DIR_compile_template |
| 42 | .PHONY: $(1)/compile |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 43 | $(1)/compile: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 44 | $(MAKE) -C $(1) compile |
| 45 | endef |
| 46 | |
| 47 | define DIR_clean_template |
| 48 | .PHONY: $(1)/clean |
| 49 | $(1)/clean: $(1)/Makefile |
| 50 | $(MAKE) -C $(1) clean |
| 51 | (cd $(1) && ../rmlinks.sh && rm Makefile) |
| 52 | endef |
| 53 | |
| 54 | define DIR_all_template |
| 55 | $(1): $(1)/all |
| 56 | .PHONY: $(1)/all |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 57 | $(1)/all: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 58 | $(MAKE) -C $(1) compile |
| 59 | $(MAKE) $(PARALLEL_MAKE) -C $(1) |
| 60 | endef |
| 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 | ) |