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 remove-systemd install-systemd remove-bin remove-man remove-examples
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
238 find . -name *.o -exec rm -f {} \;
239 rm -f config.sub config.guess
240 rm -f daemonService.h
241 rm -f daemonService.cpp
242 rm -f signalHandler.hpp
249 $(MAKE) --directory="../doc" clean
264 $(MAKE) --directory=$(CURDIR)/anyrtpproxy clean
267 $(MAKE) --directory="../doc" manpage
270 INSTALL_TARGETS := install-bin install-etc
271 REMOVE_TARGETS := remove-bin remove-etc
274 INSTALL_TARGETS += install-man
275 REMOVE_TARGETS += remove-man
279 INSTALL_TARGETS += install-examples
280 REMOVE_TARGETS += remove-examples
284 INSTALL_TARGETS += install-systemd
285 REMOVE_TARGETS := remove-systemd
288 install: all $(INSTALL_TARGETS)
290 install-bin: $(EXECUTABLES)
291 $(INSTALL) -d $(DESTDIR)$(SBINDIR)
292 $(INSTALL) -m 755 anytun $(DESTDIR)$(SBINDIR)
293 $(INSTALL) -d $(DESTDIR)$(BINDIR)
294 $(INSTALL) -m 755 anytun-config $(DESTDIR)$(BINDIR)
295 $(INSTALL) -m 755 anytun-controld $(DESTDIR)$(BINDIR)
296 $(INSTALL) -m 755 anytun-showtables $(DESTDIR)$(BINDIR)
297 $(INSTALL) -d $(DESTDIR)$(LIBDIR)
298 @ sed -e 's#/usr/local/sbin#$(SBINDIR)#' -e 's#/usr/local/bin#$(BINDIR)#' \
299 -e 's#/usr/local/etc#$(ETCDIR)#' ../usr/lib/anytun-launcher > ../usr/lib/anytun-launcher.bak
300 $(INSTALL) -m 755 ../usr/lib/anytun-launcher.bak $(DESTDIR)$(LIBDIR)/anytun-launcher
301 rm -f ../usr/lib/anytun-launcher.bak
304 $(INSTALL) -d $(DESTDIR)$(ETCDIR)/anytun
305 @ echo "example configurations can be found at $(EXAMPLESDIR)/anytun" > $(DESTDIR)$(ETCDIR)/anytun/README
306 $(INSTALL) -d $(DESTDIR)$(ETCDIR)/init.d
307 @ sed -e 's#/usr/local/bin#$(BINDIR)#' -e 's#/usr/local/lib#$(LIBDIR)#' -e 's#/usr/local/etc#$(ETCDIR)#' ../etc/init.d/anytun > ../etc/init.d/anytun.bak
308 $(INSTALL) -m 755 ../etc/init.d/anytun.bak $(DESTDIR)$(ETCDIR)/init.d/anytun
309 rm -f ../etc/init.d/anytun.bak
312 $(INSTALL) -d $(DESTDIR)$(SYSTEMDDIR)
313 $(INSTALL) -m 644 ../usr/lib/systemd/system/anytun.service $(DESTDIR)$(SYSTEMDDIR)/anytun.service
314 @ sed -e 's#/usr/local/lib#$(LIBDIR)#' ../usr/lib/systemd/system/anytun@.service > ../usr/lib/systemd/system/anytun@.service.bak
315 @ sed -e 's#/usr/local/lib#$(LIBDIR)#' ../usr/lib/systemd/system/anytun-controld@.service > ../usr/lib/systemd/system/anytun-controld@.service.bak
316 $(INSTALL) -m 644 ../usr/lib/systemd/system/anytun@.service.bak $(DESTDIR)$(SYSTEMDDIR)/anytun@.service
317 $(INSTALL) -m 644 ../usr/lib/systemd/system/anytun-controld@.service.bak $(DESTDIR)$(SYSTEMDDIR)/anytun-controld@.service
318 rm -f ../usr/lib/systemd/system/anytun@.service.bak
319 rm -f ../usr/lib/systemd/system/anytun-controld@.service.bak
320 $(INSTALL) -d $(DESTDIR)$(SYSTEMDGENERATORDIR)
321 @ sed -e 's#/usr/local/etc#$(ETCDIR)#' ../usr/lib/systemd/system-generator/anytun-generator > ../usr/lib/systemd/system-generator/anytun-generator.bak
322 $(INSTALL) -m 755 ../usr/lib/systemd/system-generator/anytun-generator.bak $(DESTDIR)$(SYSTEMDGENERATORDIR)/anytun-generator
323 rm -f ../usr/lib/systemd/system-generator/anytun-generator.bak
324 $(INSTALL) -d $(DESTDIR)$(TMPFILESDDIR)
325 $(INSTALL) -m 644 ../usr/lib/tmpfiles.d/anytun.conf $(DESTDIR)$(TMPFILESDDIR)/anytun.conf
328 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun
329 $(INSTALL) -m 644 ../etc/anytun/autostart $(DESTDIR)$(EXAMPLESDIR)/anytun/autostart
330 @( cd '../etc/anytun/' ; \
331 for dir in `ls`; do \
332 if [ -d $$dir ]; then \
333 echo "install $$dir configuration" ; \
335 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir ; \
336 $(INSTALL) -m 600 config $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/config ; \
337 if [ -e 'post-up.sh' ]; then \
338 $(INSTALL) -m 755 post-up.sh $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/post-up.sh ; \
340 if [ -d 'conf.d' ]; then \
341 $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/conf.d ; \
343 for file in `ls`; do \
344 if [ -f $$file ]; then \
345 $(INSTALL) -m 600 $$file $(DESTDIR)$(EXAMPLESDIR)/anytun/$$dir/conf.d ; \
356 $(INSTALL) -d $(DESTDIR)$(MANDIR)/man8/
357 $(INSTALL) -m 644 ../doc/anytun.8 $(DESTDIR)$(MANDIR)/man8/
358 $(INSTALL) -m 644 ../doc/anytun-config.8 $(DESTDIR)$(MANDIR)/man8/
359 $(INSTALL) -m 644 ../doc/anytun-controld.8 $(DESTDIR)$(MANDIR)/man8/
360 $(INSTALL) -m 644 ../doc/anytun-showtables.8 $(DESTDIR)$(MANDIR)/man8/
365 remove: $(REMOVE_TARGETS)
368 rm -f $(DESTDIR)$(SBINDIR)/anytun
369 rm -f $(DESTDIR)$(BINDIR)/anytun-config
370 rm -f $(DESTDIR)$(BINDIR)/anytun-controld
371 rm -f $(DESTDIR)$(BINDIR)/anytun-showtables
374 rm -f $(DESTDIR)$(ETCDIR)/init.d/anytun
377 rm -f $(DESTDIR)$(SYSTEMDDIR)/anytun.service
378 rm -f $(DESTDIR)$(SYSTEMDDIR)/anytun@.service
379 rm -f $(DESTDIR)$(SYSTEMDDIR)/anytun-controld@.service
380 rm -f $(DESTDIR)$(SYSTEMDGENERATORDIR)/anytun-generator
381 rm -f $(DESTDIR)$(TMPFILESDDIR)/anytun.conf
384 rm -rf $(DESTDIR)$(EXAMPLESDIR)/anytun/
387 rm -f $(DESTDIR)$(MANDIR)/man8/anytun.8
388 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-config.8
389 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-controld.8
390 rm -f $(DESTDIR)$(MANDIR)/man8/anytun-showtables.8
393 rm -rf $(DESTDIR)$(ETCDIR)/anytun/