blob: 81540bacf20d953c108cf6d53c7b8b3983025590 [file] [log] [blame]
Harald Welte0cdf0712019-06-19 18:15:38 +02001# 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 Smith64d6cc42021-03-17 18:44:42 +010016SUBDIRS= \
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 \
31 pcu \
32 pgw \
33 remsim \
34 sccp \
35 selftest \
36 sgsn \
37 simtrace \
38 sip \
39 smlc \
40 stp \
41 sysinfo \
42 $(NULL)
Harald Welteadd12df2017-12-12 15:51:39 +010043
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +020044NPROC=$(shell nproc 2>/dev/null)
45ifeq ($(NPROC),)
46NPROC=1
47endif
48PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +010049
50# This master makefile allows you to do things like
51# make clean (remove all generated binary, c++ and symlinks)
52# make compile (compile ttcn3 into c++)
53# make all (compile c++ into executable)
54#
55# as well as per-subdirectory targets like
56#
57# make bsc/clean
58# make bsc/compile
59# make bsc/all
60# make bsc (equivalent to bsc/all)
61
Harald Welte68079822017-12-12 16:30:53 +010062default: deps all
63
64.PHONY: deps
65deps:
66 $(MAKE) -C deps
Harald Welteadd12df2017-12-12 15:51:39 +010067
Stefan Sperling61c11e92018-03-20 18:25:26 +010068# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010069.PHONY: deps-update
70deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010071 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010072
Harald Welteadd12df2017-12-12 15:51:39 +010073compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
74clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
75all: $(foreach dir,$(SUBDIRS),$(dir)/all)
76
77define DIR_Makefile_template
78$(1)/Makefile:
79 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
80endef
81
82define DIR_compile_template
83.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010084$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010085 $(MAKE) -C $(1) compile
86endef
87
88define DIR_clean_template
89.PHONY: $(1)/clean
90$(1)/clean: $(1)/Makefile
91 $(MAKE) -C $(1) clean
92 (cd $(1) && ../rmlinks.sh && rm Makefile)
93endef
94
95define DIR_all_template
96$(1): $(1)/all
97.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +010098$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010099 $(MAKE) -C $(1) compile
100 $(MAKE) $(PARALLEL_MAKE) -C $(1)
101endef
102
103$(foreach dir,$(SUBDIRS), \
104 $(eval $(call DIR_Makefile_template,$(dir))) \
105 $(eval $(call DIR_compile_template,$(dir))) \
106 $(eval $(call DIR_clean_template,$(dir))) \
107 $(eval $(call DIR_all_template,$(dir))) \
108 )