Fix: mismatch variable type (cluster_port).
[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 $(OPTIM)
22 LDFLAGS =
23 LDLIBS =
24 INSTALL = install -c -D -o root -g root
25
26 l2tpns.LIBS = -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 l2tplac.o dhcp6.o ipv6_u.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 all: programs plugins
47 programs: $(PROGRAMS)
48 plugins: $(PLUGINS)
49
50 clean:
51 rm -f *.o test/*.o $(PROGRAMS) $(PLUGINS) Makefile.tmp Makefile.bak
52
53 depend:
54 (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
55 gcc -MM $(CPPFLAGS) $(OBJS:.o=.c) && \
56 gcc -MM $(CPPFLAGS) $(PLUGINS:.so=.c) | sed 's/\.o/.so/') >Makefile.tmp
57 mv Makefile Makefile.bak
58 mv Makefile.tmp Makefile
59
60 l2tpns: $(OBJS)
61 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
62
63 nsctl: nsctl.o control.o
64 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
65
66 %.o: %.c
67 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
68
69 %.so: %.c
70 $(CC) -fPIC -shared $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
71
72 install: all
73 $(INSTALL) -m 0755 l2tpns $(DESTDIR)$(bindir)/l2tpns
74 $(INSTALL) -m 0755 nsctl $(DESTDIR)$(bindir)/nsctl
75
76 $(INSTALL) -m 0644 Docs/startup-config.5 $(DESTDIR)$(man5dir)/startup-config.5
77 $(INSTALL) -m 0644 Docs/l2tpns.8 $(DESTDIR)$(man8dir)/l2tpns.8
78 $(INSTALL) -m 0644 Docs/nsctl.8 $(DESTDIR)$(man8dir)/nsctl.8
79
80 gzip --best --force $(DESTDIR)$(man5dir)/*.5 $(DESTDIR)$(man8dir)/*.8
81
82 @for config in startup-config users ip_pool; \
83 do \
84 suffix=; \
85 mode=0600; [ $$config = ip_pool ] && mode=0644; \
86 if [ -f $(DESTDIR)$(etcdir)/$$config ]; \
87 then \
88 cmp -s etc/$$config.default $(DESTDIR)$(etcdir)/$$config && continue; \
89 suffix=.default; \
90 fi; \
91 echo $(INSTALL) -m $$mode etc/$$config.default $(DESTDIR)$(etcdir)/$$config$$suffix; \
92 $(INSTALL) -m $$mode etc/$$config.default $(DESTDIR)$(etcdir)/$$config$$suffix; \
93 done
94
95 @for plugin in $(PLUGINS); \
96 do \
97 echo $(INSTALL) -m 0755 $$plugin $(DESTDIR)$(libdir)/$$plugin; \
98 $(INSTALL) -m 0755 $$plugin $(DESTDIR)$(libdir)/$$plugin; \
99 done
100
101 @if [ -z $(DESTDIR) ] && [ ! -e /dev/net/tun ]; \
102 then \
103 mkdir /dev/net; \
104 echo mknod /dev/net/tun c 10 200; \
105 mknod /dev/net/tun c 10 200; \
106 fi
107
108 .PHONY: all clean depend install
109
110 ## Dependencies: (autogenerated) ##
111 arp.o: arp.c dhcp6.h l2tpns.h
112 cli.o: cli.c dhcp6.h l2tpns.h constants.h util.h cluster.h tbf.h ll.h \
113 bgp.h l2tplac.h
114 cluster.o: cluster.c dhcp6.h l2tpns.h cluster.h util.h tbf.h pppoe.h \
115 bgp.h
116 constants.o: constants.c constants.h
117 control.o: control.c dhcp6.h l2tpns.h control.h
118 icmp.o: icmp.c dhcp6.h l2tpns.h ipv6_u.h
119 l2tpns.o: l2tpns.c md5.h dhcp6.h l2tpns.h cluster.h plugin.h ll.h \
120 constants.h control.h util.h tbf.h bgp.h l2tplac.h pppoe.h
121 ll.o: ll.c ll.h
122 md5.o: md5.c md5.h
123 ppp.o: ppp.c dhcp6.h l2tpns.h constants.h plugin.h util.h tbf.h cluster.h \
124 l2tplac.h pppoe.h
125 radius.o: radius.c md5.h constants.h dhcp6.h l2tpns.h plugin.h util.h \
126 cluster.h l2tplac.h pppoe.h
127 tbf.o: tbf.c dhcp6.h l2tpns.h util.h tbf.h
128 util.o: util.c dhcp6.h l2tpns.h bgp.h
129 pppoe.o: pppoe.c dhcp6.h l2tpns.h cluster.h constants.h md5.h util.h
130 l2tplac.o: l2tplac.c md5.h dhcp6.h l2tpns.h util.h cluster.h l2tplac.h \
131 pppoe.h
132 dhcp6.o: dhcp6.c dhcp6.h l2tpns.h ipv6_u.h
133 ipv6_u.o: ipv6_u.c ipv6_u.h
134 bgp.o: bgp.c dhcp6.h l2tpns.h bgp.h util.h
135 autosnoop.so: autosnoop.c dhcp6.h l2tpns.h plugin.h
136 autothrottle.so: autothrottle.c dhcp6.h l2tpns.h plugin.h
137 garden.so: garden.c dhcp6.h l2tpns.h plugin.h control.h
138 sessionctl.so: sessionctl.c dhcp6.h l2tpns.h plugin.h control.h
139 setrxspeed.so: setrxspeed.c dhcp6.h l2tpns.h plugin.h
140 snoopctl.so: snoopctl.c dhcp6.h l2tpns.h plugin.h control.h
141 stripdomain.so: stripdomain.c dhcp6.h l2tpns.h plugin.h
142 throttlectl.so: throttlectl.c dhcp6.h l2tpns.h plugin.h control.h