Harald Welte | 206587e | 2018-03-26 23:36:22 +0200 | [diff] [blame] | 1 | SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sip sysinfo |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 2 | |
Neels Hofmeyr | faa379f | 2018-03-02 00:09:46 +0100 | [diff] [blame] | 3 | PARALLEL_MAKE ?= -j8 |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 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 | |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 23 | # 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] | 24 | .PHONY: deps-update |
| 25 | deps-update: |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 26 | $(MAKE) -C deps |
Harald Welte | 6bef5dd | 2018-02-15 18:31:22 +0100 | [diff] [blame] | 27 | |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 28 | compile: $(foreach dir,$(SUBDIRS),$(dir)/compile) |
| 29 | clean: $(foreach dir,$(SUBDIRS),$(dir)/clean) |
| 30 | all: $(foreach dir,$(SUBDIRS),$(dir)/all) |
| 31 | |
| 32 | define DIR_Makefile_template |
| 33 | $(1)/Makefile: |
| 34 | (cd $(1) && ./gen_links.sh && ./regen_makefile.sh) |
| 35 | endef |
| 36 | |
| 37 | define DIR_compile_template |
| 38 | .PHONY: $(1)/compile |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 39 | $(1)/compile: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 40 | $(MAKE) -C $(1) compile |
| 41 | endef |
| 42 | |
| 43 | define DIR_clean_template |
| 44 | .PHONY: $(1)/clean |
| 45 | $(1)/clean: $(1)/Makefile |
| 46 | $(MAKE) -C $(1) clean |
| 47 | (cd $(1) && ../rmlinks.sh && rm Makefile) |
| 48 | endef |
| 49 | |
| 50 | define DIR_all_template |
| 51 | $(1): $(1)/all |
| 52 | .PHONY: $(1)/all |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 53 | $(1)/all: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 54 | $(MAKE) -C $(1) compile |
| 55 | $(MAKE) $(PARALLEL_MAKE) -C $(1) |
| 56 | endef |
| 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 | ) |