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"
40 echo "By default, \`make install' will install all the files in"
41 echo "\`$PREFIX/bin', \`$PREFIX/lib' etc. You can specify"
42 echo "an installation prefix other than \`$PREFIX' using \`--prefix',"
43 echo "for instance \`--prefix=\$HOME'."
45 echo "Optional Features:"
46 echo " --disable-libnl Disable libnl support"
47 echo " --disable-geoip Disable geoip support"
48 echo " --disable-zlib Disable zlib support"
49 echo " --enable-debug Enable debug mode (default disabled)"
51 echo "Some influential environment variables:"
52 echo " CC C compiler command"
53 echo " CROSS_COMPILE C cross-compiler prefix"
58 while [ $# -gt 0 ] ; do
80 echo "[!] Unrecognized option: '$1'. Try './configure --help' for more information"
87 [ -z "$CC" ] && CC
="${CROSS_COMPILE}gcc"
88 [ -z "$LD" ] && LD
="${CROSS_COMPILE}gcc"
89 if [ "x$SYSROOT" != "x" ] ; then
90 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
92 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
94 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
95 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
102 for tool
in $_tools ; do
107 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
109 *) TOOLS
="$TOOLS $tool" ;;
114 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
119 if [ "x$CROSS_COMPILE" != "x" ] ; then
120 echo "[*] Cross-compiling for $($CC -print-multiarch)"
121 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
124 echo -n "[*] Checking compiler $CC ... "
125 if [ "x$(which $CC 2>> config.log)" == "x" ] ; then
130 echo "CC=$CC" >> Config
133 echo -n "[*] Checking linker $LD ... "
134 if [ "x$(which $LD 2>> config.log)" == "x" ] ; then
139 echo "LD=$LD" >> Config
142 echo -n "[*] Checking $PKG_CONFIG ... "
143 if [ "x$(which $PKG_CONFIG 2>> config.log)" == "x" ] ; then
148 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
149 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
155 echo -n "[*] Checking flex ... "
157 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
160 tools_remove
"trafgen"
169 echo -n "[*] Checking bison ... "
171 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
174 tools_remove
"trafgen"
183 echo -n "[*] Checking nacl ... "
185 cat > $TMPDIR/nacltest.c
<< EOF
186 #include "crypto_hash_sha512.h"
187 #include "crypto_verify_32.h"
188 #include "crypto_hash_sha512.h"
189 #include "crypto_box_curve25519xsalsa20poly1305.h"
190 #include "crypto_scalarmult_curve25519.h"
191 #include "crypto_auth_hmacsha512256.h"
196 if [ -z $NACL_INC_DIR ] ; then
197 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
200 if [ -z $NACL_LIB_DIR ] ; then
201 NACL_LIB_DIR
="$SYSROOT/usr/lib"
204 if [ -z $NACL_LIB ] ; then
208 LDFLAGS
="-L $NACL_LIB_DIR"
209 CFLAGS
="-I $NACL_INC_DIR"
211 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
212 if [ ! -x $TMPDIR/nacltest
] ; then
215 tools_remove
"curvetun"
218 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
219 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
220 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
226 echo -n "[*] Checking libnl ... "
228 if [ "$DISABLE_LIBNL" == "1" ] ; then
233 cat > $TMPDIR/libnltest.c
<< EOF
234 #include <netlink/genl/genl.h>
235 #include <netlink/genl/family.h>
236 #include <netlink/genl/ctrl.h>
237 #include <netlink/msg.h>
238 #include <netlink/attr.h>
239 #include <netlink/version.h>
241 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
242 # error incompatible libnl version
247 struct nl_sock *sock = nl_socket_alloc();
248 struct nl_cache *nl_cache;
249 int ret = genl_connect(sock);
251 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
256 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
257 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
258 -o $TMPDIR/libnltest \
259 $TMPDIR/libnltest.c \
260 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
261 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
263 if [ ! -x $TMPDIR/libnltest
] ; then
274 echo -n "[*] Checking libnl-route ... "
276 if [ "$DISABLE_LIBNL" == "1" ] ; then
281 if [ "$HAVE_LIBNL" == "0" ] ; then
286 cat > $TMPDIR/libnlroutetest.c
<< EOF
287 #include <netlink/route/link.h>
288 #include <netlink/route/addr.h>
294 rtnl_addr_flags2str(1, str, sizeof(str));
295 rtnl_link_flags2str(1, str, sizeof(str));
296 rtnl_link_operstate2str(1, str, sizeof(str));
303 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
304 -o $TMPDIR/libnlroutetest \
305 $TMPDIR/libnlroutetest.c \
306 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
308 if [ ! -x $TMPDIR/libnlroutetest
] ; then
314 # HAVE_LIBNL already set by check_libnl()
320 echo -n "[*] Checking tpacket_v3 ... "
322 cat > $TMPDIR/tpacketv3test.c
<< EOF
324 #include <linux/if_packet.h>
328 struct tpacket3_hdr *hdr;
333 printf("%d\n", hdr->tp_status);
337 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
338 if [ ! -x $TMPDIR/tpacketv3test
] ; then
349 echo -n "[*] Checking tpacket_v2 ... "
351 cat > $TMPDIR/tpacketv2test.c
<< EOF
353 #include <linux/if_packet.h>
357 struct tpacket2_hdr *hdr;
360 TP_STATUS_SEND_REQUEST,
366 printf("%d\n", hdr->tp_status);
370 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
371 if [ ! -x $TMPDIR/tpacketv2test
] ; then
374 tools_remove
"netsniff-ng"
375 tools_remove
"trafgen"
384 echo -n "[*] Checking ncurses ... "
386 cat > $TMPDIR/ncursestest.c
<< EOF
391 WINDOW *screen = initscr();
396 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
397 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
398 $
($PKG_CONFIG --libs ncurses
2>> config.log \
399 ||
echo '-lncurses' ) \
401 if [ ! -x $TMPDIR/ncursestest
] ; then
404 tools_remove
"flowtop"
413 echo -n "[*] Checking libGeoIP ... "
415 if [ "$DISABLE_GEOIP" == "1" ] ; then
420 cat > $TMPDIR/geoiptest.c
<< EOF
422 #include <GeoIPCity.h>
427 GEOIP_CITY_EDITION_REV1,
428 GEOIP_CITY_EDITION_REV1_V6,
429 GEOIP_COUNTRY_EDITION,
430 GEOIP_COUNTRY_EDITION_V6,
432 GEOIP_ASNUM_EDITION_V6,
434 GeoIP *geoip = GeoIP_new(0);
438 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
439 if [ ! -x $TMPDIR/geoiptest
] ; then
450 echo -n "[*] Checking libnetfilter-conntrack ... "
452 cat > $TMPDIR/nfcttest.c
<< EOF
453 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
454 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
455 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
456 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
460 struct nf_conntrack *ct;
461 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
466 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
467 -o $TMPDIR/nfcttest \
469 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
471 if [ ! -x $TMPDIR/nfcttest
] ; then
474 tools_remove
"flowtop"
482 echo -n "[*] Checking libz ... "
484 if [ "$DISABLE_ZLIB" == "1" ] ; then
489 cat > $TMPDIR/ztest.c
<< EOF
494 gzFile fp = gzopen("foo.gz", "rb");
498 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
499 if [ ! -x $TMPDIR/ztest
] ; then
501 echo "CONFIG_LIBZ=0" >> Config
503 tools_remove
"astraceroute"
504 tools_remove
"flowtop"
507 echo "CONFIG_LIBZ=1" >> Config
514 echo -n "[*] Checking liburcu ... "
516 cat > $TMPDIR/urcutest.c
<< EOF
526 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
527 if [ ! -x $TMPDIR/urcutest
] ; then
530 tools_remove
"flowtop"
538 echo -n "[*] Checking libpcap ... "
540 cat > $TMPDIR/pcaptest.c
<< EOF
545 struct bpf_program bpf;
546 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
550 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
551 if [ ! -x $TMPDIR/pcaptest
] ; then
553 echo "CONFIG_LIBPCAP=0" >> Config
555 tools_remove
"mausezahn"
558 echo "CONFIG_LIBPCAP=1" >> Config
565 echo -n "[*] Checking hw timestamping ... "
567 cat > $TMPDIR/hwtstest.c
<< EOF
569 #include <arpa/inet.h>
570 #include <sys/ioctl.h>
571 #include <sys/types.h>
572 #include <sys/socket.h>
573 #include <linux/sockios.h>
574 #include <linux/net_tstamp.h>
575 #include <linux/if_packet.h>
576 #include <linux/if_ether.h>
577 #include <linux/if.h>
581 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
582 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
583 struct hwtstamp_config hwconfig;
586 memset(&hwconfig, 0, sizeof(hwconfig));
587 hwconfig.tx_type = HWTSTAMP_TX_OFF;
588 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
590 memset(&ifr, 0, sizeof(ifr));
591 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
592 ifr.ifr_data = &hwconfig;
594 ioctl(sock, SIOCSHWTSTAMP, &ifr);
595 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
600 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
601 if [ ! -x $TMPDIR/hwtstest
] ; then
603 echo "CONFIG_HWTSTAMP=0" >> Config
606 echo "CONFIG_HWTSTAMP=1" >> Config
613 echo -n "[*] Checking libcli ... "
615 cat > $TMPDIR/clitest.c
<< EOF
616 #include <sys/time.h>
621 struct cli_def *cli = cli_init();
625 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
626 if [ ! -x $TMPDIR/clitest
] ; then
629 tools_remove
"mausezahn"
637 echo -n "[*] Checking libnet ... "
639 cat > $TMPDIR/nettest.c
<< EOF
644 char err_buf[LIBNET_ERRBUF_SIZE];
645 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
649 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
650 if [ ! -x $TMPDIR/nettest
] ; then
653 tools_remove
"mausezahn"
659 gen_version_appendix
()
663 git rev-parse
> /dev
/null
2>&1
664 if [ "$?" == "0" ] ; then
665 if [ ! "`git describe --always`" == \
666 "`git describe --abbrev=0 --tags`" ] ; then
671 echo "CONFIG_RC=\"$_appendix\"" >> Config
677 local _have_libpcap
=""
678 local _have_libgeoip
=""
684 echo "[*] Generating config.h ..."
686 git rev-parse
> /dev
/null
2>&1
687 if [ "$?" == "0" ] ; then
688 _version
="`git describe --always`"
693 if [ "$HAVE_LIBNL" == "1" ] ; then
694 _have_libnl
="#define HAVE_LIBNL 1"
696 _have_libnl
="/* HAVE_LIBNL is not defined */"
699 if [ "$HAVE_LIBPCAP" == "1" ] ; then
700 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
702 _have_libpcap
="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
705 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
706 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
708 _have_hwts
="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
711 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
712 _have_libgeoip
="#define HAVE_GEOIP 1"
714 _have_libgeoip
="/* HAVE_GEOIP is not defined */"
717 if [ "$HAVE_LIBZ" == "1" ] ; then
718 _have_libz
="#define HAVE_LIBZ 1"
720 _have_libz
="/* HAVE_LIBZ is not defined */"
723 if [ "$HAVE_TPACKET3" == "1" ] ; then
724 _have_tp3
="#define HAVE_TPACKET3 1"
726 _have_tp3
="/* HAVE_TPACKET3 is not defined */"
729 cat > config.h
<< EOF
732 #define FILE_CLIENTS ".curvetun/clients"
733 #define FILE_SERVERS ".curvetun/servers"
734 #define FILE_PRIVKEY ".curvetun/priv.key"
735 #define FILE_PUBKEY ".curvetun/pub.key"
736 #define FILE_USERNAM ".curvetun/username"
737 #define GITVERSION "$_version"
744 #endif /* CONFIG_H */
750 echo "# This file is autogenerated by the configure script" > Config
753 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
754 echo "[!] One or more of the toolchain tools couldn't be found in your"
755 echo " \$PATH. Please check the file config.log for details."
779 if [ "$MISSING_DEFS" == "1" ] ; then
780 echo "[!] Some libraries or header definitions are missing or too old. Thus"
781 echo " certain tools will not be built (see below). Please refer to the"
782 echo " INSTALL file for the libraries needed to build the complete"
783 echo " netsniff-ng toolkit."
786 if [ "$MISSING_NACL" == "1" ] ; then
787 echo "[!] The NaCl crypto library is currently not present on your system or"
788 echo " could not be found. Either install it from your distro or build it"
789 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
790 echo " NACL_LIB_DIR environment variables are set appropriately."
793 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
794 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
795 echo "[*] The following tools will be built: $TOOLS"
797 echo "[*] Looks good! All tools will be built!"
800 if [ -s config.log
] ; then
801 echo "[!] There were errors in the configure script. Please check the file"
802 echo " config.log for details."
805 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
807 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
808 echo "CONFIG_GEOIP=1" >> Config
810 echo "CONFIG_GEOIP=0" >> Config
813 if [ "$HAVE_PREFIX" == "1" ] ; then
814 echo "PREFIX=$PREFIX" >> Config
817 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
818 echo "CONFIG_TOOLS=$TOOLS" >> Config
819 echo "CONFIG_OK=1" >> Config