blob: 5a35e6ec083f0184a2d7813cf2fb8fba51c7fdb3 [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= \
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010017 asterisk \
Oliver Smith64d6cc42021-03-17 18:44:42 +010018 bsc \
19 bsc-nat \
20 bts \
21 cbc \
22 ccid \
Harald Weltec98d9a92019-08-22 10:53:23 +020023 dia2gsup \
Oliver Smith64d6cc42021-03-17 18:44:42 +010024 fr \
25 fr-net \
Pau Espin Pedrol965ac642023-10-16 18:12:45 +020026 epdg \
Oliver Smith64d6cc42021-03-17 18:44:42 +010027 gbproxy \
28 ggsn_tests \
29 hlr \
Daniel Willmanndd7c0752022-02-17 16:32:15 +010030 hnbgw \
Pau Espin Pedrolb54acca2021-11-22 20:35:44 +010031 hnodeb \
Pau Espin Pedrolad4179b2023-10-10 19:12:26 +020032 hss \
Philipp Maierbb169b22024-03-04 11:09:00 +010033 ipad \
Oliver Smith64d6cc42021-03-17 18:44:42 +010034 mgw \
35 mme \
36 msc \
37 ns \
Harald Weltec4ac9e02021-04-22 23:07:44 +020038 pcap-client \
Oliver Smith64d6cc42021-03-17 18:44:42 +010039 pcu \
40 pgw \
41 remsim \
Vadim Yanitskiy95cd9352024-05-31 18:29:17 +070042 s1gw \
Oliver Smith64d6cc42021-03-17 18:44:42 +010043 sccp \
44 selftest \
45 sgsn \
46 simtrace \
47 sip \
48 smlc \
49 stp \
50 sysinfo \
Neels Hofmeyr2d292742022-06-07 23:58:05 +020051 upf \
Oliver Smith64d6cc42021-03-17 18:44:42 +010052 $(NULL)
Harald Welteadd12df2017-12-12 15:51:39 +010053
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +020054NPROC=$(shell nproc 2>/dev/null)
55ifeq ($(NPROC),)
56NPROC=1
57endif
58PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +010059
60# This master makefile allows you to do things like
61# make clean (remove all generated binary, c++ and symlinks)
62# make compile (compile ttcn3 into c++)
63# make all (compile c++ into executable)
64#
65# as well as per-subdirectory targets like
66#
67# make bsc/clean
68# make bsc/compile
69# make bsc/all
70# make bsc (equivalent to bsc/all)
71
Harald Welte68079822017-12-12 16:30:53 +010072default: deps all
73
Pau Espin Pedrol2bd2ea22023-05-04 12:58:27 +020074# Eclipse GitLab has rate limiting and sometimes to many concurrent conns fail.
75# If -jN fails, retry with -j1.
Harald Welte68079822017-12-12 16:30:53 +010076.PHONY: deps
77deps:
Pau Espin Pedrol2bd2ea22023-05-04 12:58:27 +020078 ($(MAKE) $(PARALLEL_MAKE) -C deps || $(MAKE) -j1 -C deps)
Harald Welteadd12df2017-12-12 15:51:39 +010079
Stefan Sperling61c11e92018-03-20 18:25:26 +010080# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010081.PHONY: deps-update
82deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010083 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010084
Harald Welteadd12df2017-12-12 15:51:39 +010085compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
86clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
87all: $(foreach dir,$(SUBDIRS),$(dir)/all)
88
89define DIR_Makefile_template
90$(1)/Makefile:
91 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
92endef
93
94define DIR_compile_template
95.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010096$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010097 $(MAKE) -C $(1) compile
98endef
99
100define DIR_clean_template
101.PHONY: $(1)/clean
102$(1)/clean: $(1)/Makefile
103 $(MAKE) -C $(1) clean
104 (cd $(1) && ../rmlinks.sh && rm Makefile)
105endef
106
107define DIR_all_template
108$(1): $(1)/all
109.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +0100110$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +0100111 $(MAKE) -C $(1) compile
112 $(MAKE) $(PARALLEL_MAKE) -C $(1)
113endef
114
115$(foreach dir,$(SUBDIRS), \
116 $(eval $(call DIR_Makefile_template,$(dir))) \
117 $(eval $(call DIR_compile_template,$(dir))) \
118 $(eval $(call DIR_clean_template,$(dir))) \
119 $(eval $(call DIR_all_template,$(dir))) \
120 )
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300121
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200122.PHONY: tags regen-diameter-types-ttcn
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300123tags:
124 find $(shell pwd) \
125 -type f -name "*.ttcn" -o \
126 -type f -name "*.ttcnpp" | \
127 xargs ctags
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200128
129regen-diameter-types-ttcn:
130 (cd library/ && ./regen-DIAMETER_Types_ttcn.sh)