configure: Add configure script used to detect NaCl
[netsniff-ng.git] / configure
blobfd690ed1c508f9d98b976d53ab93ad5a48f709c4
1 #!/bin/bash
2 # This isn't a configure generated by autoconf!
4 MISSING_DEFS=0
5 MISSING_NACL=0
7 [ -z $CC ] && CC=cc
9 TMPDIR=$(mktemp -d config.XXXXXX)
10 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
12 check_nacl()
14 echo -n "[*] Checking nacl ... "
16 cat > $TMPDIR/nacltest.c << EOF
17 #include "crypto_hash_sha512.h"
18 #include "crypto_verify_32.h"
19 #include "crypto_hash_sha512.h"
20 #include "crypto_box_curve25519xsalsa20poly1305.h"
21 #include "crypto_scalarmult_curve25519.h"
22 #include "crypto_auth_hmacsha512256.h"
24 int main(void) { }
25 EOF
27 if [ -z $NACL_INC_DIR ] ; then
28 NACL_INC_DIR="/usr/include/nacl"
31 if [ -z $NACL_LIB_DIR ] ; then
32 NACL_LIB_DIR="/usr/lib"
35 LDFLAGS="-L $NACL_LIB_DIR"
36 CFLAGS="-I $NACL_INC_DIR"
38 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest $TMPDIR/nacltest.c >> $TMPDIR/config.log 2>&1
39 if [ ! -x $TMPDIR/nacltest ] ; then
40 echo "[NO]"
41 MISSING_NACL=1
42 else
43 echo "[YES]"
44 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
45 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
50 check_libnl()
52 echo -n "[*] Checking libnl ... "
54 cat > $TMPDIR/libnltest.c << EOF
55 #include <libnl3/netlink/genl/genl.h>
56 #include <libnl3/netlink/genl/family.h>
57 #include <libnl3/netlink/genl/ctrl.h>
58 #include <libnl3/netlink/msg.h>
59 #include <libnl3/netlink/attr.h>
60 #include <libnl3/netlink/version.h>
62 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
63 # error incompatible libnl version
64 #endif
66 int main(void) { }
67 EOF
69 $CC $(pkg-config --cflags libnl-3.0) -o $TMPDIR/libnltest $TMPDIR/libnltest.c >> $TMPDIR/config.log 2>&1
70 if [ ! -x $TMPDIR/libnltest ] ; then
71 echo "[NO]"
72 MISSING_DEFS=1
73 else
74 echo "[YES]"
78 echo "# This file is autogenerated by the configure script" > Config
79 check_nacl
80 check_libnl
82 if [ "$MISSING_DEFS" == "1" ] ; then
83 echo "[!] Some libraries or header definitions are missing or too old."
84 echo " Please refer to the INSTALL file for the libraries needed to"
85 echo " build netsniff-ng."
86 exit 1
89 if [ "$MISSING_NACL" == "1" ] ; then
90 echo "[!] The NaCl crypto library is currently not present on your"
91 echo " system or could not be found. Either install it from your"
92 echo " distro or build it manually using 'make nacl' and make sure"
93 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
94 echo " appropriately."
95 exit 1
98 exit 0