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 \
592 $
($PKG_CONFIG --libs libpcap
2>> config.log
) \
594 if [ ! -x $TMPDIR/pcaptest
] ; then
596 echo "CONFIG_LIBPCAP=0" >> Config
598 tools_remove
"mausezahn"
601 echo "CONFIG_LIBPCAP=1" >> Config
608 echo -n "[*] Checking hw timestamping ... "
610 cat > $TMPDIR/hwtstest.c
<< EOF
612 #include <arpa/inet.h>
613 #include <sys/ioctl.h>
614 #include <sys/types.h>
615 #include <sys/socket.h>
616 #include <linux/sockios.h>
617 #include <linux/net_tstamp.h>
618 #include <linux/if_packet.h>
619 #include <linux/if_ether.h>
620 #include <linux/if.h>
624 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
625 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
626 struct hwtstamp_config hwconfig;
629 memset(&hwconfig, 0, sizeof(hwconfig));
630 hwconfig.tx_type = HWTSTAMP_TX_OFF;
631 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
633 memset(&ifr, 0, sizeof(ifr));
634 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
635 ifr.ifr_data = &hwconfig;
637 ioctl(sock, SIOCSHWTSTAMP, &ifr);
638 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
643 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
644 if [ ! -x $TMPDIR/hwtstest
] ; then
646 echo "CONFIG_HWTSTAMP=0" >> Config
649 echo "CONFIG_HWTSTAMP=1" >> Config
656 echo -n "[*] Checking libcli ... "
658 cat > $TMPDIR/clitest.c
<< EOF
659 #include <sys/time.h>
664 struct cli_def *cli = cli_init();
668 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
669 if [ ! -x $TMPDIR/clitest
] ; then
672 tools_remove
"mausezahn"
680 echo -n "[*] Checking libnet ... "
682 cat > $TMPDIR/nettest.c
<< EOF
687 char err_buf[LIBNET_ERRBUF_SIZE];
688 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
692 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
693 if [ ! -x $TMPDIR/nettest
] ; then
696 tools_remove
"mausezahn"
702 gen_version_appendix
()
706 git rev-parse
> /dev
/null
2>&1
707 if [ "$?" == "0" ] ; then
708 if [ ! "`git describe --always`" == \
709 "`git describe --abbrev=0 --tags`" ] ; then
714 echo "CONFIG_RC=\"$_appendix\"" >> Config
720 local _have_libpcap
=""
721 local _have_libgeoip
=""
727 echo "[*] Generating config.h ..."
729 git rev-parse
> /dev
/null
2>&1
730 if [ "$?" == "0" ] ; then
731 _version
="`git describe --always`"
736 if [ "$HAVE_LIBNL" == "1" ] ; then
737 _have_libnl
="#define HAVE_LIBNL 1"
739 _have_libnl
="/* HAVE_LIBNL is not defined */"
742 if [ "$HAVE_LIBPCAP" == "1" ] ; then
743 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
745 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
748 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
749 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
751 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
754 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
755 _have_libgeoip
="#define HAVE_GEOIP 1"
757 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
760 if [ "$HAVE_LIBZ" == "1" ] ; then
761 _have_libz
="#define HAVE_LIBZ 1"
763 _have_libz
="/* HAVE_LIBZ is not defined */"
766 if [ "$HAVE_TPACKET3" == "1" ] ; then
767 _have_tp3
="#define HAVE_TPACKET3 1"
769 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
772 cat > config.h
<< EOF
775 #define FILE_CLIENTS ".curvetun/clients"
776 #define FILE_SERVERS ".curvetun/servers"
777 #define FILE_PRIVKEY ".curvetun/priv.key"
778 #define FILE_PUBKEY ".curvetun/pub.key"
779 #define FILE_USERNAM ".curvetun/username"
780 #define GITVERSION "$_version"
787 #endif /* CONFIG_H */
793 echo "# This file is autogenerated by the configure script" > Config
796 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
797 echo "[!] One or more of the toolchain tools couldn't be found in your"
798 echo " \$PATH. Please check the file config.log for details."
830 if [ "$MISSING_DEFS" == "1" ] ; then
831 echo "[!] Some libraries or header definitions are missing or too old. Thus"
832 echo " certain tools will not be built (see below) or they will be built"
833 echo " with reduced functionality. Please refer to the INSTALL file for"
834 echo " the libraries needed to build the complete netsniff-ng toolkit"
837 if [ "$MISSING_NACL" == "1" ] ; then
838 echo "[!] The NaCl crypto library is currently not present on your system or"
839 echo " could not be found. Either install it from your distro or build it"
840 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
841 echo " NACL_LIB_DIR environment variables are set appropriately."
844 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
845 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
846 echo "[*] The following tools will be built: $TOOLS"
848 echo "[*] Looks good! All tools will be built!"
851 if [ -s config.log
] ; then
852 echo "[!] There were errors in the configure script. Please check the file"
853 echo " config.log for details."
856 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
858 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
859 echo "CONFIG_GEOIP=1" >> Config
861 echo "CONFIG_GEOIP=0" >> Config
864 echo "CONFIG_PREFIX=$PREFIX" >> Config
865 echo "CONFIG_ETCDIR=$SYSCONF_DIR" >> Config
867 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
868 echo "CONFIG_TOOLS=$TOOLS" >> Config
869 echo "CONFIG_OK=1" >> Config