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