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