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