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 | |
Oliver Smith | 64d6cc4 | 2021-03-17 18:44:42 +0100 | [diff] [blame] | 16 | SUBDIRS= \ |
| 17 | bsc \ |
| 18 | bsc-nat \ |
| 19 | bts \ |
| 20 | cbc \ |
| 21 | ccid \ |
| 22 | fr \ |
| 23 | fr-net \ |
| 24 | gbproxy \ |
| 25 | ggsn_tests \ |
| 26 | hlr \ |
| 27 | mgw \ |
| 28 | mme \ |
| 29 | msc \ |
| 30 | ns \ |
Harald Welte | c4ac9e0 | 2021-04-22 23:07:44 +0200 | [diff] [blame] | 31 | pcap-client \ |
Oliver Smith | 64d6cc4 | 2021-03-17 18:44:42 +0100 | [diff] [blame] | 32 | pcu \ |
| 33 | pgw \ |
| 34 | remsim \ |
| 35 | sccp \ |
| 36 | selftest \ |
| 37 | sgsn \ |
| 38 | simtrace \ |
| 39 | sip \ |
| 40 | smlc \ |
| 41 | stp \ |
| 42 | sysinfo \ |
| 43 | $(NULL) |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 44 | |
Stefan Sperling | b0ad3d8 | 2018-06-25 15:19:17 +0200 | [diff] [blame] | 45 | NPROC=$(shell nproc 2>/dev/null) |
| 46 | ifeq ($(NPROC),) |
| 47 | NPROC=1 |
| 48 | endif |
| 49 | PARALLEL_MAKE ?= -j$(NPROC) |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 50 | |
| 51 | # This master makefile allows you to do things like |
| 52 | # make clean (remove all generated binary, c++ and symlinks) |
| 53 | # make compile (compile ttcn3 into c++) |
| 54 | # make all (compile c++ into executable) |
| 55 | # |
| 56 | # as well as per-subdirectory targets like |
| 57 | # |
| 58 | # make bsc/clean |
| 59 | # make bsc/compile |
| 60 | # make bsc/all |
| 61 | # make bsc (equivalent to bsc/all) |
| 62 | |
Harald Welte | 6807982 | 2017-12-12 16:30:53 +0100 | [diff] [blame] | 63 | default: deps all |
| 64 | |
| 65 | .PHONY: deps |
| 66 | deps: |
| 67 | $(MAKE) -C deps |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 68 | |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 69 | # 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] | 70 | .PHONY: deps-update |
| 71 | deps-update: |
Stefan Sperling | 61c11e9 | 2018-03-20 18:25:26 +0100 | [diff] [blame] | 72 | $(MAKE) -C deps |
Harald Welte | 6bef5dd | 2018-02-15 18:31:22 +0100 | [diff] [blame] | 73 | |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 74 | compile: $(foreach dir,$(SUBDIRS),$(dir)/compile) |
| 75 | clean: $(foreach dir,$(SUBDIRS),$(dir)/clean) |
| 76 | all: $(foreach dir,$(SUBDIRS),$(dir)/all) |
| 77 | |
| 78 | define DIR_Makefile_template |
| 79 | $(1)/Makefile: |
| 80 | (cd $(1) && ./gen_links.sh && ./regen_makefile.sh) |
| 81 | endef |
| 82 | |
| 83 | define DIR_compile_template |
| 84 | .PHONY: $(1)/compile |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 85 | $(1)/compile: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 86 | $(MAKE) -C $(1) compile |
| 87 | endef |
| 88 | |
| 89 | define DIR_clean_template |
| 90 | .PHONY: $(1)/clean |
| 91 | $(1)/clean: $(1)/Makefile |
| 92 | $(MAKE) -C $(1) clean |
| 93 | (cd $(1) && ../rmlinks.sh && rm Makefile) |
| 94 | endef |
| 95 | |
| 96 | define DIR_all_template |
| 97 | $(1): $(1)/all |
| 98 | .PHONY: $(1)/all |
Harald Welte | f6f7846 | 2017-12-12 17:31:25 +0100 | [diff] [blame] | 99 | $(1)/all: deps $(1)/Makefile |
Harald Welte | add12df | 2017-12-12 15:51:39 +0100 | [diff] [blame] | 100 | $(MAKE) -C $(1) compile |
| 101 | $(MAKE) $(PARALLEL_MAKE) -C $(1) |
| 102 | endef |
| 103 | |
| 104 | $(foreach dir,$(SUBDIRS), \ |
| 105 | $(eval $(call DIR_Makefile_template,$(dir))) \ |
| 106 | $(eval $(call DIR_compile_template,$(dir))) \ |
| 107 | $(eval $(call DIR_clean_template,$(dir))) \ |
| 108 | $(eval $(call DIR_all_template,$(dir))) \ |
| 109 | ) |