]> 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 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 $(tests_targets_ok): %.ok: %
137 $(Q)$* 2>/dev/null && touch $*.ok
138
139 test: testsclean check
140 check: tests tests_run
141 tests: $(tests_targets)
142 tests_run: $(tests_targets_ok)
143
144 # Finally include the computed dependencies
145
146 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
147 -include $(shell find $(objdir) -name "*.d")
148 endif
149
150 ifeq ($(MAKECMDGOALS),)
151 -include $(shell find $(objdir) -name "*.d")
152 endif
153
154 tags:
155 cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
156
157 # Install
158
159 install: all
160 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@
161 $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird
162 $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl
163 if test -n "@CLIENT@" ; then \
164 $(INSTALL_PROGRAM) $(exedir)/birdc $(DESTDIR)/$(sbindir)/birdc ; \
165 fi
166 if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \
167 $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \
168 else \
169 echo "Not overwriting old bird.conf" ; \
170 fi
171
172 install-docs:
173 $(INSTALL) -d $(DESTDIR)/$(docdir)
174 $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/
175
176 # Cleanup
177 clean::
178 rm -f $(objdir)/sysdep/paths.h
179 rm -f $(addprefix $(exedir)/,bird birdc birdcl)
180 find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
181
182 testsclean:
183 rm -f $(tests_targets_ok)
184
185 ifeq ($(objdir),obj)
186 distclean: clean
187 rm -rf $(objdir)
188 rm -f config.log config.status configure Makefile
189 else
190 distclean: clean
191 rm -rf * .dir-stamp
192 rm -f config.log config.status configure Makefile
193 endif