Harald Welte | 0cdf071 | 2019-06-19 18:15:38 +0200 | [diff] [blame] | 1 | # Copyright 2017 Harald Welte |
| 2 | # Copyright 2018 sysmocom - s.f.m.c. GmbH |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Harald Welte | db7892a | 2021-02-03 20:20:09 +0100 | [diff] [blame^] | 16 | SUBDIRS=bsc bsc-nat bts ccid fr fr-net gbproxy ggsn_tests hlr mgw mme msc pcu pgw remsim \ |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 17 | sccp selftest sgsn simtrace sip stp sysinfo smlc |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 18 | |
Stefan Sperling | b0ad3d8 | 2018-06-25 15:19:17 +0200 | [diff] [blame] | 19 | NPROC=$(shell nproc 2>/dev/null) |
| 20 | ifeq ($(NPROC),) |
| 21 | NPROC=1 |
| 22 | endif |
| 23 | PARALLEL_MAKE ?= -j$(NPROC) |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 24 | |
| 25 | # This master makefile allows you to do things like |
| 26 | # make clean (remove all generated binary, c++ and symlinks) |
| 27 | # make compile (compile ttcn3 into c++) |
| 28 | # make all (compile c++ into executable) |
| 29 | # |
| 30 | # as well as per-subdirectory targets like |
| 31 | # |
| 32 | # make bsc/clean |
| 33 | # make bsc/compile |
| 34 | # make bsc/all |
| 35 | # make bsc (equivalent to bsc/all) |
| 36 | |
Harald Welte | 6807982 | 2017-12-12 16:30:53 +0100 | [diff] [blame] | 37 | default: deps all |
| 38 | |
| 39 | .PHONY: deps |
| 40 | deps: |
| 41 | $(MAKE) -C deps |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 42 | |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 43 | # 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] | 44 | .PHONY: deps-update |
| 45 | deps-update: |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 46 | $(MAKE) -C deps |
Harald Welte | 6bef5dd | 2018-02-15 18:31:22 +0100 | [diff] [blame] | 47 | |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 48 | compile: $(foreach dir,$(SUBDIRS),$(dir)/compile) |
| 49 | clean: $(foreach dir,$(SUBDIRS),$(dir)/clean) |
| 50 | all: $(foreach dir,$(SUBDIRS),$(dir)/all) |
| 51 | |
| 52 | define DIR_Makefile_template |
| 53 | $(1)/Makefile: |
| 54 | (cd $(1) && ./gen_links.sh && ./regen_makefile.sh) |
| 55 | endef |
| 56 | |
| 57 | define DIR_compile_template |
| 58 | .PHONY: $(1)/compile |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 59 | $(1)/compile: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 60 | $(MAKE) -C $(1) compile |
| 61 | endef |
| 62 | |
| 63 | define DIR_clean_template |
| 64 | .PHONY: $(1)/clean |
| 65 | $(1)/clean: $(1)/Makefile |
| 66 | $(MAKE) -C $(1) clean |
| 67 | (cd $(1) && ../rmlinks.sh && rm Makefile) |
| 68 | endef |
| 69 | |
| 70 | define DIR_all_template |
| 71 | $(1): $(1)/all |
| 72 | .PHONY: $(1)/all |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 73 | $(1)/all: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 74 | $(MAKE) -C $(1) compile |
| 75 | $(MAKE) $(PARALLEL_MAKE) -C $(1) |
| 76 | endef |
| 77 | |
| 78 | $(foreach dir,$(SUBDIRS), \ |
| 79 | $(eval $(call DIR_Makefile_template,$(dir))) \ |
| 80 | $(eval $(call DIR_compile_template,$(dir))) \ |
| 81 | $(eval $(call DIR_clean_template,$(dir))) \ |
| 82 | $(eval $(call DIR_all_template,$(dir))) \ |
| 83 | ) |