Harald Welte | 3c68a54 | 2018-01-27 16:03:20 +0100 | [diff] [blame] | 1 | SUBDIRS=bsc bsc-nat ggsn_tests gprs_gb lapdm mgw msc selftest sysinfo |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 2 | |
| 3 | PARALLEL_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 | |
Harald Welte | 6807982 | 2017-12-12 16:30:53 +0100 | [diff] [blame] | 17 | default: deps all |
| 18 | |
| 19 | .PHONY: deps |
| 20 | deps: |
| 21 | $(MAKE) -C deps |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 22 | |
| 23 | compile: $(foreach dir,$(SUBDIRS),$(dir)/compile) |
| 24 | clean: $(foreach dir,$(SUBDIRS),$(dir)/clean) |
| 25 | all: $(foreach dir,$(SUBDIRS),$(dir)/all) |
| 26 | |
| 27 | define DIR_Makefile_template |
| 28 | $(1)/Makefile: |
| 29 | (cd $(1) && ./gen_links.sh && ./regen_makefile.sh) |
| 30 | endef |
| 31 | |
| 32 | define DIR_compile_template |
| 33 | .PHONY: $(1)/compile |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 34 | $(1)/compile: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 35 | $(MAKE) -C $(1) compile |
| 36 | endef |
| 37 | |
| 38 | define DIR_clean_template |
| 39 | .PHONY: $(1)/clean |
| 40 | $(1)/clean: $(1)/Makefile |
| 41 | $(MAKE) -C $(1) clean |
| 42 | (cd $(1) && ../rmlinks.sh && rm Makefile) |
| 43 | endef |
| 44 | |
| 45 | define DIR_all_template |
| 46 | $(1): $(1)/all |
| 47 | .PHONY: $(1)/all |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 48 | $(1)/all: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 49 | $(MAKE) -C $(1) compile |
| 50 | $(MAKE) $(PARALLEL_MAKE) -C $(1) |
| 51 | endef |
| 52 | |
| 53 | $(foreach dir,$(SUBDIRS), \ |
| 54 | $(eval $(call DIR_Makefile_template,$(dir))) \ |
| 55 | $(eval $(call DIR_compile_template,$(dir))) \ |
| 56 | $(eval $(call DIR_clean_template,$(dir))) \ |
| 57 | $(eval $(call DIR_all_template,$(dir))) \ |
| 58 | ) |