blob: 0ed632f5a9eb75af956917679619bfffa2816106 [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 \
Harald Weltec98d9a92019-08-22 10:53:23 +020022 dia2gsup \
Oliver Smith64d6cc42021-03-17 18:44:42 +010023 fr \
24 fr-net \
25 gbproxy \
26 ggsn_tests \
27 hlr \
Daniel Willmanndd7c0752022-02-17 16:32:15 +010028 hnbgw \
Pau Espin Pedrolb54acca2021-11-22 20:35:44 +010029 hnodeb \
Pau Espin Pedrolad4179b2023-10-10 19:12:26 +020030 hss \
Oliver Smith64d6cc42021-03-17 18:44:42 +010031 mgw \
32 mme \
33 msc \
34 ns \
Harald Weltec4ac9e02021-04-22 23:07:44 +020035 pcap-client \
Oliver Smith64d6cc42021-03-17 18:44:42 +010036 pcu \
37 pgw \
38 remsim \
39 sccp \
40 selftest \
41 sgsn \
42 simtrace \
43 sip \
44 smlc \
45 stp \
46 sysinfo \
Neels Hofmeyr2d292742022-06-07 23:58:05 +020047 upf \
Oliver Smith64d6cc42021-03-17 18:44:42 +010048 $(NULL)
Harald Welteadd12df2017-12-12 15:51:39 +010049
Stefan Sperlingb0ad3d82018-06-25 15:19:17 +020050NPROC=$(shell nproc 2>/dev/null)
51ifeq ($(NPROC),)
52NPROC=1
53endif
54PARALLEL_MAKE ?= -j$(NPROC)
Harald Welteadd12df2017-12-12 15:51:39 +010055
56# This master makefile allows you to do things like
57# make clean (remove all generated binary, c++ and symlinks)
58# make compile (compile ttcn3 into c++)
59# make all (compile c++ into executable)
60#
61# as well as per-subdirectory targets like
62#
63# make bsc/clean
64# make bsc/compile
65# make bsc/all
66# make bsc (equivalent to bsc/all)
67
Harald Welte68079822017-12-12 16:30:53 +010068default: deps all
69
Pau Espin Pedrol2bd2ea22023-05-04 12:58:27 +020070# Eclipse GitLab has rate limiting and sometimes to many concurrent conns fail.
71# If -jN fails, retry with -j1.
Harald Welte68079822017-12-12 16:30:53 +010072.PHONY: deps
73deps:
Pau Espin Pedrol2bd2ea22023-05-04 12:58:27 +020074 ($(MAKE) $(PARALLEL_MAKE) -C deps || $(MAKE) -j1 -C deps)
Harald Welteadd12df2017-12-12 15:51:39 +010075
Stefan Sperling61c11e92018-03-20 18:25:26 +010076# deps-update target for backwards compat; now does the same as 'make deps'
Harald Welte6bef5dd2018-02-15 18:31:22 +010077.PHONY: deps-update
78deps-update:
Stefan Sperling61c11e92018-03-20 18:25:26 +010079 $(MAKE) -C deps
Harald Welte6bef5dd2018-02-15 18:31:22 +010080
Harald Welteadd12df2017-12-12 15:51:39 +010081compile: $(foreach dir,$(SUBDIRS),$(dir)/compile)
82clean: $(foreach dir,$(SUBDIRS),$(dir)/clean)
83all: $(foreach dir,$(SUBDIRS),$(dir)/all)
84
85define DIR_Makefile_template
86$(1)/Makefile:
87 (cd $(1) && ./gen_links.sh && ./regen_makefile.sh)
88endef
89
90define DIR_compile_template
91.PHONY: $(1)/compile
Harald Weltef6f78462017-12-12 17:31:25 +010092$(1)/compile: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +010093 $(MAKE) -C $(1) compile
94endef
95
96define DIR_clean_template
97.PHONY: $(1)/clean
98$(1)/clean: $(1)/Makefile
99 $(MAKE) -C $(1) clean
100 (cd $(1) && ../rmlinks.sh && rm Makefile)
101endef
102
103define DIR_all_template
104$(1): $(1)/all
105.PHONY: $(1)/all
Harald Weltef6f78462017-12-12 17:31:25 +0100106$(1)/all: deps $(1)/Makefile
Harald Welteadd12df2017-12-12 15:51:39 +0100107 $(MAKE) -C $(1) compile
108 $(MAKE) $(PARALLEL_MAKE) -C $(1)
109endef
110
111$(foreach dir,$(SUBDIRS), \
112 $(eval $(call DIR_Makefile_template,$(dir))) \
113 $(eval $(call DIR_compile_template,$(dir))) \
114 $(eval $(call DIR_clean_template,$(dir))) \
115 $(eval $(call DIR_all_template,$(dir))) \
116 )
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300117
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200118.PHONY: tags regen-diameter-types-ttcn
Vadim Yanitskiy600ebb22021-12-02 20:01:07 +0300119tags:
120 find $(shell pwd) \
121 -type f -name "*.ttcn" -o \
122 -type f -name "*.ttcnpp" | \
123 xargs ctags
Pau Espin Pedrolc24a18c2022-05-17 19:15:17 +0200124
125regen-diameter-types-ttcn:
126 (cd library/ && ./regen-DIAMETER_Types_ttcn.sh)