]>
Commit | Line | Data |
---|---|---|
7152e5ef MM |
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 | CLIENT_LIBS=@CLIENT_LIBS@ | |
14 | CC=@CC@ | |
15 | M4=@M4@ | |
16 | BISON=@BISON@ | |
17 | FLEX=@FLEX@ | |
18 | RANLIB=@RANLIB@ | |
19 | INSTALL=@INSTALL@ | |
20 | INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
21 | INSTALL_DATA=@INSTALL_DATA@ | |
22 | ||
23 | client=$(addprefix $(exedir)/,@CLIENT@) | |
24 | daemon=$(exedir)/bird | |
25 | protocols = @protocols@ | |
26 | ||
27 | prefix=@prefix@ | |
28 | exec_prefix=@exec_prefix@ | |
29 | bindir=@bindir@ | |
30 | sbindir=@sbindir@ | |
31 | sysconfdir=@sysconfdir@ | |
32 | localstatedir=@localstatedir@ | |
33 | docdir=@prefix@/doc | |
34 | ||
35 | srcdir := @srcdir@ | |
36 | objdir := @objdir@ | |
37 | exedir := @exedir@ | |
38 | ||
39 | ifeq ($(objdir),.) | |
40 | objdir := $(realpath .) | |
41 | endif | |
42 | ||
43 | ifeq ($(VERBOSE),) | |
44 | Q:=@ | |
45 | else | |
46 | Q:= | |
47 | endif | |
48 | ||
49 | # Meta rules | |
50 | cleangoals := clean distclean | |
51 | docgoals := docs userdocs progdocs | |
52 | .PHONY: all daemon cli $(cleangoals) $(docgoals) tags | |
53 | all: daemon cli | |
54 | ||
55 | daemon: $(daemon) | |
56 | cli: $(client) | |
57 | ||
58 | # Include directories | |
59 | dirs := client conf doc filter lib nest $(addprefix proto/,$(protocols)) @sysdep_dirs@ | |
60 | ||
61 | conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h) | |
62 | cf-local = $(conf-y-targets): $(s)config.Y | |
63 | ||
64 | src-o-files = $(patsubst %.c,$(o)%.o,$(src)) | |
65 | ||
66 | all-daemon = $(exedir)/bird: $(obj) | |
67 | all-client = $(exedir)/birdc $(exedir)/birdcl: $(obj) | |
68 | ||
69 | s = $(dir $(lastword $(MAKEFILE_LIST))) | |
70 | ifeq ($(srcdir),.) | |
71 | o = $(objdir)/$(s) | |
72 | else | |
73 | o = $(patsubst $(srcdir)%,$(objdir)%,$(s)) | |
74 | endif | |
75 | ||
76 | define clean_in = | |
77 | clean:: | |
78 | rm -f $(addprefix $(o),$(1)) | |
79 | endef | |
80 | ||
81 | clean = $(eval $(call clean_in,$(1))) | |
82 | ||
83 | include $(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 | ||
112 | ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),) | |
113 | -include $(shell find $(objdir) -name "*.d") | |
114 | endif | |
115 | ||
116 | ifeq ($(MAKECMDGOALS),) | |
117 | -include $(shell find $(objdir) -name "*.d") | |
118 | endif | |
119 | ||
120 | tags: | |
121 | cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]` | |
122 | ||
123 | # Install | |
124 | ||
125 | install: 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 | ||
138 | install-docs: | |
139 | $(INSTALL) -d $(DESTDIR)/$(docdir) | |
140 | $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/ | |
141 | ||
142 | # Cleanup | |
143 | clean:: | |
144 | rm -f $(objdir)/sysdep/paths.h | |
145 | rm -f $(addprefix $(exedir)/,bird birdc birdcl) | |
146 | find $(objdir) -name "*.[od]" -exec rm -f '{}' '+' | |
147 | ||
148 | ifeq ($(objdir),obj) | |
149 | distclean: clean | |
150 | rm -rf $(objdir) | |
151 | rm -f config.log config.status configure Makefile | |
152 | else | |
153 | distclean: clean | |
154 | rm -rf * .dir-stamp | |
155 | rm -f config.log config.status configure Makefile | |
156 | endif |