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/sodium ... "
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
=$
(pkg-config
--variable=includedir libsodium
)
208 if [ -z $NACL_INC_DIR ] ; then
209 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
211 NACL_INC_DIR
="$NACL_INC_DIR/sodium"
216 if [ -z $NACL_LIB_DIR ] ; then
217 NACL_LIB_DIR
="$SYSROOT/usr/lib"
220 if [ -z $NACL_LIB ] ; then
224 LDFLAGS
="-L $NACL_LIB_DIR"
225 CFLAGS
="-I $NACL_INC_DIR"
227 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
228 if [ ! -x $TMPDIR/nacltest
] ; then
231 tools_remove
"curvetun"
234 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
235 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
236 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
242 echo -n "[*] Checking libnl ... "
244 if [ "$DISABLE_LIBNL" == "1" ] ; then
249 cat > $TMPDIR/libnltest.c
<< EOF
250 #include <netlink/genl/genl.h>
251 #include <netlink/genl/family.h>
252 #include <netlink/genl/ctrl.h>
253 #include <netlink/msg.h>
254 #include <netlink/attr.h>
255 #include <netlink/version.h>
257 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
258 # error incompatible libnl version
263 struct nl_sock *sock = nl_socket_alloc();
264 struct nl_cache *nl_cache;
265 int ret = genl_connect(sock);
267 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
272 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
273 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
274 -o $TMPDIR/libnltest \
275 $TMPDIR/libnltest.c \
276 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
277 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
279 if [ ! -x $TMPDIR/libnltest
] ; then
290 echo -n "[*] Checking libnl-route ... "
292 if [ "$DISABLE_LIBNL" == "1" ] ; then
297 if [ "$HAVE_LIBNL" == "0" ] ; then
302 cat > $TMPDIR/libnlroutetest.c
<< EOF
303 #include <netlink/route/link.h>
304 #include <netlink/route/addr.h>
310 rtnl_addr_flags2str(1, str, sizeof(str));
311 rtnl_link_flags2str(1, str, sizeof(str));
312 rtnl_link_operstate2str(1, str, sizeof(str));
319 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
320 -o $TMPDIR/libnlroutetest \
321 $TMPDIR/libnlroutetest.c \
322 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
324 if [ ! -x $TMPDIR/libnlroutetest
] ; then
330 # HAVE_LIBNL already set by check_libnl()
336 echo -n "[*] Checking tpacket_v3 ... "
338 cat > $TMPDIR/tpacketv3test.c
<< EOF
340 #include <linux/if_packet.h>
344 struct tpacket3_hdr *hdr;
349 printf("%d\n", hdr->tp_status);
353 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
354 if [ ! -x $TMPDIR/tpacketv3test
] ; then
365 echo -n "[*] Checking tpacket_v2 ... "
367 cat > $TMPDIR/tpacketv2test.c
<< EOF
369 #include <linux/if_packet.h>
373 struct tpacket2_hdr *hdr;
376 TP_STATUS_SEND_REQUEST,
382 printf("%d\n", hdr->tp_status);
386 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
387 if [ ! -x $TMPDIR/tpacketv2test
] ; then
390 tools_remove
"netsniff-ng"
391 tools_remove
"trafgen"
399 echo -n "[*] Checking fopencookie ... "
401 cat > $TMPDIR/fopencookietest.c
<< EOF
405 static cookie_io_functions_t cookie_fns;
409 FILE *f = fopencookie(NULL, "w", cookie_fns);
413 $CC -o $TMPDIR/fopencookietest
$TMPDIR/fopencookietest.c
>> config.log
2>&1
414 if [ ! -x $TMPDIR/fopencookietest
] ; then
417 tools_remove
"curvetun"
425 echo -n "[*] Checking ncurses ... "
427 cat > $TMPDIR/ncursestest.c
<< EOF
432 WINDOW *screen = initscr();
437 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
438 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
439 $
($PKG_CONFIG --libs ncurses
2>> config.log \
440 ||
echo '-lncurses' ) \
442 if [ ! -x $TMPDIR/ncursestest
] ; then
445 tools_remove
"flowtop"
454 echo -n "[*] Checking libGeoIP ... "
456 if [ "$DISABLE_GEOIP" == "1" ] ; then
461 cat > $TMPDIR/geoiptest.c
<< EOF
463 #include <GeoIPCity.h>
468 GEOIP_CITY_EDITION_REV1,
469 GEOIP_CITY_EDITION_REV1_V6,
470 GEOIP_COUNTRY_EDITION,
471 GEOIP_COUNTRY_EDITION_V6,
473 GEOIP_ASNUM_EDITION_V6,
475 GeoIP *geoip = GeoIP_new(0);
479 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
480 if [ ! -x $TMPDIR/geoiptest
] ; then
491 echo -n "[*] Checking libnetfilter-conntrack ... "
493 cat > $TMPDIR/nfcttest.c
<< EOF
494 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
495 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
496 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
497 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
501 struct nf_conntrack *ct;
502 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
507 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
508 -o $TMPDIR/nfcttest \
510 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
512 if [ ! -x $TMPDIR/nfcttest
] ; then
515 tools_remove
"flowtop"
523 echo -n "[*] Checking libz ... "
525 if [ "$DISABLE_ZLIB" == "1" ] ; then
530 cat > $TMPDIR/ztest.c
<< EOF
535 gzFile fp = gzopen("foo.gz", "rb");
539 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
540 if [ ! -x $TMPDIR/ztest
] ; then
542 echo "CONFIG_LIBZ=0" >> Config
544 tools_remove
"astraceroute"
545 tools_remove
"flowtop"
548 echo "CONFIG_LIBZ=1" >> Config
555 echo -n "[*] Checking liburcu ... "
557 cat > $TMPDIR/urcutest.c
<< EOF
567 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
568 if [ ! -x $TMPDIR/urcutest
] ; then
571 tools_remove
"flowtop"
579 echo -n "[*] Checking libpcap ... "
581 cat > $TMPDIR/pcaptest.c
<< EOF
586 struct bpf_program bpf;
587 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
591 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
592 if [ ! -x $TMPDIR/pcaptest
] ; then
594 echo "CONFIG_LIBPCAP=0" >> Config
596 tools_remove
"mausezahn"
599 echo "CONFIG_LIBPCAP=1" >> Config
606 echo -n "[*] Checking hw timestamping ... "
608 cat > $TMPDIR/hwtstest.c
<< EOF
610 #include <arpa/inet.h>
611 #include <sys/ioctl.h>
612 #include <sys/types.h>
613 #include <sys/socket.h>
614 #include <linux/sockios.h>
615 #include <linux/net_tstamp.h>
616 #include <linux/if_packet.h>
617 #include <linux/if_ether.h>
618 #include <linux/if.h>
622 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
623 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
624 struct hwtstamp_config hwconfig;
627 memset(&hwconfig, 0, sizeof(hwconfig));
628 hwconfig.tx_type = HWTSTAMP_TX_OFF;
629 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
631 memset(&ifr, 0, sizeof(ifr));
632 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
633 ifr.ifr_data = &hwconfig;
635 ioctl(sock, SIOCSHWTSTAMP, &ifr);
636 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
641 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
642 if [ ! -x $TMPDIR/hwtstest
] ; then
644 echo "CONFIG_HWTSTAMP=0" >> Config
647 echo "CONFIG_HWTSTAMP=1" >> Config
654 echo -n "[*] Checking libcli ... "
656 cat > $TMPDIR/clitest.c
<< EOF
657 #include <sys/time.h>
662 struct cli_def *cli = cli_init();
666 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
667 if [ ! -x $TMPDIR/clitest
] ; then
670 tools_remove
"mausezahn"
678 echo -n "[*] Checking libnet ... "
680 cat > $TMPDIR/nettest.c
<< EOF
685 char err_buf[LIBNET_ERRBUF_SIZE];
686 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
690 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
691 if [ ! -x $TMPDIR/nettest
] ; then
694 tools_remove
"mausezahn"
700 gen_version_appendix
()
704 git rev-parse
> /dev
/null
2>&1
705 if [ "$?" == "0" ] ; then
706 if [ ! "`git describe --always`" == \
707 "`git describe --abbrev=0 --tags`" ] ; then
712 echo "CONFIG_RC=\"$_appendix\"" >> Config
718 local _have_libpcap
=""
719 local _have_libgeoip
=""
725 echo "[*] Generating config.h ..."
727 git rev-parse
> /dev
/null
2>&1
728 if [ "$?" == "0" ] ; then
729 _version
="`git describe --always`"
734 if [ "$HAVE_LIBNL" == "1" ] ; then
735 _have_libnl
="#define HAVE_LIBNL 1"
737 _have_libnl
="/* HAVE_LIBNL is not defined */"
740 if [ "$HAVE_LIBPCAP" == "1" ] ; then
741 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
743 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
746 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
747 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
749 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
752 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
753 _have_libgeoip
="#define HAVE_GEOIP 1"
755 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
758 if [ "$HAVE_LIBZ" == "1" ] ; then
759 _have_libz
="#define HAVE_LIBZ 1"
761 _have_libz
="/* HAVE_LIBZ is not defined */"
764 if [ "$HAVE_TPACKET3" == "1" ] ; then
765 _have_tp3
="#define HAVE_TPACKET3 1"
767 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
770 cat > config.h
<< EOF
773 #define FILE_CLIENTS ".curvetun/clients"
774 #define FILE_SERVERS ".curvetun/servers"
775 #define FILE_PRIVKEY ".curvetun/priv.key"
776 #define FILE_PUBKEY ".curvetun/pub.key"
777 #define FILE_USERNAM ".curvetun/username"
778 #define GITVERSION "$_version"
785 #endif /* CONFIG_H */
791 echo "# This file is autogenerated by the configure script" > Config
794 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
795 echo "[!] One or more of the toolchain tools couldn't be found in your"
796 echo " \$PATH. Please check the file config.log for details."
828 if [ "$MISSING_DEFS" == "1" ] ; then
829 echo "[!] Some libraries or header definitions are missing or too old. Thus"
830 echo " certain tools will not be built (see below) or they will be built"
831 echo " with reduced functionality. Please refer to the INSTALL file for"
832 echo " the libraries needed to build the complete netsniff-ng toolkit"
835 if [ "$MISSING_NACL" == "1" ] ; then
836 echo "[!] The NaCl crypto library is currently not present on your system or"
837 echo " could not be found. Either install it from your distro or build it"
838 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
839 echo " NACL_LIB_DIR environment variables are set appropriately."
842 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
843 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
844 echo "[*] The following tools will be built: $TOOLS"
846 echo "[*] Looks good! All tools will be built!"
849 if [ -s config.log
] ; then
850 echo "[!] There were errors in the configure script. Please check the file"
851 echo " config.log for details."
854 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
856 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
857 echo "CONFIG_GEOIP=1" >> Config
859 echo "CONFIG_GEOIP=0" >> Config
862 echo "CONFIG_PREFIX=$PREFIX" >> Config
863 echo "CONFIG_ETCDIR=$SYSCONF_DIR" >> Config
865 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
866 echo "CONFIG_TOOLS=$TOOLS" >> Config
867 echo "CONFIG_OK=1" >> Config