blob: 87ce75917898fed422481fa78ed768a87c588e83 [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 \
Pau Espin Pedrolb54acca2021-11-22 20:35:44 +010027 hnodeb \
Oliver Smith64d6cc42021-03-17 18:44:42 +010028 mgw \
29 mme \
30 msc \
31 ns \
Harald Weltec4ac9e02021-04-22 23:07:44 +020032 pcap-client \
Oliver Smith64d6cc42021-03-17 18:44:42 +010033 pcu \
34 pgw \
35 remsim \
36 sccp \
37 selftest \
38 sgsn \
39 simtrace \
40 sip \
41 smlc \
42 stp \
43 sysinfo \
44 $(NULL)
Harald Welteadd12df2017-12-12 15:51:39 +010045
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +020046NPROC=$(shell nproc 2>/dev/null)
47ifeq ($(NPROC),)
48NPROC=1
49endif
50PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +010051
52# This master makefile allows you to do things like
53# make clean (remove all generated binary, c++ and symlinks)
54# make compile (compile ttcn3 into c++)
55# make all (compile c++ into executable)
56#
57# as well as per-subdirectory targets like
58#
59# make bsc/clean
60# make bsc/compile
61# make bsc/all
62# make bsc (equivalent to bsc/all)
63
Harald Welte68079822017-12-12 16:30:53 +010064default: deps all
65
66.PHONY: deps
67deps:
68 $(MAKE) -C deps
Harald Welteadd12df2017-12-12 15:51:39 +010069
Stefan Sperling61c11e92018-03-20 18:25:26 +010070# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010071.PHONY: deps-update
72deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010073 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010074
Harald Welteadd12df2017-12-12 15:51:39 +010075compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
76clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
77all: $(foreach dir,$(SUBDIRS),$(dir)/all)
78
79define DIR_Makefile_template
80$(1)/Makefile:
81 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
82endef
83
84define DIR_compile_template
85.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010086$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010087 $(MAKE) -C $(1) compile
88endef
89
90define DIR_clean_template
91.PHONY: $(1)/clean
92$(1)/clean: $(1)/Makefile
93 $(MAKE) -C $(1) clean
94 (cd $(1) && ../rmlinks.sh && rm Makefile)
95endef
96
97define DIR_all_template
98$(1): $(1)/all
99.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +0100100$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +0100101 $(MAKE) -C $(1) compile
102 $(MAKE) $(PARALLEL_MAKE) -C $(1)
103endef
104
105$(foreach dir,$(SUBDIRS), \
106 $(eval $(call DIR_Makefile_template,$(dir))) \
107 $(eval $(call DIR_compile_template,$(dir))) \
108 $(eval $(call DIR_clean_template,$(dir))) \
109 $(eval $(call DIR_all_template,$(dir))) \
110 )
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300111
112.PHONY: tags
113tags:
114 find $(shell pwd) \
115 -type f -name "*.ttcn" -o \
116 -type f -name "*.ttcnpp" | \
117 xargs ctags