File: Makefile.in

package info (click to toggle)
bird3 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,600 kB
  • sloc: ansic: 85,199; sh: 3,807; perl: 3,484; lex: 976; python: 726; makefile: 527; xml: 520; sed: 13
file content (307 lines) | stat: -rw-r--r-- 8,942 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Makefile for the BIRD Internet Routing Daemon
# (c) 1999--2000 Martin Mares <mj@ucw.cz>
# (c) 2016--2025 Maria Matejka <mq@ucw.cz>

# Disable build-in rules
MAKEFLAGS += -r

# Variable definitions
CPPFLAGS=-I$(objdir) -I$(srcdir) @CPPFLAGS@
CFLAGS=$(CPPFLAGS) @CFLAGS@
LDFLAGS=@LDFLAGS@
M4FLAGS=@M4FLAGS@
BISONFLAGS=@BISONFLAGS@
LIBS=@LIBS@
DAEMON_LIBS=@DAEMON_LIBS@
CLIENT_LIBS=@CLIENT_LIBS@
CC=@CC@
M4=@M4@
BISON=@BISON@
FLEX=@FLEX@
RANLIB=@RANLIB@
INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DATA=@INSTALL_DATA@
PANDOC=@PANDOC@

client=$(addprefix $(exedir)/,@CLIENT@)
daemon=$(exedir)/bird
protocols=@protocols@
PROTO_BUILD := $(protocols) dev kif krt

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
runstatedir=@runstatedir@
docdir=@prefix@/doc

srcdir := @srcdir@
objdir := @objdir@
exedir := @exedir@

# Find out which version we are actually building
# This is rewritten by the release tools by hardcoded version
VERSION := $(strip $(shell $(srcdir)/tools/version))

CFLAGS += -DBIRD_VERSION='"$(VERSION)"'

ifeq ($(objdir),.)
  objdir := $(realpath .)
endif

ifeq ($(VERBOSE),)
  E:=@
  Q:=@
else
  E:=@\#
  Q:=
endif

ifneq ($(COLOR),)
  CFLAGS += -fdiagnostics-color=always
endif

# Meta rules
docgoals := docs userdocs progdocs
testgoals := check test tests tests_run
cleangoals := clean distclean testsclean
.PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope prepare gitlab

all: daemon cli

daemon: $(daemon)
cli: $(client)

$(daemon): LIBS += $(DAEMON_LIBS)

# Include directories
dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@

# conf/Makefile declarations needed for all other modules
conf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o)
conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
cf-local = $(conf-y-targets): $(s)config.Y

src-o-files = $(patsubst %.c,$(o)%.o,$(src))
tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))

all-daemon = $(daemon): $(obj)
all-client = $(client): $(obj)

s = $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(srcdir),.)
  o = $(objdir)/$(s)
else
  o = $(patsubst $(srcdir)%,$(objdir)%,$(s))
endif

define clean_in =
clean::
	rm -f $(addprefix $(o),$(1))
endef

clean = $(eval $(call clean_in,$(1)))

# Include main Makefiles of the directories
include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))

# Generic rules
# Object file rules
$(objdir)/%.o: $(srcdir)/%.c | prepare
	$(E)echo CC -o $@ -c $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<

$(objdir)/%.o: $(objdir)/%.c | prepare
	$(E)echo CC -o $@ -c $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<

# Debug: Preprocessed source rules
$(objdir)/%.E: $(srcdir)/%.c | prepare
	$(E)echo CC -o $@ -E $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<

$(objdir)/%.E: $(objdir)/%.c | prepare
	$(E)echo CC -o $@ -E $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<

# Debug: Assembler object rules
$(objdir)/%.S: $(srcdir)/%.c | prepare
	$(E)echo CC -o $@ -S $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<

$(objdir)/%.S: $(objdir)/%.c | prepare
	$(E)echo CC -o $@ -S $<
	$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<

# Finally include the computed dependencies:
DEPS = $(shell find $(objdir) -name '*.d')

# ## if there is at least one non-clean goal
ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
-include $(DEPS)
endif

# ## if the implicit goal is called
ifeq ($(MAKECMDGOALS),)
-include $(DEPS)
endif

# Rule for pre-generating all generated includables
# before compiling any C file
prepare: $(objdir)/sysdep/paths.h | $(objdir)/.dir-stamp

