Update debian changelog
[l2tpns.git] / Makefile
1 DESTDIR =
2 bindir = /usr/sbin
3 etcdir = /etc/l2tpns
4 libdir = /usr/lib/l2tpns
5 man5dir = /usr/share/man/man5
6 man8dir = /usr/share/man/man8
7 statedir = /var/lib/l2tpns
8
9 DEFINES =
10 DEFINES += -DLIBDIR='"$(libdir)"'
11 DEFINES += -DETCDIR='"$(etcdir)"'
12
13 OPTIM =
14 OPTIM += -g
15 OPTIM += -O3
16
17 CC = gcc
18 LD = gcc
19 INCLUDES = -I.
20 CPPFLAGS = $(INCLUDES) $(DEFINES)
21 CFLAGS = -Wall -Wformat-security -Wno-format-zero-length $(OPTIM)
22 LDFLAGS =
23 LDLIBS =
24 INSTALL = install -c -D -o root -g root
25
26 l2tpns.LIBS = -lm -lcli -ldl
27
28 OBJS = arp.o cli.o cluster.o constants.o control.o icmp.o l2tpns.o \
29 ll.o md5.o ppp.o radius.o tbf.o util.o pppoe.o
30
31 PROGRAMS = l2tpns nsctl
32 PLUGINS = autosnoop.so autothrottle.so garden.so sessionctl.so \
33 setrxspeed.so snoopctl.so stripdomain.so throttlectl.so
34
35 DEFINES += -DSTATISTICS
36 DEFINES += -DSTAT_CALLS
37 DEFINES += -DRINGBUFFER
38
39 ifneq (2.4, $(shell uname -r | perl -pe 's/^(\d+\.\d+).*/$$1/'))
40 DEFINES += -DHAVE_EPOLL
41 endif
42
43 DEFINES += -DBGP
44 OBJS += bgp.o
45
46 DEFINES += -DLAC
47 OBJS += l2tplac.o
48
49 all: programs plugins
50 programs: $(PROGRAMS)
51 plugins: $(PLUGINS)
52
53 clean:
54 rm -f *.o test/*.o $(PROGRAMS) $(PLUGINS) Makefile.tmp Makefile.bak
55
56 depend:
57 (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
58 gcc -MM $(CPPFLAGS) $(OBJS:.o=.c) && \
59 gcc -MM $(CPPFLAGS) $(PLUGINS:.so=.c) | sed 's/\.o/.so/') >Makefile.tmp
60 mv Makefile Makefile.bak
61 mv Makefile.tmp Makefile
62
63 l2tpns: $(OBJS)
64 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
65
66 nsctl: nsctl.o control.o
67 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
68
69 %.o: %.c
70 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
71
72 %.so: %.c
73 $(CC) -fPIC -shared $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
74
75 install: all
76 $(INSTALL) -m 0755 l2tpns $(DESTDIR)$(bindir)/l2tpns
77 $(INSTALL) -m 0755 nsctl $(DESTDIR)$(bindir)/nsctl
78
79 $(INSTALL) -m 0644 Docs/startup-config.5 $(DESTDIR)$(man5dir)/startup-config.5
80 $(INSTALL) -m 0644 Docs/l2tpns.8 $(DESTDIR)$(man8dir)/l2tpns.8
81 $(INSTALL) -m 0644 Docs/nsctl.8 $(DESTDIR)$(man8dir)/nsctl.8
82
83 gzip --best --force $(DESTDIR)$(man5dir)/*.5 $(DESTDIR)$(man8dir)/*.8
84
85 @for config in startup-config users ip_pool; \
86 do \
87 suffix=; \
88 mode=0600; [ $$config = ip_pool ] && mode=0644; \
89 if [ -f $(DESTDIR)$(etcdir)/$$config ]; \
90 then \
91 cmp -s etc/$$config.default $(DESTDIR)$(etcdir)/$$config && continue; \
92 suffix=.default; \
93 fi; \
94 echo $(INSTALL) -m $$mode etc/$$config.default $(DESTDIR)$(etcdir)/$$config$$suffix; \
95 $(INSTALL) -m $$mode etc/$$config.default $(DESTDIR)$(etcdir)/$$config$$suffix; \
96 done
97
98 @for plugin in $(PLUGINS); \
99 do \
100 echo $(INSTALL) -m 0755 $$plugin $(DESTDIR)$(libdir)/$$plugin; \
101 $(INSTALL) -m 0755 $$plugin $(DESTDIR)$(libdir)/$$plugin; \
102 done
103
104 @if [ -z $(DESTDIR) ] && [ ! -e /dev/net/tun ]; \
105 then \
106 mkdir /dev/net; \
107 echo mknod /dev/net/tun c 10 200; \
108 mknod /dev/net/tun c 10 200; \
109 fi
110
111 .PHONY: all clean depend install
112
113 ## Dependencies: (autogenerated) ##
114 arp.o: arp.c l2tpns.h
115 cli.o: cli.c l2tpns.h constants.h util.h cluster.h tbf.h ll.h bgp.h \
116 l2tplac.h
117 cluster.o: cluster.c l2tpns.h cluster.h util.h tbf.h pppoe.h bgp.h
118 constants.o: constants.c constants.h
119 control.o: control.c l2tpns.h control.h
120 icmp.o: icmp.c l2tpns.h pppoe.h
121 l2tpns.o: l2tpns.c md5.h l2tpns.h cluster.h plugin.h ll.h constants.h \
122 control.h util.h tbf.h bgp.h l2tplac.h pppoe.h
123 ll.o: ll.c ll.h
124 md5.o: md5.c md5.h
125 ppp.o: ppp.c l2tpns.h constants.h plugin.h util.h tbf.h cluster.h \
126 l2tplac.h pppoe.h
127 radius.o: radius.c md5.h constants.h l2tpns.h plugin.h util.h cluster.h \
128 l2tplac.h pppoe.h
129 tbf.o: tbf.c l2tpns.h util.h tbf.h
130 util.o: util.c l2tpns.h bgp.h
131 pppoe.o: pppoe.c l2tpns.h cluster.h constants.h md5.h util.h
132 bgp.o: bgp.c l2tpns.h bgp.h util.h
133 l2tplac.o: l2tplac.c md5.h l2tpns.h util.h cluster.h l2tplac.h pppoe.h
134 autosnoop.so: autosnoop.c l2tpns.h plugin.h
135 autothrottle.so: autothrottle.c l2tpns.h plugin.h
136 garden.so: garden.c l2tpns.h plugin.h control.h
137 sessionctl.so: sessionctl.c l2tpns.h plugin.h control.h
138 setrxspeed.so: setrxspeed.c l2tpns.h plugin.h
139 snoopctl.so: snoopctl.c l2tpns.h plugin.h control.h
140 stripdomain.so: stripdomain.c l2tpns.h plugin.h
141 throttlectl.so: throttlectl.c l2tpns.h plugin.h control.h