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