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"
29 echo "Usage: ./configure [OPTION]... [VAR=VALUE]..."
31 echo " -h, --help Display this help and exit"
33 echo "Optional Features:"
34 echo " --disable-libnl Disable libnl support"
35 echo " --disable-geoip Disable geoip support"
36 echo " --disable-zlib Disable zlib support"
37 echo " --enable-debug Enable debug mode (default disabled)"
39 echo "Some influential environment variables:"
40 echo " CC C compiler command"
41 echo " CROSS_COMPILE C cross-compiler prefix"
46 while [ $# -gt 0 ] ; do
64 echo "[!] Unrecognized option: '$1'. Try './configure --help' for more information"
71 [ -z "$CC" ] && CC
="${CROSS_COMPILE}gcc"
72 [ -z "$LD" ] && LD
="${CROSS_COMPILE}gcc"
73 if [ "x$SYSROOT" != "x" ] ; then
74 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
76 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
78 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
79 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
86 for tool
in $_tools ; do
91 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
93 *) TOOLS
="$TOOLS $tool" ;;
98 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
103 if [ "x$CROSS_COMPILE" != "x" ] ; then
104 echo "[*] Cross-compiling for $($CC -print-multiarch)"
105 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
108 echo -n "[*] Checking compiler $CC ... "
109 if [ "x$(which $CC 2>> config.log)" == "x" ] ; then
114 echo "CC=$CC" >> Config
117 echo -n "[*] Checking linker $LD ... "
118 if [ "x$(which $LD 2>> config.log)" == "x" ] ; then
123 echo "LD=$LD" >> Config
126 echo -n "[*] Checking $PKG_CONFIG ... "
127 if [ "x$(which $PKG_CONFIG 2>> config.log)" == "x" ] ; then
132 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
133 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
139 echo -n "[*] Checking flex ... "
141 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
144 tools_remove
"trafgen"
153 echo -n "[*] Checking bison ... "
155 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
158 tools_remove
"trafgen"
167 echo -n "[*] Checking nacl ... "
169 cat > $TMPDIR/nacltest.c
<< EOF
170 #include "crypto_hash_sha512.h"
171 #include "crypto_verify_32.h"
172 #include "crypto_hash_sha512.h"
173 #include "crypto_box_curve25519xsalsa20poly1305.h"
174 #include "crypto_scalarmult_curve25519.h"
175 #include "crypto_auth_hmacsha512256.h"
180 if [ -z $NACL_INC_DIR ] ; then
181 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
184 if [ -z $NACL_LIB_DIR ] ; then
185 NACL_LIB_DIR
="$SYSROOT/usr/lib"
188 if [ -z $NACL_LIB ] ; then
192 LDFLAGS
="-L $NACL_LIB_DIR"
193 CFLAGS
="-I $NACL_INC_DIR"
195 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
196 if [ ! -x $TMPDIR/nacltest
] ; then
199 tools_remove
"curvetun"
202 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
203 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
204 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
210 echo -n "[*] Checking libnl ... "
212 if [ "$DISABLE_LIBNL" == "1" ] ; then
217 cat > $TMPDIR/libnltest.c
<< EOF
218 #include <netlink/genl/genl.h>
219 #include <netlink/genl/family.h>
220 #include <netlink/genl/ctrl.h>
221 #include <netlink/msg.h>
222 #include <netlink/attr.h>
223 #include <netlink/version.h>
225 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
226 # error incompatible libnl version
231 struct nl_sock *sock = nl_socket_alloc();
232 struct nl_cache *nl_cache;
233 int ret = genl_connect(sock);
235 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
240 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
241 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
242 -o $TMPDIR/libnltest \
243 $TMPDIR/libnltest.c \
244 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
245 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
247 if [ ! -x $TMPDIR/libnltest
] ; then
258 echo -n "[*] Checking libnl-route ... "
260 if [ "$DISABLE_LIBNL" == "1" ] ; then
265 if [ "$HAVE_LIBNL" == "0" ] ; then
270 cat > $TMPDIR/libnlroutetest.c
<< EOF
271 #include <netlink/route/link.h>
272 #include <netlink/route/addr.h>
278 rtnl_addr_flags2str(1, str, sizeof(str));
279 rtnl_link_flags2str(1, str, sizeof(str));
280 rtnl_link_operstate2str(1, str, sizeof(str));
287 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
288 -o $TMPDIR/libnlroutetest \
289 $TMPDIR/libnlroutetest.c \
290 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
292 if [ ! -x $TMPDIR/libnlroutetest
] ; then
298 # HAVE_LIBNL already set by check_libnl()
304 echo -n "[*] Checking tpacket_v3 ... "
306 cat > $TMPDIR/tpacketv3test.c
<< EOF
308 #include <linux/if_packet.h>
312 struct tpacket3_hdr *hdr;
317 printf("%d\n", hdr->tp_status);
321 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
322 if [ ! -x $TMPDIR/tpacketv3test
] ; then
333 echo -n "[*] Checking tpacket_v2 ... "
335 cat > $TMPDIR/tpacketv2test.c
<< EOF
337 #include <linux/if_packet.h>
341 struct tpacket2_hdr *hdr;
344 TP_STATUS_SEND_REQUEST,
350 printf("%d\n", hdr->tp_status);
354 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
355 if [ ! -x $TMPDIR/tpacketv2test
] ; then
358 tools_remove
"netsniff-ng"
359 tools_remove
"trafgen"
368 echo -n "[*] Checking ncurses ... "
370 cat > $TMPDIR/ncursestest.c
<< EOF
375 WINDOW *screen = initscr();
380 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
381 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
382 $
($PKG_CONFIG --libs ncurses
2>> config.log \
383 ||
echo '-lncurses' ) \
385 if [ ! -x $TMPDIR/ncursestest
] ; then
388 tools_remove
"flowtop"
397 echo -n "[*] Checking libGeoIP ... "
399 if [ "$DISABLE_GEOIP" == "1" ] ; then
404 cat > $TMPDIR/geoiptest.c
<< EOF
406 #include <GeoIPCity.h>
411 GEOIP_CITY_EDITION_REV1,
412 GEOIP_CITY_EDITION_REV1_V6,
413 GEOIP_COUNTRY_EDITION,
414 GEOIP_COUNTRY_EDITION_V6,
416 GEOIP_ASNUM_EDITION_V6,
418 GeoIP *geoip = GeoIP_new(0);
422 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
423 if [ ! -x $TMPDIR/geoiptest
] ; then
434 echo -n "[*] Checking libnetfilter-conntrack ... "
436 cat > $TMPDIR/nfcttest.c
<< EOF
437 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
438 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
439 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
440 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
444 struct nf_conntrack *ct;
445 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
450 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
451 -o $TMPDIR/nfcttest \
453 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
455 if [ ! -x $TMPDIR/nfcttest
] ; then
458 tools_remove
"flowtop"
466 echo -n "[*] Checking libz ... "
468 if [ "$DISABLE_ZLIB" == "1" ] ; then
473 cat > $TMPDIR/ztest.c
<< EOF
478 gzFile fp = gzopen("foo.gz", "rb");
482 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
483 if [ ! -x $TMPDIR/ztest
] ; then
485 echo "CONFIG_LIBZ=0" >> Config
487 tools_remove
"astraceroute"
488 tools_remove
"flowtop"
491 echo "CONFIG_LIBZ=1" >> Config
498 echo -n "[*] Checking liburcu ... "
500 cat > $TMPDIR/urcutest.c
<< EOF
510 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
511 if [ ! -x $TMPDIR/urcutest
] ; then
514 tools_remove
"flowtop"
522 echo -n "[*] Checking libpcap ... "
524 cat > $TMPDIR/pcaptest.c
<< EOF
529 struct bpf_program bpf;
530 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
534 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
535 if [ ! -x $TMPDIR/pcaptest
] ; then
537 echo "CONFIG_LIBPCAP=0" >> Config
539 tools_remove
"mausezahn"
542 echo "CONFIG_LIBPCAP=1" >> Config
549 echo -n "[*] Checking hw timestamping ... "
551 cat > $TMPDIR/hwtstest.c
<< EOF
553 #include <arpa/inet.h>
554 #include <sys/ioctl.h>
555 #include <sys/types.h>
556 #include <sys/socket.h>
557 #include <linux/sockios.h>
558 #include <linux/net_tstamp.h>
559 #include <linux/if_packet.h>
560 #include <linux/if_ether.h>
561 #include <linux/if.h>
565 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
566 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
567 struct hwtstamp_config hwconfig;
570 memset(&hwconfig, 0, sizeof(hwconfig));
571 hwconfig.tx_type = HWTSTAMP_TX_OFF;
572 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
574 memset(&ifr, 0, sizeof(ifr));
575 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
576 ifr.ifr_data = &hwconfig;
578 ioctl(sock, SIOCSHWTSTAMP, &ifr);
579 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
584 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
585 if [ ! -x $TMPDIR/hwtstest
] ; then
587 echo "CONFIG_HWTSTAMP=0" >> Config
590 echo "CONFIG_HWTSTAMP=1" >> Config
597 echo -n "[*] Checking libcli ... "
599 cat > $TMPDIR/clitest.c
<< EOF
600 #include <sys/time.h>
605 struct cli_def *cli = cli_init();
609 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
610 if [ ! -x $TMPDIR/clitest
] ; then
613 tools_remove
"mausezahn"
621 echo -n "[*] Checking libnet ... "
623 cat > $TMPDIR/nettest.c
<< EOF
628 char err_buf[LIBNET_ERRBUF_SIZE];
629 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
633 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
634 if [ ! -x $TMPDIR/nettest
] ; then
637 tools_remove
"mausezahn"
643 gen_version_appendix
()
647 git rev-parse
> /dev
/null
2>&1
648 if [ "$?" == "0" ] ; then
649 if [ ! "`git describe --always`" == \
650 "`git describe --abbrev=0 --tags`" ] ; then
655 echo "CONFIG_RC=\"$_appendix\"" >> Config
661 local _have_libpcap
=""
662 local _have_libgeoip
=""
668 echo "[*] Generating config.h ..."
670 git rev-parse
> /dev
/null
2>&1
671 if [ "$?" == "0" ] ; then
672 _version
="`git describe --always`"
677 if [ "$HAVE_LIBNL" == "1" ] ; then
678 _have_libnl
="#define HAVE_LIBNL 1"
680 _have_libnl
="/* HAVE_LIBNL is not defined */"
683 if [ "$HAVE_LIBPCAP" == "1" ] ; then
684 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
686 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
689 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
690 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
692 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
695 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
696 _have_libgeoip
="#define HAVE_GEOIP 1"
698 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
701 if [ "$HAVE_LIBZ" == "1" ] ; then
702 _have_libz
="#define HAVE_LIBZ 1"
704 _have_libz
="/* HAVE_LIBZ is not defined */"
707 if [ "$HAVE_TPACKET3" == "1" ] ; then
708 _have_tp3
="#define HAVE_TPACKET3 1"
710 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
713 cat > config.h
<< EOF
716 #define FILE_CLIENTS ".curvetun/clients"
717 #define FILE_SERVERS ".curvetun/servers"
718 #define FILE_PRIVKEY ".curvetun/priv.key"
719 #define FILE_PUBKEY ".curvetun/pub.key"
720 #define FILE_USERNAM ".curvetun/username"
721 #define GITVERSION "$_version"
728 #endif /* CONFIG_H */
734 echo "# This file is autogenerated by the configure script" > Config
737 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
738 echo "[!] One or more of the toolchain tools couldn't be found in your"
739 echo " \$PATH. Please check the file config.log for details."
763 if [ "$MISSING_DEFS" == "1" ] ; then
764 echo "[!] Some libraries or header definitions are missing or too old. Thus"
765 echo " certain tools will not be built (see below). Please refer to the"
766 echo " INSTALL file for the libraries needed to build the complete"
767 echo " netsniff-ng toolkit."
770 if [ "$MISSING_NACL" == "1" ] ; then
771 echo "[!] The NaCl crypto library is currently not present on your system or"
772 echo " could not be found. Either install it from your distro or build it"
773 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
774 echo " NACL_LIB_DIR environment variables are set appropriately."
777 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
778 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
779 echo "[*] The following tools will be built: $TOOLS"
781 echo "[*] Looks good! All tools will be built!"
784 if [ -s config.log
] ; then
785 echo "[!] There were errors in the configure script. Please check the file"
786 echo " config.log for details."
789 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
791 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
792 echo "CONFIG_GEOIP=1" >> Config
794 echo "CONFIG_GEOIP=0" >> Config
797 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
798 echo "CONFIG_TOOLS=$TOOLS" >> Config
799 echo "CONFIG_OK=1" >> Config