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>
5 # Disable build-in rules
9 CPPFLAGS
=-I
$(objdir
) -I
$(srcdir) @CPPFLAGS@
10 CFLAGS
=$(CPPFLAGS
) @CFLAGS@
13 BISONFLAGS
=@BISONFLAGS@
15 DAEMON_LIBS
=@DAEMON_LIBS@
16 CLIENT_LIBS
=@CLIENT_LIBS@
23 INSTALL_PROGRAM
=@INSTALL_PROGRAM@
24 INSTALL_DATA
=@INSTALL_DATA@
26 client
=$(addprefix $(exedir
)/,@CLIENT@
)
31 exec_prefix=@
exec_prefix@
34 sysconfdir
=@sysconfdir@
35 localstatedir
=@localstatedir@
36 runstatedir
=@runstatedir@
43 git-label
:=$(strip $(shell cd
$(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe
--always
--dirty
=-x
2>/dev
/null
))
45 CFLAGS
+= -DGIT_LABEL
="$(git-label)"
49 objdir
:= $(realpath .
)
61 CFLAGS
+= -fdiagnostics-color
=always
65 docgoals
:= docs userdocs progdocs
66 testgoals
:= check test tests tests_run
67 cleangoals
:= clean distclean testsclean
68 .PHONY
: all daemon cli
$(docgoals
) $(testgoals
) $(cleangoals
) tags cscope
74 $(daemon
): LIBS
+= $(DAEMON_LIBS
)
77 dirs
:= client conf doc
filter lib nest
test $(addprefix proto
/,$(protocols
)) @sysdep_dirs@
79 # conf/Makefile declarations needed for all other modules
80 conf-lex-targets
:= $(addprefix $(objdir
)/conf
/,cf-lex.o
)
81 conf-y-targets
:= $(addprefix $(objdir
)/conf
/,cf-parse.y keywords.h commands.h
)
82 cf-local
= $(conf-y-targets
): $(s
)config.Y
84 src-o-files
= $(patsubst %.c
,$(o
)%.o
,$(src
))
85 tests-target-files
= $(patsubst %.c
,$(o
)%,$(tests_src
))
87 all-daemon
= $(daemon
): $(obj
)
88 all-client
= $(client
): $(obj
)
90 s
= $(dir $(lastword
$(MAKEFILE_LIST
)))
94 o
= $(patsubst $(srcdir)%,$(objdir
)%,$(s
))
99 rm -f
$(addprefix $(o
),$(1))
102 clean = $(eval
$(call clean_in
,$(1)))
104 # Include main Makefiles of the directories
105 include $(addsuffix /Makefile
,$(addprefix $(srcdir)/,$(dirs
)))
109 $(objdir
)/%.o
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
110 $(E
)echo CC
-o
$@
-c
$<
111 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
113 $(objdir
)/%.o
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
114 $(E
)echo CC
-o
$@
-c
$<
115 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
117 # Debug: Preprocessed source rules
118 $(objdir
)/%.E
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
119 $(E
)echo CC
-o
$@
-E
$<
120 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-E
$<
122 $(objdir
)/%.E
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
123 $(E
)echo CC
-o
$@
-E
$<
124 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-E
$<
126 # Debug: Assembler object rules
127 $(objdir
)/%.S
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
128 $(E
)echo CC
-o
$@
-S
$<
129 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
131 $(objdir
)/%.S
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
132 $(E
)echo CC
-o
$@
-S
$<
133 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
137 $(objdir
)/.dir-stamp
:
138 $(E
)echo MKDIR
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
139 $(Q
)mkdir
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
143 $(E
)echo LD
$(LDFLAGS
) -o
$@
$^
$(LIBS
)
144 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
146 $(objdir
)/sysdep
/paths.h
: Makefile
147 echo
>$@
"/* Generated by Makefile, don't edit manually! */"
148 echo
>>$@
"#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
149 echo
>>$@
"#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
150 if
test -n
"@iproutedir@" ; then echo
>>$@
"#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
154 tests_targets_ok
= $(addsuffix .ok
,$(tests_targets
))
156 $(tests_targets
): %: %.o
$(tests_objs
)
157 $(E
)echo LD
$(LDFLAGS
) -o
$@
$< "..." $(LIBS
)
158 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
160 # Hack to avoid problems with tests linking everything
161 $(tests_targets
): LIBS
+= $(DAEMON_LIBS
)
163 $(tests_targets_ok
): %.ok
: %
164 $(Q
)$* 2>/dev
/null
&& touch
$*.ok
166 test: testsclean
check
167 check: tests tests_run
168 tests
: $(tests_targets
)
169 tests_run
: $(tests_targets_ok
)
171 # Finally include the computed dependencies
173 ifneq ($(filter-out $(cleangoals
),$(MAKECMDGOALS
)),)
174 -include $(shell find
$(objdir
) -name
"*.d")
177 ifeq ($(MAKECMDGOALS
),)
178 -include $(shell find
$(objdir
) -name
"*.d")
182 cd
$(srcdir) ; etags
-lc
`find $(dirs) -name *.[chY]`
185 cd
$(srcdir) ; find
$(dirs
) -name
*.
[chY
] > cscope.files
; cscope
-b
190 $(INSTALL
) -d
$(DESTDIR
)/$(sbindir
) $(DESTDIR
)/$(sysconfdir
) $(DESTDIR
)/$(runstatedir
)
191 for BIN in bird @CLIENT@
; do \
192 $(INSTALL_PROGRAM
) $(exedir
)/$$BIN $(DESTDIR
)/$(sbindir
)/$$BIN ; \
194 if
! test -f
$(DESTDIR
)/@CONFIG_FILE@
; then \
195 $(INSTALL_DATA
) $(srcdir)/doc
/bird.conf.example
$(DESTDIR
)/@CONFIG_FILE@
; \
197 echo
"Not overwriting old bird.conf" ; \
201 $(INSTALL
) -d
$(DESTDIR
)/$(docdir
)
202 $(INSTALL_DATA
) $(objdir
)/doc
/{bird
,prog
}{,-*}.html
$(DESTDIR
)/$(docdir
)/
206 rm -f
$(objdir
)/sysdep
/paths.h
207 rm -f
$(addprefix $(exedir
)/,bird birdc birdcl
)
208 find
$(objdir
) -name
"*.[od]" -exec
rm -f
'{}' '+'
211 rm -f
$(tests_targets_ok
)
216 rm -f config.log config.status configure Makefile
220 rm -f config.log config.status configure Makefile