typo
[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
30
31 PROGRAMS = l2tpns nsctl
32 PLUGINS = garden.so throttlectl.so autothrottle.so snoopctl.so \
33 autosnoop.so stripdomain.so setrxspeed.so
34
35 TESTS = generateload bounce
36
37 DEFINES += -DSTATISTICS
38 DEFINES += -DSTAT_CALLS
39 DEFINES += -DRINGBUFFER
40
41 DEFINES += -DBGP
42 OBJS += bgp.o
43
44 all: programs plugins tests
45 programs: $(PROGRAMS)
46 plugins: $(PLUGINS)
47 tests: $(TESTS)
48
49 clean:
50 rm -f *.o test/*.o $(PROGRAMS) $(PLUGINS) $(TESTS) Makefile.tmp Makefile.bak
51
52 depend:
53 (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
54 gcc -MM $(CPPFLAGS) $(OBJS:.o=.c) && \
55 gcc -MM $(CPPFLAGS) $(PLUGINS:.so=.c) | sed 's/\.o/.so/') >Makefile.tmp
56 mv Makefile Makefile.bak
57 mv Makefile.tmp Makefile
58
59 l2tpns: $(OBJS)
60 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
61
62 nsctl: nsctl.o control.o
63 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
64
65 generateload: test/generateload.o
66 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
67
68 bounce: test/bounce.o
69 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $($@.LIBS)
70
71 %.o: %.c
72 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
73
74 %.so: %.c
75 $(CC) -fPIC -shared $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
76
77 # install config files only if a startup-config does not exist yet
78 # this does not interfere when building rpms or debs and makes
79 # fast upgrading via make install possible
80
81 install: all
82 $(INSTALL) -m 0755 l2tpns $(DESTDIR)$(bindir)/l2tpns
83 $(INSTALL) -m 0755 nsctl $(DESTDIR)$(bindir)/nsctl
84
85 $(INSTALL) -m 0644 Docs/startup-config.5 $(DESTDIR)$(man5dir)/startup-config.5
86 $(INSTALL) -m 0644 Docs/l2tpns.8 $(DESTDIR)$(man8dir)/l2tpns.8
87 $(INSTALL) -m 0644 Docs/nsctl.8 $(DESTDIR)$(man8dir)/nsctl.8
88
89 gzip --best $(DESTDIR)$(man5dir)/*.5 $(DESTDIR)$(man8dir)/*.8
90
91 @if [ -f $(DESTDIR)$(etcdir)/startup-config ]; then \
92 echo '***' Installing default config files in $(DESTDIR)$(etcdir) as .defaults; \
93 suffix=.default; \
94 else \
95 echo '***' Installing default config files in $(DESTDIR)$(etcdir) - remember to adjust them; \
96 suffix=; \
97 fi; \
98
99 $(INSTALL) -m 0600 etc/startup-config.default $(DESTDIR)$(etcdir)/startup-config$$suffix; \
100 $(INSTALL) -m 0644 etc/ip_pool.default $(DESTDIR)$(etcdir)/ip_pool$$suffix; \
101 $(INSTALL) -m 0600 etc/users.default $(DESTDIR)$(etcdir)/users$$suffix
102
103 for plugin in $(PLUGINS); do \
104 $(INSTALL) -m 0755 $$plugin $(DESTDIR)$(libdir)/$$plugin; \
105 done
106
107 if [ -z $(DESTDIR) ] && [ ! -e /dev/net/tun ]; then \
108 mkdir /dev/net; \
109 mknod /dev/net/tun c 10 200; \
110 fi
111
112 .PHONY: all clean depend install
113
114 ## Dependencies: (autogenerated) ##
115 arp.o: arp.c l2tpns.h
116 cli.o: cli.c l2tpns.h util.h cluster.h tbf.h ll.h bgp.h
117 cluster.o: cluster.c l2tpns.h cluster.h util.h tbf.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
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
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 radius.o: radius.c md5.h constants.h l2tpns.h plugin.h util.h
127 tbf.o: tbf.c l2tpns.h util.h tbf.h
128 util.o: util.c l2tpns.h bgp.h
129 bgp.o: bgp.c l2tpns.h bgp.h util.h
130 garden.so: garden.c l2tpns.h plugin.h control.h
131 throttlectl.so: throttlectl.c l2tpns.h plugin.h control.h
132 autothrottle.so: autothrottle.c l2tpns.h plugin.h
133 snoopctl.so: snoopctl.c l2tpns.h plugin.h control.h
134 autosnoop.so: autosnoop.c l2tpns.h plugin.h
135 stripdomain.so: stripdomain.c l2tpns.h plugin.h
136 setrxspeed.so: setrxspeed.c l2tpns.h plugin.h