Index: Makefile
--- Makefile.orig	2008-11-19 21:36:12 +0100
+++ Makefile	2009-11-04 18:44:22 +0100
@@ -21,11 +21,11 @@
 
 DESTDIR=
 PREFIX=/usr/local
-ETCDIR=/etc/vpnc
+ETCDIR=$(PREFIX)/etc/vpnc
 BINDIR=$(PREFIX)/bin
 SBINDIR=$(PREFIX)/sbin
-MANDIR=$(PREFIX)/share/man
-DOCDIR=$(PREFIX)/share/doc/vpnc
+MANDIR=$(PREFIX)/man
+DOCDIR=$(PREFIX)/share/vpnc
 
 SRCS = sysdep.c vpnc-debug.c isakmp-pkt.c tunip.c config.c dh.c math_group.c supp.c decrypt-utils.c
 BINS = vpnc cisco-decrypt
@@ -52,11 +52,10 @@
 
 CC=gcc
 CFLAGS ?= -O3 -g
-CFLAGS += -W -Wall -Wmissing-declarations -Wwrite-strings
-CFLAGS +=  $(shell libgcrypt-config --cflags)
-CPPFLAGS += -DVERSION=\"$(VERSION)\" $(OPENSSL_GPL_VIOLATION)
+override CFLAGS +=  $(shell libgcrypt-config --cflags)
+override CPPFLAGS += -DVERSION=\"$(VERSION)\" $(OPENSSL_GPL_VIOLATION)
 LDFLAGS ?= -g
-LDFLAGS += $(shell libgcrypt-config --libs) $(OPENSSLLIBS)
+override LDFLAGS += $(shell libgcrypt-config --libs) $(OPENSSLLIBS)
 
 ifeq ($(shell uname -s), SunOS)
 LDFLAGS += -lnsl -lresolv -lsocket
@@ -69,7 +68,7 @@
 all : $(BINS) vpnc.8 vpnc-script
 
 vpnc : $(OBJS) vpnc.o
-	$(CC) -o $@ $^ $(LDFLAGS)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
 vpnc.8 : vpnc.8.template makeman.pl vpnc
 	./makeman.pl
@@ -78,7 +77,7 @@
 	sed -e 's,@''PREFIX''@,$(PREFIX),g' $< > $@ && chmod 755 $@
 
 cisco-decrypt : cisco-decrypt.o decrypt-utils.o
-	$(CC) -o $@ $^ $(LDFLAGS)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
 .depend: $(SRCS) $(BINSRCS)
 	$(CC) -MM $(SRCS) $(BINSRCS) $(CFLAGS) $(CPPFLAGS) > $@
Index: sysdep.h
--- sysdep.h.orig	2008-11-19 21:36:12 +0100
+++ sysdep.h	2009-11-04 18:44:22 +0100
@@ -86,6 +86,10 @@
 #define HAVE_FGETLN    1
 #define HAVE_UNSETENV  1
 #define HAVE_SETENV    1
+#include <sys/param.h>
+#if __FreeBSD_version >= 800067
+#define HAVE_GETLINE   1
+#endif
 #endif
 
 /***************************************************************************/
Index: vpnc-script.in
--- vpnc-script.in.orig	2008-11-19 21:55:51 +0100
+++ vpnc-script.in	2009-11-04 18:44:22 +0100
@@ -420,11 +420,13 @@
 			fi
 		fi
 	elif [ "$OS" = "FreeBSD" ]; then
-		if [ ! -e /dev/tun ]; then
+		kldstat -q -m if_tun
+		if [ ${?} != 0 ]; then
 			kldload if_tun
 		fi
 	elif [ "$OS" = "GNU/kFreeBSD" ]; then
-		if [ ! -e /dev/tun ]; then
+		kldstat -q -m if_tun
+		if [ ${?} != 0 ]; then
 			kldload if_tun
 		fi
 	elif [ "$OS" = "NetBSD" ]; then
