2 # This isn't a configure generated by autoconf!
3 # netsniff-ng build system
4 # Copyright 2013-2016 Tobias Klauser <tklauser@distanz.ch>
5 # Copyright 2013 Daniel Borkmann <borkmann@gnumaniacs.org>
6 # Subject to the GNU GPL, version 2.
12 TOOLS
="netsniff-ng trafgen astraceroute flowtop ifpps bpfc curvetun mausezahn"
34 echo "Usage: ./configure [OPTION]... [VAR=VALUE]..."
36 echo " -h, --help Display this help and exit"
38 echo "Installation directories:"
39 echo " --prefix=PREFIX install architecture-independent files in PREFIX"
41 echo " --sysconfdir=DIR read-only single-machine data [PREFIX/etc]"
43 echo "By default, \`make install' will install all the files in"
44 echo "\`$PREFIX/bin', \`$PREFIX/lib' etc. You can specify"
45 echo "an installation prefix other than \`$PREFIX' using \`--prefix',"
46 echo "for instance \`--prefix=\$HOME'."
48 echo "Optional Features:"
49 echo " --disable-libnl Disable libnl support"
50 echo " --disable-geoip Disable geoip support"
51 echo " --disable-zlib Disable zlib support"
52 echo " --enable-debug Enable debug mode (default disabled)"
54 echo "Some influential environment variables:"
55 echo " CC C compiler command"
56 echo " CROSS_COMPILE C cross-compiler prefix"
61 while [ $# -gt 0 ] ; do
86 echo "[!] Unrecognized option: '$1'. Try './configure --help' for more information"
93 [ -z "$CC" ] && CC
="${CROSS_COMPILE}gcc"
94 [ -z "$LD" ] && LD
="${CROSS_COMPILE}gcc"
95 if [ "x$SYSROOT" != "x" ] ; then
96 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
98 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
100 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
101 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
108 for tool
in $_tools ; do
113 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
115 *) TOOLS
="$TOOLS $tool" ;;
120 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
127 [ "x$(which "$cmd" 2>> config.log)" == "x" ]
132 if [ "x$CROSS_COMPILE" != "x" ] ; then
133 echo "[*] Cross-compiling for $($CC -print-multiarch)"
134 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
137 echo -n "[*] Checking compiler $CC ... "
138 if check_command
$CC ; then
143 echo "CC=$CC" >> Config
146 echo -n "[*] Checking linker $LD ... "
147 if check_command
$LD ; then
152 echo "LD=$LD" >> Config
155 echo -n "[*] Checking $PKG_CONFIG ... "
156 if check_command
$PKG_CONFIG ; then
161 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
162 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
168 echo -n "[*] Checking flex ... "
170 if check_command flex
; then
173 tools_remove
"trafgen"
182 echo -n "[*] Checking bison ... "
184 if check_command bison
; then
187 tools_remove
"trafgen"
196 echo -n "[*] Checking nacl ... "
198 cat > $TMPDIR/nacltest.c
<< EOF
199 #include "crypto_hash_sha512.h"
200 #include "crypto_verify_32.h"
201 #include "crypto_hash_sha512.h"
202 #include "crypto_box_curve25519xsalsa20poly1305.h"
203 #include "crypto_scalarmult_curve25519.h"
204 #include "crypto_auth_hmacsha512256.h"
209 if [ -z $NACL_INC_DIR ] ; then
210 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
213 if [ -z $NACL_LIB_DIR ] ; then
214 NACL_LIB_DIR
="$SYSROOT/usr/lib"
217 if [ -z $NACL_LIB ] ; then
221 LDFLAGS
="-L $NACL_LIB_DIR"
222 CFLAGS
="-I $NACL_INC_DIR"
224 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
225 if [ ! -x $TMPDIR/nacltest
] ; then
228 tools_remove
"curvetun"
231 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
232 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
233 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
239 echo -n "[*] Checking libnl ... "
241 if [ "$DISABLE_LIBNL" == "1" ] ; then
246 cat > $TMPDIR/libnltest.c
<< EOF
247 #include <netlink/genl/genl.h>
248 #include <netlink/genl/family.h>
249 #include <netlink/genl/ctrl.h>
250 #include <netlink/msg.h>
251 #include <netlink/attr.h>
252 #include <netlink/version.h>
254 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
255 # error incompatible libnl version
260 struct nl_sock *sock = nl_socket_alloc();
261 struct nl_cache *nl_cache;
262 int ret = genl_connect(sock);
264 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
269 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
270 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
271 -o $TMPDIR/libnltest \
272 $TMPDIR/libnltest.c \
273 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
274 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
276 if [ ! -x $TMPDIR/libnltest
] ; then
287 echo -n "[*] Checking libnl-route ... "
289 if [ "$DISABLE_LIBNL" == "1" ] ; then
294 if [ "$HAVE_LIBNL" == "0" ] ; then
299 cat > $TMPDIR/libnlroutetest.c
<< EOF
300 #include <netlink/route/link.h>
301 #include <netlink/route/addr.h>
307 rtnl_addr_flags2str(1, str, sizeof(str));
308 rtnl_link_flags2str(1, str, sizeof(str));
309 rtnl_link_operstate2str(1, str, sizeof(str));
316 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
317 -o $TMPDIR/libnlroutetest \
318 $TMPDIR/libnlroutetest.c \
319 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
321 if [ ! -x $TMPDIR/libnlroutetest
] ; then
327 # HAVE_LIBNL already set by check_libnl()
333 echo -n "[*] Checking tpacket_v3 ... "
335 cat > $TMPDIR/tpacketv3test.c
<< EOF
337 #include <linux/if_packet.h>
341 struct tpacket3_hdr *hdr;
346 printf("%d\n", hdr->tp_status);
350 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
351 if [ ! -x $TMPDIR/tpacketv3test
] ; then
362 echo -n "[*] Checking tpacket_v2 ... "
364 cat > $TMPDIR/tpacketv2test.c
<< EOF
366 #include <linux/if_packet.h>
370 struct tpacket2_hdr *hdr;
373 TP_STATUS_SEND_REQUEST,
379 printf("%d\n", hdr->tp_status);
383 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
384 if [ ! -x $TMPDIR/tpacketv2test
] ; then
387 tools_remove
"netsniff-ng"
388 tools_remove
"trafgen"
397 echo -n "[*] Checking ncurses ... "
399 cat > $TMPDIR/ncursestest.c
<< EOF
404 WINDOW *screen = initscr();
409 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
410 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
411 $
($PKG_CONFIG --libs ncurses
2>> config.log \
412 ||
echo '-lncurses' ) \
414 if [ ! -x $TMPDIR/ncursestest
] ; then
417 tools_remove
"flowtop"
426 echo -n "[*] Checking libGeoIP ... "
428 if [ "$DISABLE_GEOIP" == "1" ] ; then
433 cat > $TMPDIR/geoiptest.c
<< EOF
435 #include <GeoIPCity.h>
440 GEOIP_CITY_EDITION_REV1,
441 GEOIP_CITY_EDITION_REV1_V6,
442 GEOIP_COUNTRY_EDITION,
443 GEOIP_COUNTRY_EDITION_V6,
445 GEOIP_ASNUM_EDITION_V6,
447 GeoIP *geoip = GeoIP_new(0);
451 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
452 if [ ! -x $TMPDIR/geoiptest
] ; then
463 echo -n "[*] Checking libnetfilter-conntrack ... "
465 cat > $TMPDIR/nfcttest.c
<< EOF
466 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
467 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
468 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
469 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
473 struct nf_conntrack *ct;
474 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
479 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
480 -o $TMPDIR/nfcttest \
482 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
484 if [ ! -x $TMPDIR/nfcttest
] ; then
487 tools_remove
"flowtop"
495 echo -n "[*] Checking libz ... "
497 if [ "$DISABLE_ZLIB" == "1" ] ; then
502 cat > $TMPDIR/ztest.c
<< EOF
507 gzFile fp = gzopen("foo.gz", "rb");
511 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
512 if [ ! -x $TMPDIR/ztest
] ; then
514 echo "CONFIG_LIBZ=0" >> Config
516 tools_remove
"astraceroute"
517 tools_remove
"flowtop"
520 echo "CONFIG_LIBZ=1" >> Config
527 echo -n "[*] Checking liburcu ... "
529 cat > $TMPDIR/urcutest.c
<< EOF
539 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
540 if [ ! -x $TMPDIR/urcutest
] ; then
543 tools_remove
"flowtop"
551 echo -n "[*] Checking libpcap ... "
553 cat > $TMPDIR/pcaptest.c
<< EOF
558 struct bpf_program bpf;
559 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
563 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
564 if [ ! -x $TMPDIR/pcaptest
] ; then
566 echo "CONFIG_LIBPCAP=0" >> Config
568 tools_remove
"mausezahn"
571 echo "CONFIG_LIBPCAP=1" >> Config
578 echo -n "[*] Checking hw timestamping ... "
580 cat > $TMPDIR/hwtstest.c
<< EOF
582 #include <arpa/inet.h>
583 #include <sys/ioctl.h>
584 #include <sys/types.h>
585 #include <sys/socket.h>
586 #include <linux/sockios.h>
587 #include <linux/net_tstamp.h>
588 #include <linux/if_packet.h>
589 #include <linux/if_ether.h>
590 #include <linux/if.h>
594 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
595 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
596 struct hwtstamp_config hwconfig;
599 memset(&hwconfig, 0, sizeof(hwconfig));
600 hwconfig.tx_type = HWTSTAMP_TX_OFF;
601 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
603 memset(&ifr, 0, sizeof(ifr));
604 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
605 ifr.ifr_data = &hwconfig;
607 ioctl(sock, SIOCSHWTSTAMP, &ifr);
608 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
613 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
614 if [ ! -x $TMPDIR/hwtstest
] ; then
616 echo "CONFIG_HWTSTAMP=0" >> Config
619 echo "CONFIG_HWTSTAMP=1" >> Config
626 echo -n "[*] Checking libcli ... "
628 cat > $TMPDIR/clitest.c
<< EOF
629 #include <sys/time.h>
634 struct cli_def *cli = cli_init();
638 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
639 if [ ! -x $TMPDIR/clitest
] ; then
642 tools_remove
"mausezahn"
650 echo -n "[*] Checking libnet ... "
652 cat > $TMPDIR/nettest.c
<< EOF
657 char err_buf[LIBNET_ERRBUF_SIZE];
658 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
662 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
663 if [ ! -x $TMPDIR/nettest
] ; then
666 tools_remove
"mausezahn"
672 gen_version_appendix
()
676 git rev-parse
> /dev
/null
2>&1
677 if [ "$?" == "0" ] ; then
678 if [ ! "`git describe --always`" == \
679 "`git describe --abbrev=0 --tags`" ] ; then
684 echo "CONFIG_RC=\"$_appendix\"" >> Config
690 local _have_libpcap
=""
691 local _have_libgeoip
=""
697 echo "[*] Generating config.h ..."
699 git rev-parse
> /dev
/null
2>&1
700 if [ "$?" == "0" ] ; then
701 _version
="`git describe --always`"
706 if [ "$HAVE_LIBNL" == "1" ] ; then
707 _have_libnl
="#define HAVE_LIBNL 1"
709 _have_libnl
="/* HAVE_LIBNL is not defined */"
712 if [ "$HAVE_LIBPCAP" == "1" ] ; then
713 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
715 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
718 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
719 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
721 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
724 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
725 _have_libgeoip
="#define HAVE_GEOIP 1"
727 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
730 if [ "$HAVE_LIBZ" == "1" ] ; then
731 _have_libz
="#define HAVE_LIBZ 1"
733 _have_libz
="/* HAVE_LIBZ is not defined */"
736 if [ "$HAVE_TPACKET3" == "1" ] ; then
737 _have_tp3
="#define HAVE_TPACKET3 1"
739 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
742 cat > config.h
<< EOF
745 #define FILE_CLIENTS ".curvetun/clients"
746 #define FILE_SERVERS ".curvetun/servers"
747 #define FILE_PRIVKEY ".curvetun/priv.key"
748 #define FILE_PUBKEY ".curvetun/pub.key"
749 #define FILE_USERNAM ".curvetun/username"
750 #define GITVERSION "$_version"
757 #endif /* CONFIG_H */
763 echo "# This file is autogenerated by the configure script" > Config
766 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
767 echo "[!] One or more of the toolchain tools couldn't be found in your"
768 echo " \$PATH. Please check the file config.log for details."
792 if [ "$MISSING_DEFS" == "1" ] ; then
793 echo "[!] Some libraries or header definitions are missing or too old. Thus"
794 echo " certain tools will not be built (see below). Please refer to the"
795 echo " INSTALL file for the libraries needed to build the complete"
796 echo " netsniff-ng toolkit."
799 if [ "$MISSING_NACL" == "1" ] ; then
800 echo "[!] The NaCl crypto library is currently not present on your system or"
801 echo " could not be found. Either install it from your distro or build it"
802 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
803 echo " NACL_LIB_DIR environment variables are set appropriately."
806 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
807 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
808 echo "[*] The following tools will be built: $TOOLS"
810 echo "[*] Looks good! All tools will be built!"
813 if [ -s config.log
] ; then
814 echo "[!] There were errors in the configure script. Please check the file"
815 echo " config.log for details."
818 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
820 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
821 echo "CONFIG_GEOIP=1" >> Config
823 echo "CONFIG_GEOIP=0" >> Config
826 if [ "$HAVE_PREFIX" == "1" ] ; then
827 echo "PREFIX=$PREFIX" >> Config
830 if [ ! -z $SYSCONF_DIR ] ; then
831 echo "ETCDIR=$SYSCONF_DIR" >> Config
834 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
835 echo "CONFIG_TOOLS=$TOOLS" >> Config
836 echo "CONFIG_OK=1" >> Config