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"
32 echo "Usage: ./configure [OPTION]... [VAR=VALUE]..."
34 echo " -h, --help Display this help and exit"
36 echo "Installation directories:"
37 echo " --prefix=PREFIX install architecture-independent files in PREFIX"
39 echo " --sysconfdir=DIR read-only single-machine data [$SYSCONF_DIR]"
41 echo "By default, \`make install' will install all the files in"
42 echo "\`$PREFIX/bin', \`$PREFIX/lib' etc. You can specify"
43 echo "an installation prefix other than \`$PREFIX' using \`--prefix',"
44 echo "for instance \`--prefix=\$HOME'."
46 echo "Optional Features:"
47 echo " --disable-libnl Disable libnl support"
48 echo " --disable-geoip Disable geoip support"
49 echo " --disable-zlib Disable zlib support"
50 echo " --enable-debug Enable debug mode (default disabled)"
52 echo "Some influential environment variables:"
53 echo " CC C compiler command"
54 echo " CROSS_COMPILE C cross-compiler prefix"
59 while [ $# -gt 0 ] ; do
83 echo "[!] Unrecognized option: '$1'. Try './configure --help' for more information"
90 [ -z "$CC" ] && CC
="${CROSS_COMPILE}gcc"
91 [ -z "$LD" ] && LD
="${CROSS_COMPILE}gcc"
92 if [ "x$SYSROOT" != "x" ] ; then
93 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
95 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
97 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
98 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
105 for tool
in $_tools ; do
110 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
112 *) TOOLS
="$TOOLS $tool" ;;
117 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
124 [ "x$(which "$cmd" 2>> config.log)" == "x" ]
129 if [ "x$CROSS_COMPILE" != "x" ] ; then
130 echo "[*] Cross-compiling for $($CC -print-multiarch)"
131 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
134 echo -n "[*] Checking compiler $CC ... "
135 if check_command
$CC ; then
140 echo "CC=$CC" >> Config
143 echo -n "[*] Checking linker $LD ... "
144 if check_command
$LD ; then
149 echo "LD=$LD" >> Config
152 echo -n "[*] Checking $PKG_CONFIG ... "
153 if check_command
$PKG_CONFIG ; then
158 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
159 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
165 echo -n "[*] Checking flex ... "
167 if check_command flex
; then
170 tools_remove
"trafgen"
179 echo -n "[*] Checking bison ... "
181 if check_command bison
; then
184 tools_remove
"trafgen"
193 echo -n "[*] Checking nacl ... "
195 cat > $TMPDIR/nacltest.c
<< EOF
196 #include "crypto_hash_sha512.h"
197 #include "crypto_verify_32.h"
198 #include "crypto_hash_sha512.h"
199 #include "crypto_box_curve25519xsalsa20poly1305.h"
200 #include "crypto_scalarmult_curve25519.h"
201 #include "crypto_auth_hmacsha512256.h"
206 if [ -z $NACL_INC_DIR ] ; then
207 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
210 if [ -z $NACL_LIB_DIR ] ; then
211 NACL_LIB_DIR
="$SYSROOT/usr/lib"
214 if [ -z $NACL_LIB ] ; then
218 LDFLAGS
="-L $NACL_LIB_DIR"
219 CFLAGS
="-I $NACL_INC_DIR"
221 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
222 if [ ! -x $TMPDIR/nacltest
] ; then
225 tools_remove
"curvetun"
228 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
229 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
230 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
236 echo -n "[*] Checking libnl ... "
238 if [ "$DISABLE_LIBNL" == "1" ] ; then
243 cat > $TMPDIR/libnltest.c
<< EOF
244 #include <netlink/genl/genl.h>
245 #include <netlink/genl/family.h>
246 #include <netlink/genl/ctrl.h>
247 #include <netlink/msg.h>
248 #include <netlink/attr.h>
249 #include <netlink/version.h>
251 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
252 # error incompatible libnl version
257 struct nl_sock *sock = nl_socket_alloc();
258 struct nl_cache *nl_cache;
259 int ret = genl_connect(sock);
261 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
266 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
267 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
268 -o $TMPDIR/libnltest \
269 $TMPDIR/libnltest.c \
270 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
271 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
273 if [ ! -x $TMPDIR/libnltest
] ; then
284 echo -n "[*] Checking libnl-route ... "
286 if [ "$DISABLE_LIBNL" == "1" ] ; then
291 if [ "$HAVE_LIBNL" == "0" ] ; then
296 cat > $TMPDIR/libnlroutetest.c
<< EOF
297 #include <netlink/route/link.h>
298 #include <netlink/route/addr.h>
304 rtnl_addr_flags2str(1, str, sizeof(str));
305 rtnl_link_flags2str(1, str, sizeof(str));
306 rtnl_link_operstate2str(1, str, sizeof(str));
313 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
314 -o $TMPDIR/libnlroutetest \
315 $TMPDIR/libnlroutetest.c \
316 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
318 if [ ! -x $TMPDIR/libnlroutetest
] ; then
324 # HAVE_LIBNL already set by check_libnl()
330 echo -n "[*] Checking tpacket_v3 ... "
332 cat > $TMPDIR/tpacketv3test.c
<< EOF
334 #include <linux/if_packet.h>
338 struct tpacket3_hdr *hdr;
343 printf("%d\n", hdr->tp_status);
347 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
348 if [ ! -x $TMPDIR/tpacketv3test
] ; then
359 echo -n "[*] Checking tpacket_v2 ... "
361 cat > $TMPDIR/tpacketv2test.c
<< EOF
363 #include <linux/if_packet.h>
367 struct tpacket2_hdr *hdr;
370 TP_STATUS_SEND_REQUEST,
376 printf("%d\n", hdr->tp_status);
380 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
381 if [ ! -x $TMPDIR/tpacketv2test
] ; then
384 tools_remove
"netsniff-ng"
385 tools_remove
"trafgen"
394 echo -n "[*] Checking ncurses ... "
396 cat > $TMPDIR/ncursestest.c
<< EOF
401 WINDOW *screen = initscr();
406 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
407 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
408 $
($PKG_CONFIG --libs ncurses
2>> config.log \
409 ||
echo '-lncurses' ) \
411 if [ ! -x $TMPDIR/ncursestest
] ; then
414 tools_remove
"flowtop"
423 echo -n "[*] Checking libGeoIP ... "
425 if [ "$DISABLE_GEOIP" == "1" ] ; then
430 cat > $TMPDIR/geoiptest.c
<< EOF
432 #include <GeoIPCity.h>
437 GEOIP_CITY_EDITION_REV1,
438 GEOIP_CITY_EDITION_REV1_V6,
439 GEOIP_COUNTRY_EDITION,
440 GEOIP_COUNTRY_EDITION_V6,
442 GEOIP_ASNUM_EDITION_V6,
444 GeoIP *geoip = GeoIP_new(0);
448 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
449 if [ ! -x $TMPDIR/geoiptest
] ; then
460 echo -n "[*] Checking libnetfilter-conntrack ... "
462 cat > $TMPDIR/nfcttest.c
<< EOF
463 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
464 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
465 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
466 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
470 struct nf_conntrack *ct;
471 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
476 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
477 -o $TMPDIR/nfcttest \
479 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
481 if [ ! -x $TMPDIR/nfcttest
] ; then
484 tools_remove
"flowtop"
492 echo -n "[*] Checking libz ... "
494 if [ "$DISABLE_ZLIB" == "1" ] ; then
499 cat > $TMPDIR/ztest.c
<< EOF
504 gzFile fp = gzopen("foo.gz", "rb");
508 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
509 if [ ! -x $TMPDIR/ztest
] ; then
511 echo "CONFIG_LIBZ=0" >> Config
513 tools_remove
"astraceroute"
514 tools_remove
"flowtop"
517 echo "CONFIG_LIBZ=1" >> Config
524 echo -n "[*] Checking liburcu ... "
526 cat > $TMPDIR/urcutest.c
<< EOF
536 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
537 if [ ! -x $TMPDIR/urcutest
] ; then
540 tools_remove
"flowtop"
548 echo -n "[*] Checking libpcap ... "
550 cat > $TMPDIR/pcaptest.c
<< EOF
555 struct bpf_program bpf;
556 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
560 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
561 if [ ! -x $TMPDIR/pcaptest
] ; then
563 echo "CONFIG_LIBPCAP=0" >> Config
565 tools_remove
"mausezahn"
568 echo "CONFIG_LIBPCAP=1" >> Config
575 echo -n "[*] Checking hw timestamping ... "
577 cat > $TMPDIR/hwtstest.c
<< EOF
579 #include <arpa/inet.h>
580 #include <sys/ioctl.h>
581 #include <sys/types.h>
582 #include <sys/socket.h>
583 #include <linux/sockios.h>
584 #include <linux/net_tstamp.h>
585 #include <linux/if_packet.h>
586 #include <linux/if_ether.h>
587 #include <linux/if.h>
591 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
592 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
593 struct hwtstamp_config hwconfig;
596 memset(&hwconfig, 0, sizeof(hwconfig));
597 hwconfig.tx_type = HWTSTAMP_TX_OFF;
598 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
600 memset(&ifr, 0, sizeof(ifr));
601 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
602 ifr.ifr_data = &hwconfig;
604 ioctl(sock, SIOCSHWTSTAMP, &ifr);
605 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
610 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
611 if [ ! -x $TMPDIR/hwtstest
] ; then
613 echo "CONFIG_HWTSTAMP=0" >> Config
616 echo "CONFIG_HWTSTAMP=1" >> Config
623 echo -n "[*] Checking libcli ... "
625 cat > $TMPDIR/clitest.c
<< EOF
626 #include <sys/time.h>
631 struct cli_def *cli = cli_init();
635 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
636 if [ ! -x $TMPDIR/clitest
] ; then
639 tools_remove
"mausezahn"
647 echo -n "[*] Checking libnet ... "
649 cat > $TMPDIR/nettest.c
<< EOF
654 char err_buf[LIBNET_ERRBUF_SIZE];
655 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
659 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
660 if [ ! -x $TMPDIR/nettest
] ; then
663 tools_remove
"mausezahn"
669 gen_version_appendix
()
673 git rev-parse
> /dev
/null
2>&1
674 if [ "$?" == "0" ] ; then
675 if [ ! "`git describe --always`" == \
676 "`git describe --abbrev=0 --tags`" ] ; then
681 echo "CONFIG_RC=\"$_appendix\"" >> Config
687 local _have_libpcap
=""
688 local _have_libgeoip
=""
694 echo "[*] Generating config.h ..."
696 git rev-parse
> /dev
/null
2>&1
697 if [ "$?" == "0" ] ; then
698 _version
="`git describe --always`"
703 if [ "$HAVE_LIBNL" == "1" ] ; then
704 _have_libnl
="#define HAVE_LIBNL 1"
706 _have_libnl
="/* HAVE_LIBNL is not defined */"
709 if [ "$HAVE_LIBPCAP" == "1" ] ; then
710 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
712 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
715 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
716 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
718 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
721 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
722 _have_libgeoip
="#define HAVE_GEOIP 1"
724 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
727 if [ "$HAVE_LIBZ" == "1" ] ; then
728 _have_libz
="#define HAVE_LIBZ 1"
730 _have_libz
="/* HAVE_LIBZ is not defined */"
733 if [ "$HAVE_TPACKET3" == "1" ] ; then
734 _have_tp3
="#define HAVE_TPACKET3 1"
736 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
739 cat > config.h
<< EOF
742 #define FILE_CLIENTS ".curvetun/clients"
743 #define FILE_SERVERS ".curvetun/servers"
744 #define FILE_PRIVKEY ".curvetun/priv.key"
745 #define FILE_PUBKEY ".curvetun/pub.key"
746 #define FILE_USERNAM ".curvetun/username"
747 #define GITVERSION "$_version"
754 #endif /* CONFIG_H */
760 echo "# This file is autogenerated by the configure script" > Config
763 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
764 echo "[!] One or more of the toolchain tools couldn't be found in your"
765 echo " \$PATH. Please check the file config.log for details."
789 if [ "$MISSING_DEFS" == "1" ] ; then
790 echo "[!] Some libraries or header definitions are missing or too old. Thus"
791 echo " certain tools will not be built (see below) or they will be built"
792 echo " with reduced functionality. Please refer to the INSTALL file for"
793 echo " the libraries needed to build the complete netsniff-ng toolkit"
796 if [ "$MISSING_NACL" == "1" ] ; then
797 echo "[!] The NaCl crypto library is currently not present on your system or"
798 echo " could not be found. Either install it from your distro or build it"
799 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
800 echo " NACL_LIB_DIR environment variables are set appropriately."
803 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
804 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
805 echo "[*] The following tools will be built: $TOOLS"
807 echo "[*] Looks good! All tools will be built!"
810 if [ -s config.log
] ; then
811 echo "[!] There were errors in the configure script. Please check the file"
812 echo " config.log for details."
815 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
817 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
818 echo "CONFIG_GEOIP=1" >> Config
820 echo "CONFIG_GEOIP=0" >> Config
823 echo "CONFIG_PREFIX=$PREFIX" >> Config
824 echo "CONFIG_ETCDIR=$SYSCONF_DIR" >> Config
826 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
827 echo "CONFIG_TOOLS=$TOOLS" >> Config
828 echo "CONFIG_OK=1" >> Config