$(objdir)/.dir-stamp: Makefile
	$(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
	$(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
	$(Q)touch $@

$(client) $(daemon):
	$(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
	$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

$(objdir)/sysdep/paths.h: Makefile
	$(E)echo GEN $@
	$(Q)echo  >$@ "/* Generated by Makefile, don't edit manually! */"
	$(Q)echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
	$(Q)echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
	$(Q)if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi

# Unit tests rules

tests_targets_ok = $(addsuffix .ok,$(tests_targets))

$(tests_targets): %: %.o $(tests_objs) | prepare
	$(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
	$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

# Hack to avoid problems with tests linking everything
$(tests_targets): LIBS += $(DAEMON_LIBS)

$(tests_targets_ok): %.ok: %
	$(Q)$* 2>/dev/null && touch $*.ok

test: testsclean check
check: tests tests_run
tests: $(tests_targets)
tests_run: $(tests_targets_ok)

STATIC_CHECKERS_ENABLE := nullability.NullableDereferenced nullability.NullablePassedToNonnull nullability.NullableReturnedFromNonnull optin.portability.UnixAPI valist.CopyToSelf valist.Uninitialized valist.Unterminated
STATIC_CHECKERS_DISABLE := deadcode.DeadStores
STATIC_SCAN_FLAGS := -o $(objdir)/static-scan/ $(addprefix -enable-checker ,$(STATIC_CHECKERS_ENABLE)) $(addprefix -disable-checker ,$(STATIC_CHECKERS_DISABLE))

static-scan:
	$(E)echo Running static code analysis
	$(Q)$(MAKE) clean
	$(Q)scan-build $(STATIC_SCAN_FLAGS) $(MAKE) -$(MAKEFLAGS)

tags:
	cd $(srcdir) ; etags -lc `find $(dirs) -name '*.[chY]'`

cscope:
	cd $(srcdir) ; find $(dirs) -name '*.[chY]' > cscope.files ; cscope -b

# Gitlab CI tests
gitlab-venv: .gitlab-ci.yml
gitlab-venv: USE_VENV := VENV

gitlab-local: .gitlab-ci.yml
gitlab-local: USE_VENV :=

.gitlab-ci.yml: $(addprefix misc/gitlab/,pipeline.py data.yml.j2 template.yml.j2)
	($(if $(USE_VENV),\
		VENV=$$(mktemp -d); \
		python3 -m venv $$VENV; \
		. $$VENV/bin/activate; \
		pip3 install jinja2 pyaml; \
		,) \
		python3 misc/gitlab/pipeline.py > $@; \
		$(if $(USE_VENV),rm -rf $$VENV,) \
		)

# Install

install: all
	$(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir)
	for BIN in bird @CLIENT@ ; do								\
		$(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ;		\
	done
	if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then						\
		$(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ;	\
	else											\
		echo "Not overwriting old bird.conf" ;						\
	fi

install-docs:
	$(INSTALL) -d $(DESTDIR)/$(docdir)
	$(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/

# Packaging
archive:
	tools/make-archive

deb:
	tools/make-deb

rpm:
	tools/make-rpm

# Cleanup
clean::
	rm -f $(objdir)/sysdep/paths.h $(objdir)/nest/proto-build.c
	rm -f $(addprefix $(exedir)/,bird birdc birdcl)
	find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'

testsclean:
	rm -f $(tests_targets_ok)

ifeq ($(objdir),obj)
distclean: clean
	rm -rf $(objdir)
	rm -f config.log config.status configure Makefile
else
distclean: clean
	rm -rf * .dir-stamp
	rm -f config.log config.status configure Makefile
endif

# Help dump
help:
	@echo "============================= BIRD make system ============================="
	@echo
	@echo "To build BIRD directly from sources, run './configure'. For more information"
	@echo "about that process, run './configure --help'."
	@echo "To build BIRD from Git repo, run 'autoreconf' before './configure'."
	@echo
	@echo "Source build options:"
	@echo "    make all                  Build BIRD binaries."
	@echo "    make test                 Build and run unit tests."
	@echo "    make docs                 Build documentation."
	@echo
	@echo "Partial build options:"
	@echo "    make obj/path/to/foo.o    Build an object file, don't link."
	@echo "    make obj/path/to/foo.E    Run only the C preprocessor."
	@echo "    make obj/path/to/foo.S    Generate an assembler dump."
	@echo
	@echo "Development tools:"
	@echo "    make static-scan          Run CLang static analyzer."
	@echo "    make tags                 Generate ETags cache."
	@echo "    make cscope               Generate CScope cache."
	@echo
	@echo "Auxiliary commands:"
	@echo "    make help                 Show this help."
	@echo "    make clean                Cleanup the build directory. Useful after"
	@echo "                              major changes or branch switch."
	@echo "    make distclean            Cleanup everything so that you will have to"
	@echo "                              run './configure' again."
	@echo "    make gitlab-local         Re-generate .gitlab-ci.yml without venv"
	@echo "    make gitlab-venv          Re-generate .gitlab-ci.yml inside a tmp venv"
	@echo
	@echo "Distribution commands:"
	@echo "    make install              Install binaries into the system."
	@echo "    make archive              Create a release archive (TGZ).
	@echo "                              This must exist for 'make deb' and 'make rpm'."
	@echo "    make deb                  Create a DEB package for the current system."
	@echo "    make rpm                  Create an RPM package for the current system."