]> 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
30 prefix=@prefix@
31 exec_prefix=@exec_prefix@
32 bindir=@bindir@
33 sbindir=@sbindir@
34 sysconfdir=@sysconfdir@
35 localstatedir=@localstatedir@
36 runstatedir=@runstatedir@
37 docdir=@prefix@/doc
38
39 srcdir := @srcdir@
40 objdir := @objdir@
41 exedir := @exedir@
42
43 git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null))
44 ifneq ($(git-label),)
45 CFLAGS += -DGIT_LABEL="$(git-label)"
46 endif
47
48 ifeq ($(objdir),.)
49 objdir := $(realpath .)
50 endif
51
52 ifeq ($(VERBOSE),)
53 E:=@
54 Q:=@
55 else
56 E:=@\#
57 Q:=
58 endif
59
60 ifneq ($(COLOR),)
61 CFLAGS += -fdiagnostics-color=always
62 endif
63
64 # Meta rules
65 docgoals := docs userdocs progdocs
66 testgoals := check test tests tests_run
67 cleangoals := clean distclean testsclean
68 .PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope prepare
69
70 all: daemon cli
71
72 daemon: $(daemon)
73 cli: $(client)
74
75 $(daemon): LIBS += $(DAEMON_LIBS)
76
77 # Include directories
78 dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@
79
80 conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
81 cf-local = $(conf-y-targets): $(s)config.Y
82
83 src-o-files = $(patsubst %.c,$(o)%.o,$(src))
84 tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))
85
86 all-daemon = $(daemon): $(obj)
87 all-client = $(client): $(obj)
88
89 s = $(dir $(lastword $(MAKEFILE_LIST)))
90 ifeq ($(srcdir),.)
91 o = $(objdir)/$(s)
92 else
93 o = $(patsubst $(srcdir)%,$(objdir)%,$(s))
94 endif
95
96 define clean_in =
97 clean::
98 rm -f $(addprefix $(o),$(1))
99 endef
100
101 clean = $(eval $(call clean_in,$(1)))
102
103 include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
104
105 # Generic rules
106 # Object file rules
107 $(objdir)/%.o: $(srcdir)/%.c | prepare
108 $(E)echo CC -o $@ -c $<
109 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
110
111 $(objdir)/%.o: $(objdir)/%.c | prepare
112 $(E)echo CC -o $@ -c $<
113 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
114
115 # Debug: Preprocessed source rules
116 $(objdir)/%.E: $(srcdir)/%.c | prepare
117 $(E)echo CC -o $@ -E $<
118 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
119
120 $(objdir)/%.E: $(objdir)/%.c | prepare
121 $(E)echo CC -o $@ -E $<
122 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
123
124 # Debug: Assembler object rules
125 $(objdir)/%.S: $(srcdir)/%.c | prepare
126 $(E)echo CC -o $@ -S $<
127 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
128
129 $(objdir)/%.S: $(objdir)/%.c | prepare
130 $(E)echo CC -o $@ -S $<
131 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
132
133 # Finally include the computed dependencies:
134 DEPS = $(shell find $(objdir) -name '*.d')
135
136 # ## if there is at least one non-clean goal
137 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
138 -include $(DEPS)
139 endif
140
141 # ## if the implicit goal is called
142 ifeq ($(MAKECMDGOALS),)
143 -include $(DEPS)
144 endif
145
146 # Rule for pre-generating all generated includables
147 # before compiling any C file
148 prepare: $(objdir)/sysdep/paths.h | $(objdir)/.dir-stamp
149
150 $(objdir)/.dir-stamp: Makefile
151 $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
152 $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
153 $(Q)touch $@
154
155 $(client) $(daemon):
156 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
157 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
158
159 $(objdir)/sysdep/paths.h: Makefile
160 echo >$@ "/* Generated by Makefile, don't edit manually! */"
161 echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
162 echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
163 if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
164
165 # Unit tests rules
166
167 tests_targets_ok = $(addsuffix .ok,$(tests_targets))
168
169 $(tests_targets): %: %.o $(tests_objs) | prepare
170 $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
171 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
172
173 # Hack to avoid problems with tests linking everything
174 $(tests_targets): LIBS += $(DAEMON_LIBS)
175
176 $(tests_targets_ok): %.ok: %
177 $(Q)$* 2>/dev/null && touch $*.ok
178
179 test: testsclean check
180 check: tests tests_run
181 tests: $(tests_targets)
182 tests_run: $(tests_targets_ok)
183
184 tags:
185 cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
186
187 cscope:
188 cd $(srcdir) ; find $(dirs) -name *.[chY] > cscope.files ; cscope -b
189
190 # Install
191
192 install: all
193 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir)
194 for BIN in bird @CLIENT@ ; do \
195 $(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ; \
196 done
197 if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \
198 $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \
199 else \
200 echo "Not overwriting old bird.conf" ; \
201 fi
202
203 install-docs:
204 $(INSTALL) -d $(DESTDIR)/$(docdir)
205 $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/
206
207 # Cleanup
208 clean::
209 rm -f $(objdir)/sysdep/paths.h
210 rm -f $(addprefix $(exedir)/,bird birdc birdcl)
211 find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
212
213 testsclean:
214 rm -f $(tests_targets_ok)
215
216 ifeq ($(objdir),obj)
217 distclean: clean
218 rm -rf $(objdir)
219 rm -f config.log config.status configure Makefile
220 else
221 distclean: clean
222 rm -rf * .dir-stamp
223 rm -f config.log config.status configure Makefile
224 endif