Add mac address config option handling
[l2tpns.git] / Makefile
1 DESTDIR =
2 bindir = $(DESTDIR)/usr/sbin
3 etcdir = $(DESTDIR)/etc/l2tpns
4 libdir = $(DESTDIR)/usr/lib/l2tpns
5
6 CC = gcc
7 DEFINES = -DBGP -DRINGBUFFER -DSTAT_CALLS -DSTATISTICS
8 OPTIM = -g -O3 -funroll-loops -fomit-frame-pointer -finline-functions
9 CFLAGS = -Wall $(OPTIM) $(DEFINES)
10 LDFLAGS = -rdynamic
11 LIBS = -lm
12 INSTALL = /usr/bin/install -c
13
14 OBJS= md5.o \
15 icmp.o \
16 cli.o \
17 l2tpns.o \
18 ppp.o \
19 radius.o \
20 ll.o \
21 cluster.o \
22 arp.o \
23 constants.o \
24 ll.o \
25 control.o \
26 util.o \
27 tbf.o \
28 bgp.o \
29
30 PLUGINS=garden.so autothrottle.so autosnoop.so stripdomain.so
31 TARGETS=l2tpns nsctl generateload bounce $(PLUGINS)
32
33 all: $(TARGETS)
34
35 clean:
36 /bin/rm -f *.o *.so $(TARGETS)
37
38 depend:
39 (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
40 gcc -MM $(DEFINES) $(OBJS:.o=.c) && \
41 gcc -MM $(DEFINES) $(PLUGINS:.so=.c) | sed 's/\.o/.so/') >Makefile.tmp
42 mv Makefile Makefile.bak
43 mv Makefile.tmp Makefile
44
45 # install config files only if a startup-config does not exist yet JK 20040713
46 # this does not interfere when building rpms or debs and makes
47 # fast upgrading via make install possible
48
49 install: all
50 $(INSTALL) -D -o root -g root -m 0755 l2tpns $(bindir)/l2tpns
51 $(INSTALL) -D -o root -g root -m 0755 nsctl $(bindir)/nsctl
52 @if [ -f $(etcdir)/startup-config ]; then \
53 echo '***' Installing default config files in $(etcdir) as .defaults; \
54 $(INSTALL) -D -o root -g root -m 0600 etc/startup-config.default $(etcdir)/startup-config.default; \
55 $(INSTALL) -D -o root -g root -m 0644 etc/ip_pool.default $(etcdir)/ip_pool.default; \
56 $(INSTALL) -D -o root -g root -m 0600 etc/users.default $(etcdir)/users.default; \
57 else \
58 echo '***' Installing default config files in $(etcdir) - remember to adjust them; \
59 $(INSTALL) -D -o root -g root -m 0600 etc/startup-config.default $(etcdir)/startup-config; \
60 $(INSTALL) -D -o root -g root -m 0644 etc/ip_pool.default $(etcdir)/ip_pool; \
61 $(INSTALL) -D -o root -g root -m 0600 etc/users.default $(etcdir)/users; \
62 fi
63
64 for plugin in $(PLUGINS); do \
65 $(INSTALL) -D -o root -g root -m 0755 $$plugin $(libdir)/$$plugin; \
66 done
67 if [ ! -e /dev/net/tun ]; then \
68 mkdir /dev/net; \
69 mknod /dev/net/tun c 10 200; \
70 fi
71
72 l2tpns: $(OBJS)
73 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) -lcli -ldl
74
75 nsctl: nsctl.o control.o
76 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
77
78 generateload: test/generateload.o
79 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
80
81 bounce: test/bounce.o
82 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
83
84 %.o: %.c
85 $(CC) -c $(CFLAGS) -o $@ $<
86
87 %.so: %.c
88 $(CC) -fPIC -shared $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS)
89
90 .PHONY: all clean depend
91
92 ## Dependencies: (autogenerated) ##
93 md5.o: md5.c md5.h
94 icmp.o: icmp.c l2tpns.h config.h
95 cli.o: cli.c l2tpns.h config.h util.h cluster.h tbf.h ll.h bgp.h
96 l2tpns.o: l2tpns.c md5.h l2tpns.h config.h cluster.h plugin.h ll.h \
97 constants.h control.h util.h tbf.h bgp.h
98 ppp.o: ppp.c l2tpns.h config.h constants.h plugin.h util.h tbf.h \
99 cluster.h
100 radius.o: radius.c md5.h constants.h l2tpns.h config.h plugin.h util.h
101 ll.o: ll.c ll.h
102 cluster.o: cluster.c l2tpns.h config.h cluster.h util.h tbf.h bgp.h
103 arp.o: arp.c l2tpns.h config.h
104 constants.o: constants.c constants.h
105 ll.o: ll.c ll.h
106 control.o: control.c control.h
107 util.o: util.c l2tpns.h config.h
108 tbf.o: tbf.c l2tpns.h config.h util.h tbf.h
109 bgp.o: bgp.c l2tpns.h config.h bgp.h util.h
110 garden.so: garden.c l2tpns.h config.h plugin.h control.h
111 autothrottle.so: autothrottle.c l2tpns.h config.h plugin.h control.h
112 autosnoop.so: autosnoop.c l2tpns.h config.h plugin.h control.h