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@
14 DAEMON_LIBS
=@DAEMON_LIBS@
15 CLIENT_LIBS
=@CLIENT_LIBS@
22 INSTALL_PROGRAM
=@INSTALL_PROGRAM@
23 INSTALL_DATA
=@INSTALL_DATA@
25 client
=$(addprefix $(exedir
)/,@CLIENT@
)
30 exec_prefix=@
exec_prefix@
33 sysconfdir
=@sysconfdir@
34 localstatedir
=@localstatedir@
41 git-label
:=$(strip $(shell cd
$(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe
--always
--dirty
=-x
2>/dev
/null
))
43 CFLAGS
+= -DGIT_LABEL
="$(git-label)"
47 objdir
:= $(realpath .
)
59 docgoals
:= docs userdocs progdocs
60 testgoals
:= check test tests tests_run
61 cleangoals
:= clean distclean testsclean
62 .PHONY
: all daemon cli
$(docgoals
) $(testgoals
) $(cleangoals
) tags cscope
68 $(daemon
): LIBS
+= $(DAEMON_LIBS
)
71 dirs
:= client conf doc
filter lib nest
test $(addprefix proto
/,$(protocols
)) @sysdep_dirs@
73 conf-y-targets
:= $(addprefix $(objdir
)/conf
/,cf-parse.y keywords.h commands.h
)
74 cf-local
= $(conf-y-targets
): $(s
)config.Y
76 src-o-files
= $(patsubst %.c
,$(o
)%.o
,$(src
))
77 tests-target-files
= $(patsubst %.c
,$(o
)%,$(tests_src
))
79 all-daemon
= $(daemon
): $(obj
)
80 all-client
= $(client
): $(obj
)
82 s
= $(dir $(lastword
$(MAKEFILE_LIST
)))
86 o
= $(patsubst $(srcdir)%,$(objdir
)%,$(s
))
91 rm -f
$(addprefix $(o
),$(1))
94 clean = $(eval
$(call clean_in
,$(1)))
96 include $(addsuffix /Makefile
,$(addprefix $(srcdir)/,$(dirs
)))
100 $(objdir
)/%.o
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
101 $(E
)echo CC
-o
$@
-c
$<
102 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
104 $(objdir
)/%.o
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
105 $(E
)echo CC
-o
$@
-c
$<
106 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
108 # Debug: Preprocessed source rules
109 $(objdir
)/%.E
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
110 $(E
)echo CC
-o
$@
-E
$<
111 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-E
$<
113 $(objdir
)/%.E
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
114 $(E
)echo CC
-o
$@
-E
$<
115 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-E
$<
117 # Debug: Assembler object rules
118 $(objdir
)/%.S
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
119 $(E
)echo CC
-o
$@
-S
$<
120 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
122 $(objdir
)/%.S
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
123 $(E
)echo CC
-o
$@
-S
$<
124 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
128 $(objdir
)/.dir-stamp
:
129 $(E
)echo MKDIR
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
130 $(Q
)mkdir
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
134 $(E
)echo LD
$(LDFLAGS
) -o
$@
$^
$(LIBS
)
135 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
137 $(objdir
)/sysdep
/paths.h
: Makefile
138 echo
>$@
"/* Generated by Makefile, don't edit manually! */"
139 echo
>>$@
"#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
140 echo
>>$@
"#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
141 if
test -n
"@iproutedir@" ; then echo
>>$@
"#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
145 tests_targets_ok
= $(addsuffix .ok
,$(tests_targets
))
147 $(tests_targets
): %: %.o
$(tests_objs
)
148 $(E
)echo LD
$(LDFLAGS
) -o
$@
$< "..." $(LIBS
)
149 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
151 # Hack to avoid problems with tests linking everything
152 $(tests_targets
): LIBS
+= $(DAEMON_LIBS
)
154 $(tests_targets_ok
): %.ok
: %
155 $(Q
)$* 2>/dev
/null
&& touch
$*.ok
157 test: testsclean
check
158 check: tests tests_run
159 tests
: $(tests_targets
)
160 tests_run
: $(tests_targets_ok
)
162 # Finally include the computed dependencies
164 ifneq ($(filter-out $(cleangoals
),$(MAKECMDGOALS
)),)
165 -include $(shell find
$(objdir
) -name
"*.d")
168 ifeq ($(MAKECMDGOALS
),)
169 -include $(shell find
$(objdir
) -name
"*.d")
173 cd
$(srcdir) ; etags
-lc
`find $(dirs) -name *.[chY]`
176 cd
$(srcdir) ; find
$(dirs
) -name
*.
[chY
] > cscope.files
; cscope
-b
181 $(INSTALL
) -d
$(DESTDIR
)/$(sbindir
) $(DESTDIR
)/$(sysconfdir
) $(DESTDIR
)/@runtimedir@
182 $(INSTALL_PROGRAM
) $(exedir
)/bird
$(DESTDIR
)/$(sbindir
)/bird
183 $(INSTALL_PROGRAM
) $(exedir
)/birdcl
$(DESTDIR
)/$(sbindir
)/birdcl
184 if
test -n
"@CLIENT@" ; then \
185 $(INSTALL_PROGRAM
) $(exedir
)/birdc
$(DESTDIR
)/$(sbindir
)/birdc
; \
187 if
! test -f
$(DESTDIR
)/@CONFIG_FILE@
; then \
188 $(INSTALL_DATA
) $(srcdir)/doc
/bird.conf.example
$(DESTDIR
)/@CONFIG_FILE@
; \
190 echo
"Not overwriting old bird.conf" ; \
194 $(INSTALL
) -d
$(DESTDIR
)/$(docdir
)
195 $(INSTALL_DATA
) $(objdir
)/doc
/{bird
,prog
}{,-*}.html
$(DESTDIR
)/$(docdir
)/
199 rm -f
$(objdir
)/sysdep
/paths.h
200 rm -f
$(addprefix $(exedir
)/,bird birdc birdcl
)
201 find
$(objdir
) -name
"*.[od]" -exec
rm -f
'{}' '+'
204 rm -f
$(tests_targets_ok
)
209 rm -f config.log config.status configure Makefile
213 rm -f config.log config.status configure Makefile