]> git.ipfire.org Git - thirdparty/bird.git/blob - Makefile.in
Make: Add option to force colors in compiler output
[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 ifneq ($(COLOR),)
59 CFLAGS += -fdiagnostics-color=always
60 endif
61
62 # Meta rules
63 docgoals := docs userdocs progdocs
64 testgoals := check test tests tests_run
65 cleangoals := clean distclean testsclean
66 .PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope
67 all: daemon cli
68
69 daemon: $(daemon)
70 cli: $(client)
71
72 $(daemon): LIBS += $(DAEMON_LIBS)
73
74 # Include directories
75 dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@
76
77 conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
78 cf-local = $(conf-y-targets): $(s)config.Y
79
80 src-o-files = $(patsubst %.c,$(o)%.o,$(src))
81 tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))
82
83 all-daemon = $(daemon): $(obj)
84 all-client = $(client): $(obj)
85
86 s = $(dir $(lastword $(MAKEFILE_LIST)))
87 ifeq ($(srcdir),.)
88 o = $(objdir)/$(s)
89 else
90 o = $(patsubst $(srcdir)%,$(objdir)%,$(s))
91 endif
92
93 define clean_in =
94 clean::
95 rm -f $(addprefix $(o),$(1))
96 endef
97
98 clean = $(eval $(call clean_in,$(1)))
99
100 include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
101
102 # Generic rules
103 # Object file rules
104 $(objdir)/%.o: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
105 $(E)echo CC -o $@ -c $<
106 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
107
108 $(objdir)/%.o: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
109 $(E)echo CC -o $@ -c $<
110 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
111
112 # Debug: Preprocessed source rules
113 $(objdir)/%.E: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
114 $(E)echo CC -o $@ -E $<
115 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
116
117 $(objdir)/%.E: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
118 $(E)echo CC -o $@ -E $<
119 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
120
121 # Debug: Assembler object rules
122 $(objdir)/%.S: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
123 $(E)echo CC -o $@ -S $<
124 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
125
126 $(objdir)/%.S: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
127 $(E)echo CC -o $@ -S $<
128 $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
129
130
131
132 $(objdir)/.dir-stamp:
133 $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
134 $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
135 $(Q)touch $@
136
137 $(client) $(daemon):
138 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
139 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
140
141 $(objdir)/sysdep/paths.h: Makefile
142 echo >$@ "/* Generated by Makefile, don't edit manually! */"
143 echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
144 echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
145 if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
146
147 # Unit tests rules
148
149 tests_targets_ok = $(addsuffix .ok,$(tests_targets))
150
151 $(tests_targets): %: %.o $(tests_objs)
152 $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
153 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
154
155 # Hack to avoid problems with tests linking everything
156 $(tests_targets): LIBS += $(DAEMON_LIBS)
157
158 $(tests_targets_ok): %.ok: %
159 $(Q)$* 2>/dev/null && touch $*.ok
160
161 test: testsclean check
162 check: tests tests_run
163 tests: $(tests_targets)
164 tests_run: $(tests_targets_ok)
165
166 # Finally include the computed dependencies
167
168 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
169 -include $(shell find $(objdir) -name "*.d")
170 endif
171
172 ifeq ($(MAKECMDGOALS),)
173 -include $(shell find $(objdir) -name "*.d")
174 endif
175
176 tags:
177 cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
178
179 cscope:
180 cd $(srcdir) ; find $(dirs) -name *.[chY] > cscope.files ; cscope -b
181
182 # Install
183
184 install: all
185 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@
186 $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird
187 $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl
188 if test -n "@CLIENT@" ; then \
189 $(INSTALL_PROGRAM) $(exedir)/birdc $(DESTDIR)/$(sbindir)/birdc ; \
190 fi
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