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