Imported Upstream version 0.3
[anytun.git] / src / configure
1 #!/bin/sh
2 #
3 #  anytun
4 #
5 #  The secure anycast tunneling protocol (satp) defines a protocol used
6 #  for communication between any combination of unicast and anycast
7 #  tunnel endpoints.  It has less protocol overhead than IPSec in Tunnel
8 #  mode and allows tunneling of every ETHER TYPE protocol (e.g.
9 #  ethernet, ip, arp ...). satp directly includes cryptography and
10 #  message authentication based on the methodes used by SRTP.  It is
11 #  intended to deliver a generic, scaleable and secure solution for
12 #  tunneling and relaying of packets of any protocol.
13 #
14 #
15 #  Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl, 
16 #                          Christian Pointner <satp@wirdorange.org>
17 #
18 #  This file is part of Anytun.
19 #
20 #  Anytun is free software: you can redistribute it and/or modify
21 #  it under the terms of the GNU General Public License version 3 as
22 #  published by the Free Software Foundation.
23 #
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.
28 #
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/>.
31 #
32
33 TARGET=`uname -s`
34
35 CXXFLAGS='-g -Wall -O2 -DLOG_SYSLOG -DLOG_FILE -DLOG_STDOUT'
36 LDFLAGS='-g -Wall -O2 -lboost_thread -lboost_serialization -lboost_system'
37
38 CRYPTO_LIB='gcrypt'
39 PASSPHRASE=1
40 ROUTING=1
41
42 print_usage() {
43   echo "configure --help                    print this"
44   echo "          --use-ssl-crypto          use ssl crypto library instead of libgcrypt"
45   echo "          --disable-crypto          disable crypto at all (only NULL cipher)"
46   echo "          --disable-passphrase      disable master key and salt passphrase"
47   echo "          --disable-routing         disable built-in routing capability"
48 }
49
50 for arg
51 do
52   case $arg in
53   --use-ssl-crypto)
54     CRYPTO_LIB='ssl'
55   ;;
56   --disable-crypto)
57     CRYPTO_LIB='none'
58   ;; 
59   --disable-passphrase)
60     PASSPHRASE=0
61   ;;
62   --disable-routing)
63     ROUTING=0
64   ;;
65   --help)
66     print_usage
67     exit 0
68   ;;
69   *)
70     echo "Unknown argument: $arg"
71     print_usage
72     exit 1
73   ;;
74   esac
75 done
76
77 rm -f include.mk
78 case $TARGET in 
79         Linux)
80                 rm -rf tunDevice.cpp
81                 ln -sf linux/tunDevice.cpp 
82     echo "loading Linux specific TUN Device"
83         ;;
84         OpenBSD|FreeBSD|NetBSD)
85                 rm -rf tunDevice.cpp
86                 ln -sf bsd/tunDevice.cpp 
87     echo "loading BSD specific TUN Device"
88     CXXFLAGS=$CXXFLAGS' -I/usr/local/include'
89     LDFLAGS=$LDFLAGS' -L/usr/local/lib'
90         ;;
91         *)
92                 echo "Plattform not supported"
93     exit 1
94         ;;
95 esac
96
97 case $CRYPTO_LIB in
98   gcrypt)
99     LDFLAGS=$LDFLAGS' -lgcrypt -lgpg-error'
100     echo "using libgcrypt library"
101   ;;
102   ssl)
103     CXXFLAGS=$CXXFLAGS' -DUSE_SSL_CRYPTO'
104     LDFLAGS=$LDFLAGS' -lcrypto'
105     echo "using ssl crypto library"
106   ;;
107   none)
108     CXXFLAGS=$CXXFLAGS' -DNO_CRYPT'
109     echo "NO_CRYPT_OBJ = 1" >> include.mk
110     echo "disabling crypto"
111   ;;
112 esac
113
114 if [ $PASSPHRASE -eq 0 ]; then
115   CXXFLAGS=$CXXFLAGS' -DNO_PASSPHRASE'
116   echo "disabling master key and salt passphrase"
117 fi
118
119 if [ $ROUTING -eq 0 ]; then
120   CXXFLAGS=$CXXFLAGS' -DNO_ROUTING'
121   echo "disabling built-in routing capability"
122 fi
123
124 cat >> include.mk <<EOF
125 # this file was created automatically
126 # do not edit this file directly 
127 # use ./configure instead
128
129 TARGET = $TARGET
130 CXX = gcc
131 CXXFLAGS = $CXXFLAGS
132 LD = gcc
133 LDFLAGS = $LDFLAGS
134 EOF
135
136 exit 0