blob: fbd380cbc4d135eb1a1e9808204bb6f16ef7f2b8 [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 \
Daniel Willmanndd7c0752022-02-17 16:32:15 +010027 hnbgw \
Pau Espin Pedrolb54acca2021-11-22 20:35:44 +010028 hnodeb \
Oliver Smith64d6cc42021-03-17 18:44:42 +010029 mgw \
30 mme \
31 msc \
32 ns \
Harald Weltec4ac9e02021-04-22 23:07:44 +020033 pcap-client \
Oliver Smith64d6cc42021-03-17 18:44:42 +010034 pcu \
35 pgw \
36 remsim \
37 sccp \
38 selftest \
39 sgsn \
40 simtrace \
41 sip \
42 smlc \
43 stp \
44 sysinfo \
45 $(NULL)
Harald Welteadd12df2017-12-12 15:51:39 +010046
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +020047NPROC=$(shell nproc 2>/dev/null)
48ifeq ($(NPROC),)
49NPROC=1
50endif
51PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +010052
53# This master makefile allows you to do things like
54# make clean (remove all generated binary, c++ and symlinks)
55# make compile (compile ttcn3 into c++)
56# make all (compile c++ into executable)
57#
58# as well as per-subdirectory targets like
59#
60# make bsc/clean
61# make bsc/compile
62# make bsc/all
63# make bsc (equivalent to bsc/all)
64
Harald Welte68079822017-12-12 16:30:53 +010065default: deps all
66
67.PHONY: deps
68deps:
Vadim Yanitskiy134aea92022-02-10 00:47:50 +060069 $(MAKE) $(PARALLEL_MAKE) -C deps
Harald Welteadd12df2017-12-12 15:51:39 +010070
Stefan Sperling61c11e92018-03-20 18:25:26 +010071# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010072.PHONY: deps-update
73deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010074 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010075
Harald Welteadd12df2017-12-12 15:51:39 +010076compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
77clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
78all: $(foreach dir,$(SUBDIRS),$(dir)/all)
79
80define DIR_Makefile_template
81$(1)/Makefile:
82 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
83endef
84
85define DIR_compile_template
86.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010087$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010088 $(MAKE) -C $(1) compile
89endef
90
91define DIR_clean_template
92.PHONY: $(1)/clean
93$(1)/clean: $(1)/Makefile
94 $(MAKE) -C $(1) clean
95 (cd $(1) && ../rmlinks.sh && rm Makefile)
96endef
97
98define DIR_all_template
99$(1): $(1)/all
100.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +0100101$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +0100102 $(MAKE) -C $(1) compile
103 $(MAKE) $(PARALLEL_MAKE) -C $(1)
104endef
105
106$(foreach dir,$(SUBDIRS), \
107 $(eval $(call DIR_Makefile_template,$(dir))) \
108 $(eval $(call DIR_compile_template,$(dir))) \
109 $(eval $(call DIR_clean_template,$(dir))) \
110 $(eval $(call DIR_all_template,$(dir))) \
111 )
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300112
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200113.PHONY: tags regen-diameter-types-ttcn
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300114tags:
115 find $(shell pwd) \
116 -type f -name "*.ttcn" -o \
117 -type f -name "*.ttcnpp" | \
118 xargs ctags
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200119
120regen-diameter-types-ttcn:
121 (cd library/ && ./regen-DIAMETER_Types_ttcn.sh)