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