Imported Upstream version 0.3
[anytun.git] / src / Makefile
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.
12 ##
13 ##
14 ##  Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl, 
15 ##                          Christian Pointner <satp@wirdorange.org>
16 ##
17 ##  This file is part of Anytun.
18 ##
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.
22 ##
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.
27 ##
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/>.
30 ##
31
32 ifneq ($(MAKECMDGOALS),distclean)
33 include include.mk
34 endif
35
36 OBJS := tunDevice.o \
37        packetSource.o \
38        buffer.o \
39        syncBuffer.o \
40                          plainPacket.o \
41                          encryptedPacket.o \
42        cipher.o \
43        authAlgo.o \
44                          keyDerivation.o \
45                          cipherFactory.o \
46                          authAlgoFactory.o \
47                          keyDerivationFactory.o \
48                          connectionList.o \
49                          connectionParam.o \
50                          networkAddress.o \
51                          networkPrefix.o \
52                          routingTable.o \
53        signalController.o \
54        log.o \
55        logTargets.o \
56        anytunError.o \
57        options.o \
58        seqWindow.o \
59                          routingTreeNode.o \
60                          resolver.o
61
62 SYNCOBJS := syncServer.o \
63        syncClient.o \
64        syncQueue.o \
65                          syncCommand.o \
66        syncRouteCommand.o \
67        syncConnectionCommand.o \
68        syncTcpConnection.o
69
70 ANYCTROBJS := signalController.o \
71                                                         anyCtrOptions.o \
72                                                  buffer.o \
73                                                  log.o \
74                                                  logTargets.o \
75                                                  anytunError.o \
76                                                  syncTcpConnection.o \
77                                                  syncServer.o \
78                                                  resolver.o
79
80 ANYCONFOBJS := log.o \
81                                                  logTargets.o \
82                                                  anytunError.o \
83                                                  buffer.o \
84                                                  keyDerivation.o \
85                                                  keyDerivationFactory.o \
86                                                  networkAddress.o \
87                                                  networkPrefix.o \
88                                                  connectionList.o \
89                                                  connectionParam.o \
90                                                  routingTreeNode.o \
91                                                  anyConfOptions.o \
92                                                  routingTable.o \
93                                                  seqWindow.o \
94                                                  syncQueue.o \
95                                                  syncBuffer.o \
96                                                  syncCommand.o \
97                                                  syncServer.o \
98              syncTcpConnection.o \
99                                                  syncRouteCommand.o \
100                                                  syncConnectionCommand.o \
101                                                  resolver.o
102
103 EXECUTABLE := anytun anytun-config anytun-controld anytun-showtables anytun-nosync
104 EXEOBJS := anytun.o anytun-config.o anytun-controld.o anytun-showtables.o
105
106 SRCS := $(OBJS:%.o=%.cpp)
107 SYNCSRCS := $(SYNCOBJS:%.o=%.cpp)
108 ANYCTRSRCS := $(ANYCTROBJS:%.o=%.cpp)
109 ANYCONFSRCS := $(ANYCONFOBJS:%.o=%.cpp)
110 EXESRCS := $(EXEOBJS:%.o=%.cpp)
111
112 .PHONY: distclean cleanall clean ctags
113
114 all: $(EXECUTABLE) #libAnysync.a 
115
116 %.d: %.cpp
117         @set -e; rm -f $@; \
118          $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
119    sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
120    rm -f $@.$$$$; echo '(re)building $@'
121
122 ifneq ($(MAKECMDGOALS),distclean)
123 -include $(SRCS:%.cpp=%.d) $(SYNCSRCS:%.cpp=%.d) $(ANYCTRSRCS:%.cpp=%.d) $(ANYCONFSRCS:%.cpp=%.d) $(EXESRCS:%.cpp=%.d)
124 endif
125
126 strip: $(EXECUTABLE)
127         strip -s $(EXECUTABLE) 
128
129 anytun: $(OBJS) $(SYNCOBJS) anytun.o
130         $(LD) $(OBJS) $(SYNCOBJS) anytun.o -o $@ $(LDFLAGS)
131
132 anytun-static: $(OBJS) $(SYNCOBJS) anytun-noprivdrop.o
133         $(LD) $(OBJS) $(SYNCOBJS) anytun-noprivdrop.o -o $@ -Bstatic -lstdc++ -static $(LDFLAGS) -lpthread
134         strip -s anytun-static
135
136 anytun-nosync: $(OBJS) anytun-nosync.o
137         $(LD) $(OBJS) anytun-nosync.o -o $@ $(LDFLAGS)
138
139 anytun-nosync.o: anytun.cpp
140         $(CXX) $(CXXFLAGS) -DANYTUN_NOSYNC $< -c -o anytun-nosync.o
141
142 anytun-noprivdrop.o: anytun.cpp
143         $(CXX) $(CXXFLAGS) -DNO_PRIVDROP $< -c -o anytun-noprivdrop.o
144
145 anytun-showtables: $(OBJS) $(SYNCOBJS) anytun-showtables.o
146         $(LD) $(OBJS) $(SYNCOBJS) anytun-showtables.o -o $@ $(LDFLAGS)
147
148 anytun-config: $(ANYCONFOBJS) anytun-config.o
149         $(LD) $(ANYCONFOBJS) anytun-config.o -o $@ $(LDFLAGS)
150
151 anytun-controld: $(ANYCTROBJS) anytun-controld.o
152         $(LD) $(ANYCTROBJS) anytun-controld.o -o $@ $(LDFLAGS)
153
154
155 options.o: options.cpp 
156         $(CXX) $(CXXFLAGS) -DANYTUN_OPTIONS $< -c -o $@
157
158 anyCtrOptions.o: options.cpp 
159         $(CXX) $(CXXFLAGS) -DANYCTR_OPTIONS $< -c -o $@
160
161 anyConfOptions.o: options.cpp 
162         $(CXX) $(CXXFLAGS) -DANYCONF_OPTIONS $< -c -o $@
163
164 %.o: %.cpp
165         $(CXX) $(CXXFLAGS) $< -c
166
167
168 libAnysync.a: $(OBJS)
169         ar cru $@ $(OBJS)
170         ranlib $@
171
172 anyrtpproxy: anytun
173         $(MAKE) --directory=$(CURDIR)/anyrtpproxy
174
175
176 distclean: cleanall
177         find . -name *.o -exec rm -f {} \;
178         rm -f config.sub config.guess
179         rm -f tunDevice.cpp
180         rm -f include.mk
181
182 cleanall: clean
183         $(MAKE) --directory=$(CURDIR)/man clean
184
185 clean:
186         rm -f *.o
187         rm -f *.d
188         rm -f *.d.*
189         rm -f $(EXECUTABLE)
190         rm -f anytun-nosync
191         rm -f -r doc/html/*
192         rm -f -r doc/latex/*
193         rm -f libAnysync.a
194         $(MAKE) --directory=$(CURDIR)/anyrtpproxy clean
195
196 manpage:
197         @cd man ; $(MAKE)
198