]> git.ipfire.org Git - thirdparty/bird.git/blob - Makefile.in
Doc: BFD update
[thirdparty/bird.git] / Makefile.in
1 # Makefile for the BIRD Internet Routing Daemon
2 # (c) 1999--2000 Martin Mares <mj@ucw.cz>
3 # (c) 2016 Jan Moskyto Matejka <mq@ucw.cz>
4
5 # Disable build-in rules
6 MAKEFLAGS += -r
7
8 # Variable definitions
9 CPPFLAGS=-I$(objdir) -I$(srcdir) @CPPFLAGS@
10 CFLAGS=$(CPPFLAGS) @CFLAGS@
11 LDFLAGS=@LDFLAGS@
12 M4FLAGS=@M4FLAGS@
13 BISONFLAGS=@BISONFLAGS@
14 LIBS=@LIBS@
15 DAEMON_LIBS=@DAEMON_LIBS@
16 CLIENT_LIBS=@CLIENT_LIBS@
17 CC=@CC@
18 M4=@M4@
19 BISON=@BISON@
20 FLEX=@FLEX@
21 RANLIB=@RANLIB@
22 INSTALL=@INSTALL@
23 INSTALL_PROGRAM=@INSTALL_PROGRAM@
24 INSTALL_DATA=@INSTALL_DATA@
25
26 client=$(addprefix $(exedir)/,@CLIENT@)
27 daemon=$(exedir)/bird
28 protocols=@protocols@
29 PROTO_BUILD := $(protocols) dev kif krt
30
31 prefix=@prefix@
32 exec_prefix=@exec_prefix@
33 bindir=@bindir@
34 sbindir=@sbindir@
35 sysconfdir=@sysconfdir@
36 localstatedir=@localstatedir@
37 runstatedir=@runstatedir@
38 docdir=@prefix@/doc
39
40 srcdir := @srcdir@
41 objdir := @objdir@
42 exedir := @exedir@
43
44 git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null))
45 ifneq ($(git-label),)
46 CFLAGS += -DGIT_LABEL="$(git-label)"
47 endif
48
49 ifeq ($(objdir),.)
50 objdir := $(realpath .)
51 endif
52
53 ifeq ($(VERBOSE),)
54 E:=@
55 Q:=@
56 else
57 E:=@\#
58 Q:=
59 endif
60
61 ifneq ($(COLOR),)
62 CFLAGS += -fdiagnostics-color=always
63 endif
64
65 # Meta rules
66 docgoals := docs userdocs progdocs
67 testgoals := check test tests tests_run
68 cleangoals := clean distclean testsclean
69 .PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope prepare
70
71 all: daemon cli
72
73 daemon: $(daemon)
74 cli: $(client)
75
76 $(daemon): LIBS += $(DAEMON_LIBS)
77
78 # Include directories
79 dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@
80
81 # conf/Makefile declarations needed for all other modules
82 conf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o)
83 conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
84 cf-local = $(conf-y-targets): $(s)config.Y
85
86 src-o-files = $(patsubst %.c,$(o)%.o,$(src))
87 tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))
88
89 all-daemon = $(daemon): $(obj)
90 all-client = $(client): $(obj)
91
92 s = $(dir $(lastword $(MAKEFILE_LIST)))
93 ifeq ($(srcdir),.)
94 o = $(objdir)/$(s)
95 else
96 o = $(patsubst $(srcdir)%,$(objdir)%,$(s))
97 endif
98
99 define clean_in =
100 clean::
101 rm -f $(addprefix $(o),$(1))
102 endef
103
104 clean = $(eval $(call clean_in,$(1)))
105
106 # Include main Makefiles of the directories
107 include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
108
109 # Generic rules
110 # Object file rules
111 $(objdir)/%.o: $(srcdir)/%.c | prepare
112 $(E)echo CC -o $@ -c $<
113 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
114
115 $(objdir)/%.o: $(objdir)/%.c | prepare
116 $(E)echo CC -o $@ -c $<
117 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
118
119 # Debug: Preprocessed source rules
120 $(objdir)/%.E: $(srcdir)/%.c | prepare
121 $(E)echo CC -o $@ -E $<
122 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
123
124 $(objdir)/%.E: $(objdir)/%.c | prepare
125 $(E)echo CC -o $@ -E $<
126 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
127
128 # Debug: Assembler object rules
129 $(objdir)/%.S: $(srcdir)/%.c | prepare
130 $(E)echo CC -o $@ -S $<
131 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
132
133 $(objdir)/%.S: $(objdir)/%.c | prepare
134 $(E)echo CC -o $@ -S $<
135 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
136
137 # Finally include the computed dependencies:
138 DEPS = $(shell find $(objdir) -name '*.d')
139
140 # ## if there is at least one non-clean goal
141 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
142 -include $(DEPS)
143 endif
144
145 # ## if the implicit goal is called
146 ifeq ($(MAKECMDGOALS),)
147 -include $(DEPS)
148 endif
149
150 # Rule for pre-generating all generated includables
151 # before compiling any C file
152 prepare: $(objdir)/sysdep/paths.h | $(objdir)/.dir-stamp
153
154 $(objdir)/.dir-stamp: Makefile
155 $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
156 $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
157 $(Q)touch $@
158
159 $(client) $(daemon):
160 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
161 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
162
163 $(objdir)/sysdep/paths.h: Makefile
164 $(E)echo GEN $@
165 $(Q)echo >$@ "/* Generated by Makefile, don't edit manually! */"
166 $(Q)echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
167 $(Q)echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
168 $(Q)if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
169
170 # Unit tests rules
171
172 tests_targets_ok = $(addsuffix .ok,$(tests_targets))
173
174 $(tests_targets): %: %.o $(tests_objs) | prepare
175 $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
176 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
177
178 # Hack to avoid problems with tests linking everything
179 $(tests_targets): LIBS += $(DAEMON_LIBS)
180
181 $(tests_targets_ok): %.ok: %
182 $(Q)$* 2>/dev/null && touch $*.ok
183
184 test: testsclean check
185 check: tests tests_run
186 tests: $(tests_targets)
187 tests_run: $(tests_targets_ok)
188
189 STATIC_CHECKERS_ENABLE := nullability.NullableDereferenced nullability.NullablePassedToNonnull nullability.NullableReturnedFromNonnull optin.portability.UnixAPI valist.CopyToSelf valist.Uninitialized valist.Unterminated
190 STATIC_CHECKERS_DISABLE := deadcode.DeadStores
191 STATIC_SCAN_FLAGS := -o $(objdir)/static-scan/ $(addprefix -enable-checker ,$(STATIC_CHECKERS_ENABLE)) $(addprefix -disable-checker ,$(STATIC_CHECKERS_DISABLE))
192
193 static-scan:
194 $(E)echo Running static code analysis
195 $(Q)$(MAKE) clean
196 $(Q)scan-build $(STATIC_SCAN_FLAGS) $(MAKE) -$(MAKEFLAGS)
197
198 tags:
199 cd $(srcdir) ; etags -lc `find $(dirs) -name '*.[chY]'`
200
201 cscope:
202 cd $(srcdir) ; find $(dirs) -name '*.[chY]' > cscope.files ; cscope -b
203
204 # Install
205
206 install: all
207 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir)
208 for BIN in bird @CLIENT@ ; do \
209 $(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ; \
210 done
211 if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \
212 $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \
213 else \
214 echo "Not overwriting old bird.conf" ; \
215 fi
216
217 install-docs:
218 $(INSTALL) -d $(DESTDIR)/$(docdir)
219 $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/
220
221 # Cleanup
222 clean::
223 rm -f $(objdir)/sysdep/paths.h $(objdir)/nest/proto-build.c
224 rm -f $(addprefix $(exedir)/,bird birdc birdcl)
225 find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
226
227 testsclean:
228 rm -f $(tests_targets_ok)
229
230 ifeq ($(objdir),obj)
231 distclean: clean
232 rm -rf $(objdir)
233 rm -f config.log config.status configure Makefile
234 else
235 distclean: clean
236 rm -rf * .dir-stamp
237 rm -f config.log config.status configure Makefile
238 endif