summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-06-24 11:29:44 +0200
committerTobias Klauser <tklauser@distanz.ch>2013-06-24 11:29:44 +0200
commitf72460bd5176c0c1a058b6e0e7bd236dfab188c9 (patch)
tree68dc1eedb183390fb650d982e1674817d588e8b6 /configure
parentbb59a298dd26f0d066c7ae755a9748384c952f43 (diff)
configure: Add configure script used to detect NaCl
In order to use an installation of NaCl provided by the distro or by previous manual installation, provide a configure script which checks for nacl's presence. Also check of libnl-genl headers. More checks of the other libraries depended on by netsniff-ng as well as checks for necessary kernel headers should be added here too. The configure script is preliminary and has not yet extensively been tested on multiple systems. The concept was inspired by the configure script of trinity and iproute2. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure98
1 files changed, 98 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 0000000..fd690ed
--- /dev/null
+++ b/configure
@@ -0,0 +1,98 @@
+#!/bin/bash
+# This isn't a configure generated by autoconf!
+
+MISSING_DEFS=0
+MISSING_NACL=0
+
+[ -z $CC ] && CC=cc
+
+TMPDIR=$(mktemp -d config.XXXXXX)
+trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
+
+check_nacl()
+{
+ echo -n "[*] Checking nacl ... "
+
+ cat > $TMPDIR/nacltest.c << EOF
+#include "crypto_hash_sha512.h"
+#include "crypto_verify_32.h"
+#include "crypto_hash_sha512.h"
+#include "crypto_box_curve25519xsalsa20poly1305.h"
+#include "crypto_scalarmult_curve25519.h"
+#include "crypto_auth_hmacsha512256.h"
+
+int main(void) { }
+EOF
+
+ if [ -z $NACL_INC_DIR ] ; then
+ NACL_INC_DIR="/usr/include/nacl"
+ fi
+
+ if [ -z $NACL_LIB_DIR ] ; then
+ NACL_LIB_DIR="/usr/lib"
+ fi
+
+ LDFLAGS="-L $NACL_LIB_DIR"
+ CFLAGS="-I $NACL_INC_DIR"
+
+ $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest $TMPDIR/nacltest.c >> $TMPDIR/config.log 2>&1
+ if [ ! -x $TMPDIR/nacltest ] ; then
+ echo "[NO]"
+ MISSING_NACL=1
+ else
+ echo "[YES]"
+ echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
+ echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
+ fi
+
+}
+
+check_libnl()
+{
+ echo -n "[*] Checking libnl ... "
+
+ cat > $TMPDIR/libnltest.c << EOF
+#include <libnl3/netlink/genl/genl.h>
+#include <libnl3/netlink/genl/family.h>
+#include <libnl3/netlink/genl/ctrl.h>
+#include <libnl3/netlink/msg.h>
+#include <libnl3/netlink/attr.h>
+#include <libnl3/netlink/version.h>
+
+#if LIBNL_VER_NUM < LIBNL_VER(3,0)
+# error incompatible libnl version
+#endif
+
+int main(void) { }
+EOF
+
+ $CC $(pkg-config --cflags libnl-3.0) -o $TMPDIR/libnltest $TMPDIR/libnltest.c >> $TMPDIR/config.log 2>&1
+ if [ ! -x $TMPDIR/libnltest ] ; then
+ echo "[NO]"
+ MISSING_DEFS=1
+ else
+ echo "[YES]"
+ fi
+}
+
+echo "# This file is autogenerated by the configure script" > Config
+check_nacl
+check_libnl
+
+if [ "$MISSING_DEFS" == "1" ] ; then
+ echo "[!] Some libraries or header definitions are missing or too old."
+ echo " Please refer to the INSTALL file for the libraries needed to"
+ echo " build netsniff-ng."
+ exit 1
+fi
+
+if [ "$MISSING_NACL" == "1" ] ; then
+ echo "[!] The NaCl crypto library is currently not present on your"
+ echo " system or could not be found. Either install it from your"
+ echo " distro or build it manually using 'make nacl' and make sure"
+ echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
+ echo " appropriately."
+ exit 1
+fi
+
+exit 0