4 libdir = /usr
/lib
/l2tpns
5 man5dir = /usr
/share
/man
/man5
6 man8dir = /usr
/share
/man
/man8
7 statedir = /var
/lib
/l2tpns
10 DEFINES
+= -DSTATISTICS
11 DEFINES
+= -DSTAT_CALLS
12 DEFINES
+= -DRINGBUFFER
14 DEFINES
+= -DLIBDIR
='"$(libdir)"'
15 DEFINES
+= -DETCDIR
='"$(etcdir)"'
16 DEFINES
+= -DSTATEDIR
='"$(statedir)"'
20 OPTIM
+= -funroll-loops
21 OPTIM
+= -fomit-frame-pointer
22 OPTIM
+= -finline-functions
23 #OPTIM += -fstrength-reduce
28 CPPFLAGS
= $(INCLUDES
) $(DEFINES
)
29 CFLAGS
= -Wall
$(OPTIM
)
32 INSTALL
= install -c
-D
-o root
-g root
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
37 PLUGINS
= garden.so throttlectl.so autothrottle.so snoopctl.so \
38 autosnoop.so stripdomain.so setrxspeed.so
40 TARGETS
= l2tpns nsctl generateload bounce
$(PLUGINS
)
45 rm -f
*.o
test/*.o
$(TARGETS
) Makefile.tmp Makefile.bak
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
55 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
) -lcli
-ldl
57 nsctl
: nsctl.o control.o
58 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
60 generateload
: test/generateload.o
61 $(LD
) $(LDFLAGS
) -o
$@
$^
# -lpthread
64 $(LD
) $(LDFLAGS
) -o
$@
$^
67 $(CC
) $(CFLAGS
) $(CPPFLAGS
) -c
-o
$@
$<
70 $(CC
) -fPIC
-shared
$(CFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) -o
$@
$<
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
77 $(INSTALL
) -m
0755 l2tpns
$(DESTDIR
)$(bindir)/l2tpns
78 $(INSTALL
) -m
0755 nsctl
$(DESTDIR
)$(bindir)/nsctl
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
84 gzip
$(DESTDIR
)$(man5dir)/*.5 $(DESTDIR
)$(man8dir)/*.8
86 @if
[ -f
$(DESTDIR
)$(etcdir
)/startup-config
]; then \
87 echo
'***' Installing default config files in
$(DESTDIR
)$(etcdir
) as .defaults
; \
90 echo
'***' Installing default config files in
$(DESTDIR
)$(etcdir
) - remember to adjust them
; \
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
98 for plugin in
$(PLUGINS
); do \
99 $(INSTALL
) -m
0755 $$plugin $(DESTDIR
)$(libdir)/$$plugin; \
102 if
[ -z
$(DESTDIR
) ] && [ ! -e
/dev
/net
/tun
]; then \
104 mknod
/dev
/net
/tun c
10 200; \
107 .PHONY
: all clean depend
install
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
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