4 libdir = /usr
/lib
/l2tpns
5 man5dir = /usr
/share
/man
/man5
6 man8dir = /usr
/share
/man
/man8
7 statedir = /var
/lib
/l2tpns
10 DEFINES
+= -DLIBDIR
='"$(libdir)"'
11 DEFINES
+= -DETCDIR
='"$(etcdir)"'
20 CPPFLAGS
= $(INCLUDES
) $(DEFINES
)
21 CFLAGS
= -Wall
-Wformat-security
-Wno-format-zero-length
$(OPTIM
)
24 INSTALL
= install -c
-D
-o root
-g root
26 l2tpns.LIBS
= -lm
-lcli
-ldl
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
31 PROGRAMS
= l2tpns nsctl
32 PLUGINS
= garden.so throttlectl.so autothrottle.so snoopctl.so \
33 autosnoop.so stripdomain.so setrxspeed.so
35 TESTS
= generateload bounce
37 DEFINES
+= -DSTATISTICS
38 DEFINES
+= -DSTAT_CALLS
39 DEFINES
+= -DRINGBUFFER
44 doit
= echo
$(1); $(1)
46 all: programs plugins tests
52 rm -f
*.o
test/*.o
$(PROGRAMS
) $(PLUGINS
) $(TESTS
) Makefile.tmp Makefile.bak
55 (sed
-n
'p; /^## Dependencies: (autogenerated) ##/q' Makefile
&& \
56 gcc
-MM
$(CPPFLAGS
) $(OBJS
:.o
=.c
) && \
57 gcc
-MM
$(CPPFLAGS
) $(PLUGINS
:.so
=.c
) | sed
's/\.o/.so/') >Makefile.tmp
58 mv Makefile Makefile.bak
59 mv Makefile.tmp Makefile
62 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
) $($@.LIBS
)
64 nsctl
: nsctl.o control.o
65 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
) $($@.LIBS
)
67 generateload
: test/generateload.o
68 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
) $($@.LIBS
)
71 $(LD
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
) $($@.LIBS
)
74 $(CC
) $(CFLAGS
) $(CPPFLAGS
) -c
-o
$@
$<
77 $(CC
) -fPIC
-shared
$(CFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) -o
$@
$<
80 $(INSTALL
) -m
0755 l2tpns
$(DESTDIR
)$(bindir)/l2tpns
81 $(INSTALL
) -m
0755 nsctl
$(DESTDIR
)$(bindir)/nsctl
83 $(INSTALL
) -m
0644 Docs
/startup-config
.5 $(DESTDIR
)$(man5dir)/startup-config
.5
84 $(INSTALL
) -m
0644 Docs
/l2tpns
.8 $(DESTDIR
)$(man8dir)/l2tpns
.8
85 $(INSTALL
) -m
0644 Docs
/nsctl
.8 $(DESTDIR
)$(man8dir)/nsctl
.8
87 gzip
--best
--force $(DESTDIR
)$(man5dir)/*.5 $(DESTDIR
)$(man8dir)/*.8
89 @for config in startup-config users ip_pool
; \
92 mode
=0600; [ $$config = ip_pool
] && mode
=0644; \
93 if
[ -f
$(DESTDIR
)$(etcdir
)/$$config ]; \
95 cmp
-s etc
/$$config.default
$(DESTDIR
)$(etcdir
)/$$config && continue
; \
98 $(call doit
,$(INSTALL
) -m
$$mode etc
/$$config.default
$(DESTDIR
)$(etcdir
)/$$config$$suffix); \
101 @for plugin in
$(PLUGINS
); \
103 $(call doit
,$(INSTALL
) -m
0755 $$plugin $(DESTDIR
)$(libdir)/$$plugin); \
106 @if
[ -z
$(DESTDIR
) ] && [ ! -e
/dev
/net
/tun
]; \
109 $(call doit
,mknod
/dev
/net
/tun c
10 200); \
112 .PHONY
: all clean depend
install
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
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