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# }
125 if [ "x$CROSS_COMPILE" != "x" ] ; then
126 echo "[*] Cross-compiling for $($CC -print-multiarch)"
127 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
130 echo -n "[*] Checking compiler $CC ... "
131 if [ "x$(which $CC 2>> config.log)" == "x" ] ; then
136 echo "CC=$CC" >> Config
139 echo -n "[*] Checking linker $LD ... "
140 if [ "x$(which $LD 2>> config.log)" == "x" ] ; then
145 echo "LD=$LD" >> Config
148 echo -n "[*] Checking $PKG_CONFIG ... "
149 if [ "x$(which $PKG_CONFIG 2>> config.log)" == "x" ] ; then
154 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
155 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
161 echo -n "[*] Checking flex ... "
163 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
166 tools_remove
"trafgen"
175 echo -n "[*] Checking bison ... "
177 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
180 tools_remove
"trafgen"
189 echo -n "[*] Checking nacl ... "
191 cat > $TMPDIR/nacltest.c
<< EOF
192 #include "crypto_hash_sha512.h"
193 #include "crypto_verify_32.h"
194 #include "crypto_hash_sha512.h"
195 #include "crypto_box_curve25519xsalsa20poly1305.h"
196 #include "crypto_scalarmult_curve25519.h"
197 #include "crypto_auth_hmacsha512256.h"
202 if [ -z $NACL_INC_DIR ] ; then
203 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
206 if [ -z $NACL_LIB_DIR ] ; then
207 NACL_LIB_DIR
="$SYSROOT/usr/lib"
210 if [ -z $NACL_LIB ] ; then
214 LDFLAGS
="-L $NACL_LIB_DIR"
215 CFLAGS
="-I $NACL_INC_DIR"
217 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
218 if [ ! -x $TMPDIR/nacltest
] ; then
221 tools_remove
"curvetun"
224 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
225 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
226 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
232 echo -n "[*] Checking libnl ... "
234 if [ "$DISABLE_LIBNL" == "1" ] ; then
239 cat > $TMPDIR/libnltest.c
<< EOF
240 #include <netlink/genl/genl.h>
241 #include <netlink/genl/family.h>
242 #include <netlink/genl/ctrl.h>
243 #include <netlink/msg.h>
244 #include <netlink/attr.h>
245 #include <netlink/version.h>
247 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
248 # error incompatible libnl version
253 struct nl_sock *sock = nl_socket_alloc();
254 struct nl_cache *nl_cache;
255 int ret = genl_connect(sock);
257 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
262 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
263 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
264 -o $TMPDIR/libnltest \
265 $TMPDIR/libnltest.c \
266 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
267 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
269 if [ ! -x $TMPDIR/libnltest
] ; then
280 echo -n "[*] Checking libnl-route ... "
282 if [ "$DISABLE_LIBNL" == "1" ] ; then
287 if [ "$HAVE_LIBNL" == "0" ] ; then
292 cat > $TMPDIR/libnlroutetest.c
<< EOF
293 #include <netlink/route/link.h>
294 #include <netlink/route/addr.h>
300 rtnl_addr_flags2str(1, str, sizeof(str));
301 rtnl_link_flags2str(1, str, sizeof(str));
302 rtnl_link_operstate2str(1, str, sizeof(str));
309 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
310 -o $TMPDIR/libnlroutetest \
311 $TMPDIR/libnlroutetest.c \
312 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
314 if [ ! -x $TMPDIR/libnlroutetest
] ; then
320 # HAVE_LIBNL already set by check_libnl()
326 echo -n "[*] Checking tpacket_v3 ... "
328 cat > $TMPDIR/tpacketv3test.c
<< EOF
330 #include <linux/if_packet.h>
334 struct tpacket3_hdr *hdr;
339 printf("%d\n", hdr->tp_status);
343 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
344 if [ ! -x $TMPDIR/tpacketv3test
] ; then
355 echo -n "[*] Checking tpacket_v2 ... "
357 cat > $TMPDIR/tpacketv2test.c
<< EOF
359 #include <linux/if_packet.h>
363 struct tpacket2_hdr *hdr;
366 TP_STATUS_SEND_REQUEST,
372 printf("%d\n", hdr->tp_status);
376 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
377 if [ ! -x $TMPDIR/tpacketv2test
] ; then
380 tools_remove
"netsniff-ng"
381 tools_remove
"trafgen"
390 echo -n "[*] Checking ncurses ... "
392 cat > $TMPDIR/ncursestest.c
<< EOF
397 WINDOW *screen = initscr();
402 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
403 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
404 $
($PKG_CONFIG --libs ncurses
2>> config.log \
405 ||
echo '-lncurses' ) \
407 if [ ! -x $TMPDIR/ncursestest
] ; then
410 tools_remove
"flowtop"
419 echo -n "[*] Checking libGeoIP ... "
421 if [ "$DISABLE_GEOIP" == "1" ] ; then
426 cat > $TMPDIR/geoiptest.c
<< EOF
428 #include <GeoIPCity.h>
433 GEOIP_CITY_EDITION_REV1,
434 GEOIP_CITY_EDITION_REV1_V6,
435 GEOIP_COUNTRY_EDITION,
436 GEOIP_COUNTRY_EDITION_V6,
438 GEOIP_ASNUM_EDITION_V6,
440 GeoIP *geoip = GeoIP_new(0);
444 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
445 if [ ! -x $TMPDIR/geoiptest
] ; then
456 echo -n "[*] Checking libnetfilter-conntrack ... "
458 cat > $TMPDIR/nfcttest.c
<< EOF
459 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
460 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
461 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
462 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
466 struct nf_conntrack *ct;
467 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
472 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
473 -o $TMPDIR/nfcttest \
475 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
477 if [ ! -x $TMPDIR/nfcttest
] ; then
480 tools_remove
"flowtop"
488 echo -n "[*] Checking libz ... "
490 if [ "$DISABLE_ZLIB" == "1" ] ; then
495 cat > $TMPDIR/ztest.c
<< EOF
500 gzFile fp = gzopen("foo.gz", "rb");
504 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
505 if [ ! -x $TMPDIR/ztest
] ; then
507 echo "CONFIG_LIBZ=0" >> Config
509 tools_remove
"astraceroute"
510 tools_remove
"flowtop"
513 echo "CONFIG_LIBZ=1" >> Config
520 echo -n "[*] Checking liburcu ... "
522 cat > $TMPDIR/urcutest.c
<< EOF
532 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
533 if [ ! -x $TMPDIR/urcutest
] ; then
536 tools_remove
"flowtop"
544 echo -n "[*] Checking libpcap ... "
546 cat > $TMPDIR/pcaptest.c
<< EOF
551 struct bpf_program bpf;
552 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
556 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
557 if [ ! -x $TMPDIR/pcaptest
] ; then
559 echo "CONFIG_LIBPCAP=0" >> Config
561 tools_remove
"mausezahn"
564 echo "CONFIG_LIBPCAP=1" >> Config
571 echo -n "[*] Checking hw timestamping ... "
573 cat > $TMPDIR/hwtstest.c
<< EOF
575 #include <arpa/inet.h>
576 #include <sys/ioctl.h>
577 #include <sys/types.h>
578 #include <sys/socket.h>
579 #include <linux/sockios.h>
580 #include <linux/net_tstamp.h>
581 #include <linux/if_packet.h>
582 #include <linux/if_ether.h>
583 #include <linux/if.h>
587 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
588 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
589 struct hwtstamp_config hwconfig;
592 memset(&hwconfig, 0, sizeof(hwconfig));
593 hwconfig.tx_type = HWTSTAMP_TX_OFF;
594 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
596 memset(&ifr, 0, sizeof(ifr));
597 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
598 ifr.ifr_data = &hwconfig;
600 ioctl(sock, SIOCSHWTSTAMP, &ifr);
601 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
606 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
607 if [ ! -x $TMPDIR/hwtstest
] ; then
609 echo "CONFIG_HWTSTAMP=0" >> Config
612 echo "CONFIG_HWTSTAMP=1" >> Config
619 echo -n "[*] Checking libcli ... "
621 cat > $TMPDIR/clitest.c
<< EOF
622 #include <sys/time.h>
627 struct cli_def *cli = cli_init();
631 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
632 if [ ! -x $TMPDIR/clitest
] ; then
635 tools_remove
"mausezahn"
643 echo -n "[*] Checking libnet ... "
645 cat > $TMPDIR/nettest.c
<< EOF
650 char err_buf[LIBNET_ERRBUF_SIZE];
651 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
655 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
656 if [ ! -x $TMPDIR/nettest
] ; then
659 tools_remove
"mausezahn"
665 gen_version_appendix
()
669 git rev-parse
> /dev
/null
2>&1
670 if [ "$?" == "0" ] ; then
671 if [ ! "`git describe --always`" == \
672 "`git describe --abbrev=0 --tags`" ] ; then
677 echo "CONFIG_RC=\"$_appendix\"" >> Config
683 local _have_libpcap
=""
684 local _have_libgeoip
=""
690 echo "[*] Generating config.h ..."
692 git rev-parse
> /dev
/null
2>&1
693 if [ "$?" == "0" ] ; then
694 _version
="`git describe --always`"
699 if [ "$HAVE_LIBNL" == "1" ] ; then
700 _have_libnl
="#define HAVE_LIBNL 1"
702 _have_libnl
="/* HAVE_LIBNL is not defined */"
705 if [ "$HAVE_LIBPCAP" == "1" ] ; then
706 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
708 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
711 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
712 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
714 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
717 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
718 _have_libgeoip
="#define HAVE_GEOIP 1"
720 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
723 if [ "$HAVE_LIBZ" == "1" ] ; then
724 _have_libz
="#define HAVE_LIBZ 1"
726 _have_libz
="/* HAVE_LIBZ is not defined */"
729 if [ "$HAVE_TPACKET3" == "1" ] ; then
730 _have_tp3
="#define HAVE_TPACKET3 1"
732 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
735 cat > config.h
<< EOF
738 #define FILE_CLIENTS ".curvetun/clients"
739 #define FILE_SERVERS ".curvetun/servers"
740 #define FILE_PRIVKEY ".curvetun/priv.key"
741 #define FILE_PUBKEY ".curvetun/pub.key"
742 #define FILE_USERNAM ".curvetun/username"
743 #define GITVERSION "$_version"
750 #endif /* CONFIG_H */
756 echo "# This file is autogenerated by the configure script" > Config
759 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
760 echo "[!] One or more of the toolchain tools couldn't be found in your"
761 echo " \$PATH. Please check the file config.log for details."
785 if [ "$MISSING_DEFS" == "1" ] ; then
786 echo "[!] Some libraries or header definitions are missing or too old. Thus"
787 echo " certain tools will not be built (see below). Please refer to the"
788 echo " INSTALL file for the libraries needed to build the complete"
789 echo " netsniff-ng toolkit."
792 if [ "$MISSING_NACL" == "1" ] ; then
793 echo "[!] The NaCl crypto library is currently not present on your system or"
794 echo " could not be found. Either install it from your distro or build it"
795 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
796 echo " NACL_LIB_DIR environment variables are set appropriately."
799 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
800 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
801 echo "[*] The following tools will be built: $TOOLS"
803 echo "[*] Looks good! All tools will be built!"
806 if [ -s config.log
] ; then
807 echo "[!] There were errors in the configure script. Please check the file"
808 echo " config.log for details."
811 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
813 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
814 echo "CONFIG_GEOIP=1" >> Config
816 echo "CONFIG_GEOIP=0" >> Config
819 if [ "$HAVE_PREFIX" == "1" ] ; then
820 echo "PREFIX=$PREFIX" >> Config
823 if [ ! -z $SYSCONF_DIR ] ; then
824 echo "ETCDIR=$SYSCONF_DIR" >> Config
827 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
828 echo "CONFIG_TOOLS=$TOOLS" >> Config
829 echo "CONFIG_OK=1" >> Config