New upstream version 0.3.6
[anytun.git] / src / configure
index f070150..082e523 100755 (executable)
@@ -59,11 +59,16 @@ ROUTING=1
 PREFIX='/usr/local'
 BINDIR=''
 SBINDIR=''
+LIBDIR=''
 ETCDIR=''
 MANDIR=''
 INSTALLMANPAGE=1
 EXAMPLESDIR=''
 INSTALLEXAMPLES=1
+SYSTEMDDIR=''
+SYSTEMDGENERATORDIR=''
+TMPFILESDDIR=''
+INSTALLSYSTEMD=1
 
 BOOST_PREFIX=''
 GCRYPT_PREFIX=''
@@ -71,30 +76,35 @@ NETTLE_PREFIX=''
 OPENSSL_PREFIX=''
 
 print_usage() {
-  echo "configure --help                    print this"
-  echo "          --target=<TARGET>         build target i.e. Linux (default: autodetect)"
-  echo "          --prefix=<PREFIX>         the installation prefix (default: /usr/local)"
-  echo "          --bindir=<DIR>            the path to the bin directory (default: $PREFIX/bin)"
-  echo "          --sbindir=<DIR>           the path to the sbin directory (default: $PREFIX/sbin)"
-  echo "          --sysconfdir=<DIR>        the path to the system configuration directory (default: $PREFIX/etc"
-  echo "          --mandir=<DIR>            the path to the system man pages (default: $PREFIX/share/man)"
-  echo "          --no-manpage              dont't install manpages"
-  echo "          --examplesdir=<DIR>       the path to the examples files (default: $PREFIX/share/examples)"
-  echo "          --no-examples             dont't install example files"
-  echo "          --use-gcrypt              use libgcrypt (this is the default)"
-  echo "          --use-nettle              use libnettle instead of libgcrypt"
-  echo "          --use-ssl-crypto          use openssl crypto library instead of libgcrypt"
-  echo "          --no-crypto               disable crypto at all (only NULL cipher)"
-  echo "          --disable-passphrase      disable master key and salt passphrase"
-  echo "          --enable-passphrase       enable master key and salt passphrase"
-  echo "          --disable-routing         disable built-in routing capability"
-  echo "          --enable-routing          enable built-in routing capability"
-  echo "          --cross-prefix=<PREFIX>   add PREFIX to compiler calls"
-  echo "          --with-boost=<PREFIX>     don't use systemwide boost"
-  echo "          --with-gcrypt=<PREFIX>    don't use systemwide gcrypt"
-  echo "          --with-nettle=<PREFIX>    don't use systemwide nettle"
-  echo "          --with-openssl=<PREFIX>   don't use systemwide openssl"
-  echo "          --use-clang               use clang/llvm as compiler/linker"
+  echo "configure --help                             print this"
+  echo "          --target=<TARGET>                  build target i.e. Linux (default: autodetect)"
+  echo "          --prefix=<PREFIX>                  the installation prefix (default: /usr/local)"
+  echo "          --bindir=<DIR>                     the path to the bin directory (default: $PREFIX/bin)"
+  echo "          --sbindir=<DIR>                    the path to the sbin directory (default: $PREFIX/sbin)"
+  echo "          --libdir=<DIR>                     the path to the lib directory (default: $PREFIX/lib)"
+  echo "          --sysconfdir=<DIR>                 the path to the system configuration directory (default: $PREFIX/etc"
+  echo "          --mandir=<DIR>                     the path to the system man pages (default: $PREFIX/share/man)"
+  echo "          --no-manpage                       don't install manpages"
+  echo "          --examplesdir=<DIR>                the path to the examples files (default: $PREFIX/share/examples)"
+  echo "          --no-examples                      don't install example files"
+  echo "          --systemddir=<DIR>                 the path to the systemd service unit directory (default: from pkg-config)"
+  echo "          --systemdgeneratordir=<DIR>        the path to the systemd generator directory (default: from pkg-config)"
+  echo "          --tmpfilesddir=<DIR>               the path to the systemd tmpfiles.d configuration file (default: from pkg-config)"
+  echo "          --no-systemd                       don't install systemd units"
+  echo "          --use-gcrypt                       use libgcrypt (this is the default)"
+  echo "          --use-nettle                       use libnettle instead of libgcrypt"
+  echo "          --use-ssl-crypto                   use openssl crypto library instead of libgcrypt"
+  echo "          --no-crypto                        disable crypto at all (only NULL cipher)"
+  echo "          --disable-passphrase               disable master key and salt passphrase"
+  echo "          --enable-passphrase                enable master key and salt passphrase"
+  echo "          --disable-routing                  disable built-in routing capability"
+  echo "          --enable-routing                   enable built-in routing capability"
+  echo "          --cross-prefix=<PREFIX>            add PREFIX to compiler calls"
+  echo "          --with-boost=<PREFIX>              don't use systemwide boost"
+  echo "          --with-gcrypt=<PREFIX>             don't use systemwide gcrypt"
+  echo "          --with-nettle=<PREFIX>             don't use systemwide nettle"
+  echo "          --with-openssl=<PREFIX>            don't use systemwide openssl"
+  echo "          --use-clang                        use clang/llvm as compiler/linker"
 }
 
 for arg
