]> git.ipfire.org Git - thirdparty/bird.git/blob - Makefile.in
Merge branch 'int-new-rpki-squashed' (early part) 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 $(objdir)/.dir-stamp:
103 $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
104 $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
105 $(Q)touch $@
106
107 $(client) $(daemon):
108 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
109 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
110
111 $(objdir)/sysdep/paths.h: Makefile
112 echo >$@ "/* Generated by Makefile, don't edit manually! */"
113 echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
114 echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
115 if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
116
117 # Unit tests rules
118
119 tests_targets_ok = $(addsuffix .ok,$(tests_targets))
120
121 $(tests_targets): %: %.o $(tests_objs)
122 $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
123 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
124
125 $(tests_targets_ok): %.ok: %
126 $(Q)$* 2>/dev/null && touch $*.ok
127
128 test: testsclean check
129 check: tests tests_run
130 tests: $(tests_targets)
131 tests_run: $(tests_targets_ok)
132
133 # Finally include the computed dependencies
134
135 ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
136 -include $(shell find $(objdir) -name "*.d")
137 endif
138
139 ifeq ($(MAKECMDGOALS),)
140 -include $(shell find $(objdir) -name "*.d")
141 endif
142
143 tags:
144 cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
145
146 # Install
147
148 install: all
149 $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@
150 $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird
151 $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl
152 if test -n "@CLIENT@" ; then \
153 $(INSTALL_PROGRAM) $(exedir)/birdc $(DESTDIR)/$(sbindir)/birdc ; \
154 fi
155 if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \
156 $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \
157 else \
158 echo "Not overwriting old bird.conf" ; \
159 fi
160
161 install-docs:
162 $(INSTALL) -d $(DESTDIR)/$(docdir)
163 $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/
164
165 # Cleanup
166 clean::
167 rm -f $(objdir)/sysdep/paths.h
168 rm -f $(addprefix $(exedir)/,bird birdc birdcl)
169 find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
170
171 testsclean:
172 rm -f $(tests_targets_ok)
173
174 ifeq ($(objdir),obj)
175 distclean: clean
176 rm -rf $(objdir)
177 rm -f config.log config.status configure Makefile
178 else
179 distclean: clean
180 rm -rf * .dir-stamp
181 rm -f config.log config.status configure Makefile
182 endif