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 DAEMON_LIBS
=@DAEMON_LIBS@
14 CLIENT_LIBS
=@CLIENT_LIBS@
21 INSTALL_PROGRAM
=@INSTALL_PROGRAM@
22 INSTALL_DATA
=@INSTALL_DATA@
24 git-label
:=$(strip $(shell git describe
--always
--dirty
=-x
2>/dev
/null
))
26 CFLAGS
+= -DGIT_LABEL
="$(git-label)"
29 client
=$(addprefix $(exedir
)/,@CLIENT@
)
34 exec_prefix=@
exec_prefix@
37 sysconfdir
=@sysconfdir@
38 localstatedir
=@localstatedir@
46 objdir
:= $(realpath .
)
58 docgoals
:= docs userdocs progdocs
59 testgoals
:= check test tests tests_run
60 cleangoals
:= clean distclean testsclean
61 .PHONY
: all daemon cli
$(docgoals
) $(testgoals
) $(cleangoals
) tags cscope
67 $(daemon
): LIBS
+= $(DAEMON_LIBS
)
70 dirs
:= client conf doc
filter lib nest
test $(addprefix proto
/,$(protocols
)) @sysdep_dirs@
72 conf-y-targets
:= $(addprefix $(objdir
)/conf
/,cf-parse.y keywords.h commands.h
)
73 cf-local
= $(conf-y-targets
): $(s
)config.Y
75 src-o-files
= $(patsubst %.c
,$(o
)%.o
,$(src
))
76 tests-target-files
= $(patsubst %.c
,$(o
)%,$(tests_src
))
78 all-daemon
= $(daemon
): $(obj
)
79 all-client
= $(client
): $(obj
)
81 s
= $(dir $(lastword
$(MAKEFILE_LIST
)))
85 o
= $(patsubst $(srcdir)%,$(objdir
)%,$(s
))
90 rm -f
$(addprefix $(o
),$(1))
93 clean = $(eval
$(call clean_in
,$(1)))
95 include $(addsuffix /Makefile
,$(addprefix $(srcdir)/,$(dirs
)))
99 $(objdir
)/%.o
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
100 $(E
)echo CC
-o
$@
-c
$<
101 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
103 $(objdir
)/%.o
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
104 $(E
)echo CC
-o
$@
-c
$<
105 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-c
$<
108 $(objdir
)/%.S
: $(srcdir)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
109 $(E
)echo CC
-o
$@
-S
$<
110 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
112 $(objdir
)/%.S
: $(objdir
)/%.c
$(objdir
)/.dir-stamp
$(objdir
)/sysdep
/paths.h
113 $(E
)echo CC
-o
$@
-S
$<
114 $(Q
)$(CC
) $(CFLAGS
) -MMD
-MP
-o
$@
-S
$<
118 $(objdir
)/.dir-stamp
:
119 $(E
)echo MKDIR
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
120 $(Q
)mkdir
-p
$(addprefix $(objdir
)/,$(dirs
) doc
)
124 $(E
)echo LD
$(LDFLAGS
) -o
$@
$^
$(LIBS
)
125 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
127 $(objdir
)/sysdep
/paths.h
: Makefile
128 echo
>$@
"/* Generated by Makefile, don't edit manually! */"
129 echo
>>$@
"#define PATH_CONFIG_FILE \"@CONFIG_FILE@\""
130 echo
>>$@
"#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\""
131 if
test -n
"@iproutedir@" ; then echo
>>$@
"#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
135 tests_targets_ok
= $(addsuffix .ok
,$(tests_targets
))
137 $(tests_targets
): %: %.o
$(tests_objs
)
138 $(E
)echo LD
$(LDFLAGS
) -o
$@
$< "..." $(LIBS
)
139 $(Q
)$(CC
) $(LDFLAGS
) -o
$@
$^
$(LIBS
)
141 # Hack to avoid problems with tests linking everything
142 $(tests_targets
): LIBS
+= $(DAEMON_LIBS
)
144 $(tests_targets_ok
): %.ok
: %
145 $(Q
)$* 2>/dev
/null
&& touch
$*.ok
147 test: testsclean
check
148 check: tests tests_run
149 tests
: $(tests_targets
)
150 tests_run
: $(tests_targets_ok
)
152 # Finally include the computed dependencies
154 ifneq ($(filter-out $(cleangoals
),$(MAKECMDGOALS
)),)
155 -include $(shell find
$(objdir
) -name
"*.d")
158 ifeq ($(MAKECMDGOALS
),)
159 -include $(shell find
$(objdir
) -name
"*.d")
163 cd
$(srcdir) ; etags
-lc
`find $(dirs) -name *.[chY]`
166 cd
$(srcdir) ; find
$(dirs
) -name
*.
[chY
] > cscope.files
; cscope
-b
171 $(INSTALL
) -d
$(DESTDIR
)/$(sbindir
) $(DESTDIR
)/$(sysconfdir
) $(DESTDIR
)/@runtimedir@
172 $(INSTALL_PROGRAM
) $(exedir
)/bird
$(DESTDIR
)/$(sbindir
)/bird
173 $(INSTALL_PROGRAM
) $(exedir
)/birdcl
$(DESTDIR
)/$(sbindir
)/birdcl
174 if
test -n
"@CLIENT@" ; then \
175 $(INSTALL_PROGRAM
) $(exedir
)/birdc
$(DESTDIR
)/$(sbindir
)/birdc
; \
177 if
! test -f
$(DESTDIR
)/@CONFIG_FILE@
; then \
178 $(INSTALL_DATA
) $(srcdir)/doc
/bird.conf.example
$(DESTDIR
)/@CONFIG_FILE@
; \
180 echo
"Not overwriting old bird.conf" ; \
184 $(INSTALL
) -d
$(DESTDIR
)/$(docdir
)
185 $(INSTALL_DATA
) $(objdir
)/doc
/{bird
,prog
}{,-*}.html
$(DESTDIR
)/$(docdir
)/
189 rm -f
$(objdir
)/sysdep
/paths.h
190 rm -f
$(addprefix $(exedir
)/,bird birdc birdcl
)
191 find
$(objdir
) -name
"*.[od]" -exec
rm -f
'{}' '+'
194 rm -f
$(tests_targets_ok
)
199 rm -f config.log config.status configure Makefile
203 rm -f config.log config.status configure Makefile