4 ## The secure anycast tunneling protocol (satp) defines a protocol used
5 ## for communication between any combination of unicast and anycast
6 ## tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 ## mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 ## ethernet, ip, arp ...). satp directly includes cryptography and
9 ## message authentication based on the methods used by SRTP. It is
10 ## intended to deliver a generic, scaleable and secure solution for
11 ## tunneling and relaying of packets of any protocol.
14 ## Copyright (C) 2007-2014 Markus Grüneis, Othmar Gsenger, Erwin Nindl,
15 ## Christian Pointner <satp@wirdorange.org>
17 ## This file is part of Anytun.
19 ## Anytun is free software: you can redistribute it and/or modify
20 ## it under the terms of the GNU General Public License as published by
21 ## the Free Software Foundation, either version 3 of the License, or
24 ## Anytun is distributed in the hope that it will be useful,
25 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ## GNU General Public License for more details.
29 ## You should have received a copy of the GNU General Public License
30 ## along with Anytun. If not, see <http://www.gnu.org/licenses/>.
32 ## In addition, as a special exception, the copyright holders give
33 ## permission to link the code of portions of this program with the
34 ## OpenSSL library under certain conditions as described in each
35 ## individual source file, and distribute linked combinations
37 ## You must obey the GNU General Public License in all respects
38 ## for all of the code used other than OpenSSL. If you modify
39 ## file(s) with this exception, you may extend this exception to your
40 ## version of the file(s), but you are not obligated to do so. If you
41 ## do not wish to do so, delete this exception statement from your
42 ## version. If you delete this exception statement from all source
43 ## files in the program, then also delete it here.
46 ifneq ($(MAKECMDGOALS),distclean)
50 ANYTUNOBJS := packetSource.o \
64 keyDerivationFactory.o \
76 ifneq ($(TARGET),mingw)
77 ANYTUNOBJS := $(ANYTUNOBJS) \
81 ANYTUNOBJS := $(ANYTUNOBJS) \
89 ANYSHOWOBJS := buffer.o \
92 keyDerivationFactory.o \
107 SYNCOBJS := syncServer.o \
112 syncConnectionCommand.o \
116 ANYCTROBJS := signalController.o \
122 syncTcpConnection.o \
126 ifneq ($(TARGET),mingw)
127 ANYCTROBJS := $(ANYCTROBJS) \
130 ANYCTROBJS := $(ANYCTROBJS) \
135 ANYCONFOBJS := log.o \
140 keyDerivationFactory.o \
153 syncTcpConnection.o \
155 syncConnectionCommand.o \
158 ifneq ($(TARGET),mingw)
164 EXECUTABLES := anytun$(EXE) anytun-config$(EXE) anytun-controld$(EXE) anytun-showtables$(EXE) anytun-nosync$(EXE)
165 EXEOBJS := anytun.o anytun-config.o anytun-controld.o anytun-showtables.o
167 ANYTUNSRCS := $(ANYTUNOBJS:%.o=%.cpp)
168 ANYSHOWSRCS := $(ANYSHOWOBJS:%.o=%.cpp)
169 SYNCSRCS := $(SYNCOBJS:%.o=%.cpp)
170 ANYCTRSRCS := $(ANYCTROBJS:%.o=%.cpp)
171 ANYCONFSRCS := $(ANYCONFOBJS:%.o=%.cpp)
172 EXESRCS := $(EXEOBJS:%.o=%.cpp)
174 .PHONY: distclean cleanall clean manpage install install-bin install-etc install-man uninstall remove purge
176 all: $(EXECUTABLES) #libAnysync.a
180 $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
181 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
182 rm -f $@.$$$$; echo '(re)building $@'
184 ifneq ($(MAKECMDGOALS),distclean)
185 -include $(ANYTUNSRCS:%.cpp=%.d) $(ANYSHOWSRCS:%.cpp=%.d) $(SYNCSRCS:%.cpp=%.d) $(ANYCTRSRCS:%.cpp=%.d) $(ANYCONFSRCS:%.cpp=%.d) $(EXESRCS:%.cpp=%.d)
188 strip: $(EXECUTABLES)
189 $(STRIP) -s $(EXECUTABLES)
191 anytun$(EXE): $(ANYTUNOBJS) $(SYNCOBJS) anytun.o
192 $(LD) $(ANYTUNOBJS) $(SYNCOBJS) anytun.o -o $@ $(LDFLAGS)
194 anytun-static: $(ANYTUNOBJS) $(SYNCOBJS) anytun-noprivdrop.o
195 $(LD) $(ANYTUNOBJS) $(SYNCOBJS) anytun-noprivdrop.o -o $@ -Bstatic -lstdc++ -static $(LDFLAGS) -lpthread
196 $(STRIP) -s anytun-static
198 anytun-nosync$(EXE): $(ANYTUNOBJS) anytun-nosync.o
199 $(LD) $(ANYTUNOBJS) anytun-nosync.o -o $@ $(LDFLAGS)
201 anytun-nosync.o: anytun.cpp
202 $(CXX) $(CXXFLAGS) -DANYTUN_NOSYNC $< -c -o anytun-nosync.o
204 anytun-showtables$(EXE): $(ANYSHOWOBJS) $(SYNCOBJS) anytun-showtables.o
205 $(LD) $(ANYSHOWOBJS) $(SYNCOBJS) anytun-showtables.o -o $@ $(LDFLAGS)
207 anytun-config$(EXE): $(ANYCONFOBJS) anytun-config.o
208 $(LD) $(ANYCONFOBJS) anytun-config.o -o $@ $(LDFLAGS)
210 anytun-controld$(EXE): $(ANYCTROBJS) anytun-controld.o
211 $(LD) $(ANYCTROBJS) anytun-controld.o -o $@ $(LDFLAGS)
214 options.o: options.cpp
215 $(CXX) $(CXXFLAGS) -DANYTUN_OPTIONS $< -c -o $@
217 anyCtrOptions.o: options.cpp
218 $(CXX) $(CXXFLAGS) -DANYCTR_OPTIONS $< -c -o $@
220 anyConfOptions.o: options.cpp
221 $(CXX) $(CXXFLAGS) -DANYCONF_OPTIONS $< -c -o $@
223 nullOptions.o: options.cpp
224 $(CXX) $(CXXFLAGS) $< -c -o $@
227 $(CXX) $(CXXFLAGS) $< -c -o $@
230 libAnysync.a: $(OBJS)
235 $(MAKE) --directory=$(CURDIR)/anyrtpproxy
239 find . -name *.o -exec rm -f {} \;
240 rm -f config.sub config.guess
241 rm -f daemonService.h
242 rm -f daemonService.cpp
243 rm -f signalHandler.hpp
250 $(MAKE) --directory="../doc" clean
265 $(MAKE) --directory=$(CURDIR)/anyrtpproxy clean
268 $(MAKE) --directory="../doc" manpage
271 INSTALL_TARGETS := install-bin install-etc
272 REMOVE_TARGETS := remove-bin remove-etc
275 INSTALL_TARGETS += install-man
276 REMOVE_TARGETS += remove-man
280 INSTALL_TARGETS += install-examples
281 REMOVE_TARGETS += remove-examples
284 install: all $(INSTALL_TARGETS)
286 install-bin: $(EXECUTABLES)
287 $(INSTALL) -d $(DESTDIR)$(SBINDIR)
288 $(INSTALL) -m 755 anytun $(DESTDIR)$(SBINDIR)
289 $(INSTALL) -d $(DESTDIR)$(BINDIR)
290 $(INSTALL) -m 755 anytun-config $(DESTDIR)$(BINDIR)
291 $(INSTALL) -m 755 anytun-controld $(DESTDIR)$(BINDIR)
292 $(INSTALL) -m 755 anytun-showtables $(DESTDIR)$(BINDIR)
295 $(INSTALL) -d $(DESTDIR)$(ETCDIR)/anytun
296 @ echo "example configurations can be found at $(EXAMPLESDIR)/anytun" > $(DESTDIR)$(ETCDIR)/anytun/README
297 $(INSTALL) -d $(DESTDIR)$(ETCDIR)/init.d
298 @ sed -e 's#DAEMON=/usr/sbin/anytun#DAEMON=$(SBINDIR)/anytun#' \
299 -e 's#ANYTUNCONFIG=/usr/bin/anytun-config#ANYTUNCONFIG=$(BINDIR)/anytun-config#' \
300 -e 's#CONTROLDAEMON=/usr/bin/anytun-controld#CONTROLDAEMON=$(BINDIR)/anytun-controld#' \
301 -e 's#CONFIG_DIR=/etc/anytun#CONFIG_DIR=$(ETCDIR)/anytun#' ../etc/init.d/anytun > ../etc/init.d/anytun.bak
302 $(INSTALL) -m 755 ../etc/init.d/anytun.bak $(DESTDIR)$(ETCDIR)/init.d/anytun
303 rm -f ../etc/init.d/anytun.bak
306 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun
307 $(INSTALL) -m 644 ../etc/anytun/autostart $(DESTDIR)$(EXAMPLESDIR)/anytun/autostart
308 @( cd '../etc/anytun/' ; \
309 for dir in `ls`; do \
310 if [ -d $$dir ]; then \
311 echo "install $$dir configuration" ; \
313 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir ; \
314 $(INSTALL) -m 600 config $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/config ; \
315 if [ -e 'post-up.sh' ]; then \
316 $(INSTALL) -m 755 post-up.sh $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/post-up.sh ; \
318 if [ -d 'conf.d' ]; then \
319 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/conf.d ; \
321 for file in `ls`; do \
322 if [ -f $$file ]; then \
323 $(INSTALL) -m 600 $$file $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/conf.d ; \
334 $(INSTALL) -d $(DESTDIR)$(MANDIR)/man8/
335 $(INSTALL) -m 644 ../doc/anytun.8 $(DESTDIR)$(MANDIR)/man8/
336 $(INSTALL) -m 644 ../doc/anytun-config.8 $(DESTDIR)$(MANDIR)/man8/
337 $(INSTALL) -m 644 ../doc/anytun-controld.8 $(DESTDIR)$(MANDIR)/man8/
338 $(INSTALL) -m 644 ../doc/anytun-showtables.8 $(DESTDIR)$(MANDIR)/man8/
343 remove: $(REMOVE_TARGETS)
346 rm -f $(DESTDIR)$(SBINDIR)/anytun
347 rm -f $(DESTDIR)$(BINDIR)/anytun-config
348 rm -f $(DESTDIR)$(BINDIR)/anytun-controld
349 rm -f $(DESTDIR)$(BINDIR)/anytun-showtables
352 rm -f $(DESTDIR)$(ETCDIR)/init.d/anytun
355 rm -rf $(DESTDIR)$(EXAMPLESDIR)/anytun/
358 rm -f $(DESTDIR)$(MANDIR)/man8/anytun.8
359 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-config.8
360 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-controld.8
361 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-showtables.8
364 rm -rf $(DESTDIR)$(ETCDIR)/anytun/