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