improved Makefile (clean now for -j *)
[anytun.git] / src / Makefile
blob52956e6760741cf4395b90fe8eb661a8a977e71c
1 ##
2 ## anytun
3 ##
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 methodes 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-2008 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 version 3 as
21 ## published by the Free Software Foundation.
23 ## Anytun is distributed in the hope that it will be useful,
24 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
25 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ## GNU General Public License for more details.
28 ## You should have received a copy of the GNU General Public License
29 ## along with anytun. If not, see <http://www.gnu.org/licenses/>.
31 TARGET=$(shell uname -s)
32 CC = gcc
33 CFLAGS = -g
34 CXX = g++
35 CXXFLAGS = -g -Wall -O2 #-DUSE_SSL_CRYPTO
36 LD = g++
37 LDFLAGS = -g -Wall -O2 -lboost_thread -lgcrypt -lgpg-error -lboost_serialization -lboost_system
38 #LDFLAGS = -g -Wall -O2 -lboost_thread -lcrypto -lboost_serialization -lboost_system
40 ifeq ($(TARGET),Linux)
41 CFLAGS += -D_XOPEN_SOURCE=600
42 CXXFLAGS += -D_XOPEN_SOURCE=600
43 LDFLAGS += -ldl
44 endif
45 ifeq ($(TARGET),OpenBSD)
46 CXXFLAGS += -I/usr/local/include
47 LDFLAGS += -L/usr/local/lib
48 endif
50 OBJS = tunDevice.o \
51 packetSource.o \
52 buffer.o \
53 syncBuffer.o \
54 plainPacket.o \
55 encryptedPacket.o \
56 cipher.o \
57 authAlgo.o \
58 keyDerivation.o \
59 cipherFactory.o \
60 authAlgoFactory.o \
61 keyDerivationFactory.o \
62 connectionList.o \
63 connectionParam.o \
64 networkAddress.o \
65 networkPrefix.o \
66 routingTable.o \
67 signalController.o \
68 log.o \
69 options.o \
70 seqWindow.o \
71 routingTreeNode.o \
73 SYNCOBJS= syncServer.o \
74 syncClient.o \
75 syncQueue.o \
76 syncCommand.o \
77 syncRouteCommand.o \
78 syncConnectionCommand.o \
79 syncTcpConnection.o
81 ANYCTROBJS = signalController.o \
82 anyCtrOptions.o \
83 log.o \
84 syncTcpConnection.o \
85 syncServer.o
87 ANYCONFOBJS = log.o \
88 buffer.o \
89 keyDerivation.o \
90 keyDerivationFactory.o \
91 networkAddress.o \
92 networkPrefix.o \
93 connectionList.o \
94 connectionParam.o \
95 routingTreeNode.o \
96 anyConfOptions.o \
97 routingTable.o \
98 seqWindow.o \
99 syncQueue.o \
100 syncBuffer.o \
101 syncCommand.o \
102 syncServer.o \
103 syncTcpConnection.o \
104 syncRouteCommand.o \
105 syncConnectionCommand.o
107 EXECUTABLE = anytun anytun-config anytun-controld anytun-showtables
108 EXEOBJS = anytun.o anytun-config.o anytun-controld.o anytun-showtables.o
110 SRCS = $(OBJS:%.o=%.cpp)
111 SYNCSRCS = $(SYNCOBJS:%.o=%.cpp)
112 ANYCTRSRCS = $(ANYCTROBJS:%.o=%.cpp)
113 ANYCONFSRCS = $(ANYCONFOBJS:%.o=%.cpp)
114 EXESRCS = $(EXEOBJS:%.o=%.cpp)
116 .PHONY: distclean cleanall clean ctags
118 all: $(EXECUTABLE) #libAnysync.a
120 %.d: %.cpp
121 @set -e; rm -f $@; \
122 $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
123 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
124 rm -f $@.$$$$; echo '(re)building $@'
126 -include $(SRCS:%.cpp=%.d) $(SYNCSRCS:%.cpp=%.d) $(ANYCTRSRCS:%.cpp=%.d) $(ANYCONFSRCS:%.cpp=%.d) $(EXESRCS:%.cpp=%.d)
128 anytun: $(OBJS) $(SYNCOBJS) anytun.o
129 $(LD) $(OBJS) $(SYNCOBJS) anytun.o -o $@ $(LDFLAGS)
131 anytun-static: $(OBJS) $(SYNCOBJS) anytun.o
132 $(LD) $(OBJS) $(SYNCOBJS) anytun.o -o $@ $(LDFLAGS) -lpthread -static
133 strip -s anytun-static
135 anytun-nosync: $(OBJS) anytun-nosync.o
136 $(LD) $(OBJS) anytun-nosync.o -o $@ $(LDFLAGS)
138 anytun-nosync.o: anytun.cpp anytun.o
139 $(CXX) $(CXXFLAGS) -DANYTUN_NOSYNC $< -c -o anytun-nosync.o
141 anytun-showtables: $(OBJS) $(SYNCOBJS) anytun-showtables.o
142 $(LD) $(OBJS) $(SYNCOBJS) anytun-showtables.o -o $@ $(LDFLAGS)
144 anytun-config: $(ANYCONFOBJS) anytun-config.o
145 $(LD) $(ANYCONFOBJS) anytun-config.o -o $@ $(LDFLAGS)
147 anytun-controld: $(ANYCTROBJS) anytun-controld.o
148 $(LD) $(ANYCTROBJS) anytun-controld.o -o $@ $(LDFLAGS)
150 %.o: %.cpp
151 $(CXX) $(CXXFLAGS) $< -c
153 libAnysync.a: $(OBJS)
154 ar cru $@ $(OBJS)
155 ranlib $@
157 anyrtpproxy: anytun
158 $(MAKE) --directory=$(CURDIR)/anyrtpproxy
160 distclean: cleanall
161 find . -name *.o -exec rm -f {} \;
162 rm -f config.sub config.guess
163 rm -f tunDevice.cpp
165 cleanall: clean
166 $(MAKE) --directory=$(CURDIR)/man clean
168 clean:
169 rm -f *.o
170 rm -f *.d
171 rm -f $(EXECUTABLE)
172 rm -f anytun-nosync
173 rm -f -r doc/html/*
174 rm -f -r doc/latex/*
175 rm -f libAnysync.a
176 $(MAKE) --directory=$(CURDIR)/anyrtpproxy clean
178 manpage:
179 @cd man ; $(MAKE)
181 doxygen:
182 doxygen Doxyfile
184 ctags:
185 ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .