summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile91
-rwxr-xr-xsrc/configure76
2 files changed, 103 insertions, 64 deletions
diff --git a/src/Makefile b/src/Makefile
index bdee4fe..f5eea2c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -32,88 +32,51 @@
## along with ľAnytun. If not, see <http://www.gnu.org/licenses/>.
##
-TARGET=$(shell uname -s)
-CC = gcc
-CCFLAGS = -g -O2 -DANYTUN_02_COMPAT #-DUSE_SSL_CRYPTO #-DNO_CRYPT
-LD = gcc
-LDFLAGS = -g -Wall -O2 -lgcrypt -lgpg-error #-lcrypto
-
-ifeq ($(TARGET),Linux)
- LDFLAGS += -ldl
-endif
-ifeq ($(TARGET),OpenBSD)
- CCFLAGS += -I/usr/local/include -DNO_UDPV6
- LDFLAGS += -L/usr/local/lib
-endif
-
-CRYPT_OBJS = key_derivation.o \
- auth_algo.o
-
-OBJS = log.o \
- signal.o \
- options.o \
- tun.o \
- udp.o \
- plain_packet.o \
- encrypted_packet.o \
- seq_window.o \
- cipher.o \
- uanytun.o
-
-OBJS += $(CRYPT_OBJS)
+include include.mk
+DEPENDFILE = .depend
EXECUTABLE = uanytun
-all: $(EXECUTABLE)
-
-uanytun: $(OBJS)
- $(LD) $(OBJS) -o $@ $(LDFLAGS)
-
-uanytun.o: uanytun.c
- $(CC) $(CCFLAGS) $< -c
-
-log.o: log.c log.h
- $(CC) $(CCFLAGS) $< -c
-
-signal.o: signal.c signal.h
- $(CC) $(CCFLAGS) $< -c
+CRYPT_OBJ = key_derivation.o \
+ auth_algo.o
+OBJ = log.o \
+ signal.o \
+ options.o \
+ tun.o \
+ udp.o \
+ plain_packet.o \
+ encrypted_packet.o \
+ seq_window.o \
+ cipher.o \
+ uanytun.o
-options.o: options.c options.h
- $(CC) $(CCFLAGS) $< -c
+OBJ += $(CRYPT_OBJ)
-tun.o: tun.c tun.h
- $(CC) $(CCFLAGS) $< -c
+SRC = $(OBJ:%.o=%.c)
-udp.o: udp.c udp.h
- $(CC) $(CCFLAGS) $< -c
+.PHONY: dep distclean clean
-plain_packet.o: plain_packet.c plain_packet.h
- $(CC) $(CCFLAGS) $< -c
+all: dep $(EXECUTABLE)
-encrypted_packet.o: encrypted_packet.c encrypted_packet.h
- $(CC) $(CCFLAGS) $< -c
+dep: $(SRC)
+ $(CC) -MM $(SRC) > $(DEPENDFILE)
-seq_window.o: seq_window.c seq_window.h
- $(CC) $(CCFLAGS) $< -c
+-include $(DEPENDFILE)
-key_derivation.o: key_derivation.c key_derivation.h
- $(CC) $(CCFLAGS) $< -c
+uanytun: $(OBJ)
+ $(LD) $(OBJ) -o $@ $(LDFLAGS)
-cipher.o: cipher.c cipher.h
- $(CC) $(CCFLAGS) $< -c
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
-auth_algo.o: auth_algo.c auth_algo.h
- $(CC) $(CCFLAGS) $< -c
distclean: clean
find . -name *.o -exec rm -f {} \;
find . -name "*.\~*" -exec rm -rf {} \;
+ rm -f include.mk
rm -f tun.c
clean:
rm -f *.o
+ rm -f $(DEPENDFILE)
rm -f $(EXECUTABLE)
-
-ctags:
- ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
-
diff --git a/src/configure b/src/configure
index e17d6e3..3246ca0 100755
--- a/src/configure
+++ b/src/configure
@@ -35,16 +35,92 @@
TARGET=`uname -s`
+CFLAGS='-g -O2'
+LDFLAGS='-g -Wall -O2'
+
+CRYPTO_LIB='gcrypt'
+ANYTUN_02_COMPAT=0
+V4_MAPPED=1
+
+for arg
+do
+ case $arg in
+ --use-ssl-crypto)
+ CRYPTO_LIB='ssl'
+ ;;
+ --disable-crypto)
+ CRYPTO_LIB='none'
+ ;;
+ --enable-anytun02-compat)
+ ANYTUN_02_COMPAT=1
+ ;;
+ --disable-v4-mapped)
+ V4_MAPPED=0
+ ;;
+ *)
+ echo "Unknown argument: $arg"
+ exit 1
+ ;;
+ esac
+done
+
+rm -f include.mk
case $TARGET in
Linux)
rm -rf tun.c
ln -sf linux/tun.c
+ echo "loading Linux specific TUN Device"
+ LDFLAGS=$LDFLAGS" -ldl"
;;
OpenBSD|FreeBSD|NetBSD)
rm -rf tun.c
ln -sf bsd/tun.c
+ echo "loading BSD specific TUN Device"
+ CFLAGS=$CFLAGS' -I/usr/local/include'
+ LDFLAGS=$LDFLAGS' -L/usr/local/lib'
+ if [ '$TARGET' == 'OpenBSD' ]; then
+ V4_MAPPED=0
+ fi
;;
*)
echo "Plattform not supported"
+ exit 1;
;;
esac
+
+
+case $CRYPTO_LIB in
+ gcrypt)
+ LDFLAGS=$LDFLAGS' -lgcrypt -lgpg-error'
+ echo "Using libgcrypt library"
+ ;;
+ ssl)
+ CFLAGS=$CFLAGS' -DUSE_SSL_CRYPTO'
+ LDFLAGS=$LDFLAGS' -lcrypto'
+ echo "Using ssl crypto library"
+ ;;
+ none)
+ CFLAGS=$CFLAGS' -DNO_CRYPT'
+ echo "Disabling crypto"
+ ;;
+esac
+
+if [ $ANYTUN_02_COMPAT -eq 1 ]; then
+ CFLAGS=$CFLAGS' -DANYTUN_02_COMPAT'
+ echo "enbabling anytun 0.2 crypto compatiblity mode"
+fi
+
+if [ $V4_MAPPED -eq 0 ]; then
+ CFLAGS=$CFLAGS' -DNO_UDPV6'
+ echo "WARNING: disabling V4 mapped addresses, this prevents uanytun from using IPv6 as outer Protocol"
+fi
+
+cat >> include.mk <<EOF
+TARGET = $TARGET
+CC = gcc
+CFLAGS = $CFLAGS
+LD = gcc
+LDFLAGS = $LDFLAGS
+EOF
+
+exit 0