summaryrefslogtreecommitdiff
path: root/tools/Rules.in
blob: 56c0903b6b4ad0a7cd238b6a8024d84a14174879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Makefile fragments for the BIRD Internet Routing Daemon
# (c) 1999 Martin Mares <mj@ucw.cz>

srcdir=@srcdir_rel_mf@
objdir=@objdir@
exedir=@exedir@

protocols=@protocols@
static-dirs := nest $(addprefix proto/,$(protocols))
static-dir-paths := $(addprefix $(srcdir)/,$(static-dirs))
dynamic-dirs := lib conf
dynamic-dir-paths := $(dynamic-dirs)
dir-makefiles := $(addsuffix /Makefile,$(static-dir-paths) $(dynamic-dir-paths))

all-dirs:=$(static-dirs) $(dynamic-dirs)
clean-dirs:=$(all-dirs) proto sysdep
dir-objs:=$(addprefix $(objdir)/,$(all-dirs))

CPPFLAGS=-I$(root-rel) -I$(srcdir)
CFLAGS=$(CPPFLAGS) @CFLAGS@
CC=@CC@
M4=@M4@
BISON=@BISON@
FLEX=@FLEX@
RANLIB=@RANLIB@

ifdef source

objs := $(subst .c,.o,$(source))

ifdef dir-name
src-path := $(srcdir)/$(dir-name)/
endif

all:
	cd $(root-rel) && make

ifdef lib-dest

subdir: $(lib-dest)

$(lib-dest): $(objs)
	rm -f $@
	ar rcs $@ $^
	$(RANLIB) $@

else

subdir: all.o

all.o: $(objs)
	$(LD) -r -o $@ $^

endif

%.o: $(src-path)%.c
	$(CC) $(CFLAGS) -o $@ -c $^

depend:
	gcc $(CPPFLAGS) -MM $(addprefix $(src-path),$(source)) >depend

ifneq ($(wildcard .depend),)
include .depend
endif

endif