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