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