@@ -115,6 +125,9 @@ do
   --sbindir=*)
     SBINDIR=${arg#--sbindir=}
   ;;
+  --libdir=*)
+    LIBDIR=${arg#--libdir=}
+  ;;
   --sysconfdir=*)
     ETCDIR=${arg#--sysconfdir=}
   ;;
@@ -130,6 +143,18 @@ do
   --no-examples)
     INSTALLEXAMPLES=0
   ;;
+  --systemddir=*)
+    SYSTEMDDIR=${arg#--systemddir=}
+  ;;
+  --systemdgeneratordir=*)
+    SYSTEMDGENERATORDIR=${arg#--systemdgeneratordir=}
+  ;;
+  --tmpfilesddir=*)
+    TMPFILESDDIR=${arg#--tmpfilesddir=}
+  ;;
+  --no-systemd)
+    INSTALLSYSTEMD=0
+  ;;
   --use-gcrypt)
     CRYPTO_LIB='gcrypt'
   ;;
@@ -192,8 +217,8 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
 fi
 
 if [ $USE_CLANG -eq 0 ]; then
-  CXXFLAGS='-g -Wall -O2'
-  LDFLAGS='-g -Wall -O2'
+  CXXFLAGS='-g -Wall -Werror -Wno-error=unused-variable -O2'
+  LDFLAGS='-g -Wall -Werror -O2'
   COMPILER='g++'
 else
   CXXFLAGS='-g -O2'
@@ -232,6 +257,7 @@ case $TARGET in
     CXXFLAGS=$CXXFLAGS' -I/usr/local/include'
     LDFLAGS=$LDFLAGS' -L/usr/local/lib  -lboost_thread -lboost_serialization -lboost_system -lboost_date_time -lpthread'
     LOG_TARGETS='-DLOG_SYSLOG -DLOG_FILE -DLOG_STDOUT'
+    INSTALLSYSTEMD=0
   ;;
   mingw)
     rm -f tunDevice.cpp
@@ -242,6 +268,7 @@ case $TARGET in
     CXXFLAGS=$CXXFLAGS' -DMINGW -D_WIN32_WINNT=0x0501 -DWIN32_LEAN_AND_MEAN -DBOOST_WINDOWS -fno-strict-aliasing -DBOOST_THREAD_USE_LIB'
     LDFLAGS=$LDFLAGS'  -lboost_thread_win32 -lboost_serialization -lboost_system -lboost_date_time -lwsock32 -lws2_32'
     LOG_TARGETS='-DWIN_EVENTLOG -DLOG_FILE -DLOG_STDOUT'
+    INSTALLSYSTEMD=0
   ;;
   *)
     echo "platform not supported"
@@ -308,6 +335,10 @@ if [ -z "$SBINDIR" ]; then
   SBINDIR=$PREFIX/sbin
 fi
 
+if [ -z "$LIBDIR" ]; then
+  LIBDIR=$PREFIX/lib
+fi
+
 if [ -z "$ETCDIR" ]; then
   ETCDIR=$PREFIX/etc
 fi
@@ -320,6 +351,18 @@ if [ -z "$EXAMPLESDIR" ]; then
   EXAMPLESDIR=$PREFIX/share/examples
 fi
 
+if [ $INSTALLSYSTEMD -eq 1 ]; then
+  if [ -z "$SYSTEMDDIR" ]; then
+    SYSTEMDDIR=`pkg-config systemd --variable=systemdsystemunitdir`
+  fi
+  if [ -z "$SYSTEMDGENERATORDIR" ]; then
+    SYSTEMDGENERATORDIR=`pkg-config systemd --variable=systemdsystemgeneratordir`
+  fi
+  if [ -z "$TMPFILESDDIR" ]; then
+    TMPFILESDDIR=`pkg-config systemd --variable=tmpfilesdir`
+  fi
+fi
+
 cat > include.mk <<EOF
 # this file was created automatically
 # do not edit this file directly
@@ -333,9 +376,10 @@ LDFLAGS = $LDFLAGS
 STRIP = ${CROSS_PREFIX}strip
 INSTALL = install
 
-PREFIX := $PREFIX
+prefix := $PREFIX
 BINDIR := $BINDIR
 SBINDIR := $SBINDIR
+LIBDIR := $LIBDIR
 ETCDIR := $ETCDIR
 EOF
 
@@ -357,12 +401,21 @@ else
   echo "not installing example files"
 fi
 
+if [ $INSTALLSYSTEMD -eq 1 ]; then
+  echo "SYSTEMDDIR := $SYSTEMDDIR" >> include.mk
+  echo "SYSTEMDGENERATORDIR := $SYSTEMDGENERATORDIR" >> include.mk
+  echo "TMPFILESDDIR := $TMPFILESDDIR" >> include.mk
+  echo "installing systemd units"
+else
+  echo "not installing systemd units"
+fi
+
 VERSION=`cat ../version`
-if which svn >/dev/null; then
-  SVN_REV=`svn info 2> /dev/null | grep "^Revision: " | awk '{print($2)}'`
-  if [ -n "$SVN_REV" ]; then
-    VERSION="$VERSION (svn$SVN_REV)"
-  fi
+if which git >/dev/null; then
+    GIT_HASH=`git rev-parse HEAD 2> /dev/null`
+    if [ -n "$GIT_HASH" ]; then
+        VERSION="$VERSION (git $GIT_HASH)"
+    fi
 fi
 HOSTNAME=`hostname`
 DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
@@ -383,7 +436,6 @@ cat > version.h <<EOF
 #define VERSION_STRING_1 "built on $HOSTNAME, $DATE"
 
 #endif
-
 EOF
 
 exit 0