- Add startup-config(5) manpage.
[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 += -DSTATISTICS
11 DEFINES += -DSTAT_CALLS
12 DEFINES += -DRINGBUFFER
13 DEFINES += -DBGP
14 DEFINES += -DLIBDIR='"$(libdir)"'
15 DEFINES += -DETCDIR='"$(etcdir)"'
16 DEFINES += -DSTATEDIR='"$(statedir)"'
17
18 OPTIM = -g
19 OPTIM += -O3
20 OPTIM += -funroll-loops
21 OPTIM += -fomit-frame-pointer
22 OPTIM += -finline-functions
23 #OPTIM += -fstrength-reduce
24
25 CC = gcc
26 LD = gcc
27 INCLUDES = -I.
28 CPPFLAGS = $(INCLUDES) $(DEFINES)
29 CFLAGS = -Wall $(OPTIM)
30 LDFLAGS =
31 LDLIBS = -lm
32 INSTALL = install -c -D -o root -g root
33
34 OBJS = arp.o bgp.o cli.o cluster.o constants.o control.o icmp.o \
35 l2tpns.o ll.o md5.o ppp.o radius.o tbf.o util.o
36
37 PLUGINS = garden.so throttlectl.so autothrottle.so snoopctl.so \
38 autosnoop.so stripdomain.so setrxspeed.so
39
40 TARGETS = l2tpns nsctl generateload bounce $(PLUGINS)
41
42 all: $(TARGETS)
43
44 clean:
45 rm -f *.o test/*.o $(TARGETS) Makefile.tmp Makefile.bak
46
47 depend:
48 (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
49 gcc -MM $(CPPFLAGS) $(OBJS:.o=.c) && \
50 gcc -MM $(CPPFLAGS) $(PLUGINS:.so=.c) | sed 's/\.o/.so/') >Makefile.tmp
51 mv Makefile Makefile.bak
52 mv Makefile.tmp Makefile
53
54 l2tpns: $(OBJS)
55 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) -lcli -ldl
56
57 nsctl: nsctl.o control.o
58 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
59
60 generateload: test/generateload.o
61 $(LD) $(LDFLAGS) -o $@ $^ # -lpthread
62
63 bounce: test/bounce.o
64 $(LD) $(LDFLAGS) -o $@ $^
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 config files only if a startup-config does not exist yet
73 # this does not interfere when building rpms or debs and makes
74 # fast upgrading via make install possible
75
76 install: all
77 $(INSTALL) -m 0755 l2tpns $(DESTDIR)$(bindir)/l2tpns
78 $(INSTALL) -m 0755 nsctl $(DESTDIR)$(bindir)/nsctl
79
80 $(INSTALL) -m 0644 Docs/startup-config.5 $(DESTDIR)$(man5dir)/startup-config.5
81 $(INSTALL) -m 0644 Docs/l2tpns.8 $(DESTDIR)$(man8dir)/l2tpns.8
82 $(INSTALL) -m 0644 Docs/nsctl.8 $(DESTDIR)$(man8dir)/nsctl.8
83
84 gzip $(DESTDIR)$(man5dir)/*.5 $(DESTDIR)$(man8dir)/*.8
85
86 @if [ -f $(DESTDIR)$(etcdir)/startup-config ]; then \
87 echo '***' Installing default config files in $(DESTDIR)$(etcdir) as .defaults; \
88 suffix=.default; \
89 else \
90 echo '***' Installing default config files in $(DESTDIR)$(etcdir) - remember to adjust them; \
91 suffix=; \
92 fi; \
93
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 install
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 l2tpns.h 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 throttlectl.so: throttlectl.c l2tpns.h plugin.h control.h
127 autothrottle.so: autothrottle.c l2tpns.h plugin.h
128 snoopctl.so: snoopctl.c l2tpns.h plugin.h control.h
129 autosnoop.so: autosnoop.c l2tpns.h plugin.h
130 stripdomain.so: stripdomain.c l2tpns.h plugin.h
131 setrxspeed.so: setrxspeed.c l2tpns.h plugin.h