]> git.ipfire.org Git - thirdparty/bird.git/blob - Makefile.in
Configure: Use standard --runstatedir option
[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
69 all: daemon cli
70
71 daemon: $(daemon)
72 cli: $(client)
73
74 $(daemon): LIBS += $(DAEMON_LIBS)
75
76 # Include directories
77 dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@
78
79 conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
80 cf-local = $(conf-y-targets): $(s)config.Y
81
82 src-o-files = $(patsubst %.c,$(o)%.o,$(src))
83 tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))
84
85 all-daemon = $(daemon): $(obj)
86 all-client = $(client): $(obj)
87
88 s = $(dir $(lastword $(MAKEFILE_LIST)))
89 ifeq ($(srcdir),.)
90 o = $(objdir)/$(s)
91 else
92 o = $(patsubst $(srcdir)%,$(objdir)%,$(s))
93 endif
94
95 define clean_in =
96 clean::
97 rm -f $(addprefix $(o),$(1))
98 endef
99
100 clean = $(eval $(call clean_in,$(1)))
101
102 include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
103
104 # Generic rules
105 # Object file rules
106 $(objdir)/%.o: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
107 $(E)echo CC -o $@ -c $<
108 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
109
110 $(objdir)/%.o: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
111 $(E)echo CC -o $@ -c $<
112 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
113
114 # Debug: Preprocessed source rules
115 $(objdir)/%.E: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
116 $(E)echo CC -o $@ -E $<
117 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
118
119 $(objdir)/%.E: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
120 $(E)echo CC -o $@ -E $<
121 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
122
123 # Debug: Assembler object rules
124 $(objdir)/%.S: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
125 $(E)echo CC -o $@ -S $<
126 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
127
128 $(objdir)/%.S: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
129 $(E)echo CC -o $@ -S $<
130 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
131
132
133
134 $(objdir)/.dir-stamp:
135 $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
136 $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
137 $(Q)touch $@
138
139 $(client) $(daemon):
140 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
141 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
142
143 $(objdir)/sysdep/paths.h: Makefile
144 echo >$@ "/* Generated by Makefile, don't edit manually! */"
145 echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
146 echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
147 if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
148
149 # Unit tests rules
150
151 tests_targets_ok = $(addsuffix .ok,$(tests_targets))
152
153 $(tests_targets): %: %.o $(tests_objs)
154 $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
155 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
156
157 # Hack to avoid problems with tests linking everything
158 $(tests_targets): LIBS += $(DAEMON_LIBS)
159
160 $(tests_targets_ok): %.ok: %
161 $(Q)$* 2>/dev/null && touch $*.ok
162
163 test: testsclean check
164 check: tests tests_run
165 tests: $(tests_targets)
166 tests_run: $(tests_targets_ok)
167
168 # Finally include the computed dependencies
169
170 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
171 -include $(shell find $(objdir) -name "*.d")
172 endif
173
174 ifeq ($(MAKECMDGOALS),)
175 -include $(shell find $(objdir) -name "*.d")
176 endif
177
178 tags:
179 cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
180
181 cscope:
182 cd $(srcdir) ; find $(dirs) -name *.[chY] > cscope.files ; cscope -b
183
184 # Install
185
186 install: all
187 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir)
188 for BIN in bird @CLIENT@ ; do \
189 $(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ; \
190 done
191 if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \
192 $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \
193 else \
194 echo "Not overwriting old bird.conf" ; \
195 fi
196
197 install-docs:
198 $(INSTALL) -d $(DESTDIR)/$(docdir)
199 $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/
200
201 # Cleanup
202 clean::
203 rm -f $(objdir)/sysdep/paths.h
204 rm -f $(addprefix $(exedir)/,bird birdc birdcl)
205 find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
206
207 testsclean:
208 rm -f $(tests_targets_ok)
209
210 ifeq ($(objdir),obj)
211 distclean: clean
212 rm -rf $(objdir)
213 rm -f config.log config.status configure Makefile
214 else
215 distclean: clean
216 rm -rf * .dir-stamp
217 rm -f config.log config.status configure Makefile
218 endif