2 # This isn't a configure generated by autoconf!
3 # netsniff-ng build system
4 # Copyright 2013-2015 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"
21 # use "CROSS_COMPILE=<prefix> SYSROOT=<path> ./configure && make" for cross compilation
23 [ -z "$CC" ] && CC
="${CROSS_COMPILE}gcc"
24 [ -z "$LD" ] && LD
="${CROSS_COMPILE}gcc"
25 if [ "x$SYSROOT" != "x" ] ; then
26 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
28 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
30 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
31 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
38 for tool
in $_tools ; do
43 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
45 *) TOOLS
="$TOOLS $tool" ;;
50 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
55 if [ "x$CROSS_COMPILE" != "x" ] ; then
56 echo "[*] Cross-compiling for $($CC -print-multiarch)"
57 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
60 echo -n "[*] Checking compiler $CC ... "
61 if [ "x$(which $CC 2>> config.log)" == "x" ] ; then
66 echo "CC=$CC" >> Config
69 echo -n "[*] Checking linker $LD ... "
70 if [ "x$(which $LD 2>> config.log)" == "x" ] ; then
75 echo "LD=$LD" >> Config
78 echo -n "[*] Checking $PKG_CONFIG ... "
79 if [ "x$(which $PKG_CONFIG 2>> config.log)" == "x" ] ; then
84 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
85 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
91 echo -n "[*] Checking flex ... "
93 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
96 tools_remove
"trafgen"
105 echo -n "[*] Checking bison ... "
107 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
110 tools_remove
"trafgen"
119 echo -n "[*] Checking nacl ... "
121 cat > $TMPDIR/nacltest.c
<< EOF
122 #include "crypto_hash_sha512.h"
123 #include "crypto_verify_32.h"
124 #include "crypto_hash_sha512.h"
125 #include "crypto_box_curve25519xsalsa20poly1305.h"
126 #include "crypto_scalarmult_curve25519.h"
127 #include "crypto_auth_hmacsha512256.h"
132 if [ -z $NACL_INC_DIR ] ; then
133 NACL_INC_DIR
="$SYSROOT/usr/include/nacl"
136 if [ -z $NACL_LIB_DIR ] ; then
137 NACL_LIB_DIR
="$SYSROOT/usr/lib"
140 if [ -z $NACL_LIB ] ; then
144 LDFLAGS
="-L $NACL_LIB_DIR"
145 CFLAGS
="-I $NACL_INC_DIR"
147 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
148 if [ ! -x $TMPDIR/nacltest
] ; then
151 tools_remove
"curvetun"
154 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
155 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
156 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
162 echo -n "[*] Checking libnl ... "
164 cat > $TMPDIR/libnltest.c
<< EOF
165 #include <netlink/genl/genl.h>
166 #include <netlink/genl/family.h>
167 #include <netlink/genl/ctrl.h>
168 #include <netlink/msg.h>
169 #include <netlink/attr.h>
170 #include <netlink/version.h>
172 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
173 # error incompatible libnl version
178 struct nl_sock *sock = nl_socket_alloc();
179 struct nl_cache *nl_cache;
180 int ret = genl_connect(sock);
182 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
187 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
188 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
189 -o $TMPDIR/libnltest \
190 $TMPDIR/libnltest.c \
191 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
192 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
194 if [ ! -x $TMPDIR/libnltest
] ; then
197 tools_remove
"trafgen"
198 tools_remove
"netsniff-ng"
206 echo -n "[*] Checking libnl-route ... "
208 cat > $TMPDIR/libnlroutetest.c
<< EOF
209 #include <netlink/route/link.h>
210 #include <netlink/route/addr.h>
216 rtnl_addr_flags2str(1, str, sizeof(str));
217 rtnl_link_flags2str(1, str, sizeof(str));
218 rtnl_link_operstate2str(1, str, sizeof(str));
225 $
($PKG_CONFIG --cflags libnl-route-3.0
2>> config.log
) \
226 -o $TMPDIR/libnlroutetest \
227 $TMPDIR/libnlroutetest.c \
228 $
($PKG_CONFIG --libs libnl-route-3.0
2>> config.log
) \
230 if [ ! -x $TMPDIR/libnlroutetest
] ; then
233 tools_remove
"netsniff-ng"
241 echo -n "[*] Checking tpacket_v3 ... "
243 cat > $TMPDIR/tpacketv3test.c
<< EOF
245 #include <linux/if_packet.h>
249 struct tpacket3_hdr *hdr;
254 printf("%d\n", hdr->tp_status);
258 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
259 if [ ! -x $TMPDIR/tpacketv3test
] ; then
270 echo -n "[*] Checking tpacket_v2 ... "
272 cat > $TMPDIR/tpacketv2test.c
<< EOF
274 #include <linux/if_packet.h>
278 struct tpacket2_hdr *hdr;
281 TP_STATUS_SEND_REQUEST,
287 printf("%d\n", hdr->tp_status);
291 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
292 if [ ! -x $TMPDIR/tpacketv2test
] ; then
295 tools_remove
"netsniff-ng"
296 tools_remove
"trafgen"
305 echo -n "[*] Checking ncurses ... "
307 cat > $TMPDIR/ncursestest.c
<< EOF
312 WINDOW *screen = initscr();
317 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
318 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
319 $
($PKG_CONFIG --libs ncurses
2>> config.log \
320 ||
echo '-lncurses' ) \
322 if [ ! -x $TMPDIR/ncursestest
] ; then
325 tools_remove
"flowtop"
334 echo -n "[*] Checking libGeoIP ... "
336 cat > $TMPDIR/geoiptest.c
<< EOF
338 #include <GeoIPCity.h>
343 GEOIP_CITY_EDITION_REV1,
344 GEOIP_CITY_EDITION_REV1_V6,
345 GEOIP_COUNTRY_EDITION,
346 GEOIP_COUNTRY_EDITION_V6,
348 GEOIP_ASNUM_EDITION_V6,
350 GeoIP *geoip = GeoIP_new(0);
354 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
355 if [ ! -x $TMPDIR/geoiptest
] ; then
366 echo -n "[*] Checking libnetfilter-conntrack ... "
368 cat > $TMPDIR/nfcttest.c
<< EOF
369 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
370 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
371 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
372 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
376 struct nf_conntrack *ct;
377 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
382 $
($PKG_CONFIG --cflags libnetfilter_conntrack
2>> config.log
) \
383 -o $TMPDIR/nfcttest \
385 $
($PKG_CONFIG --libs libnetfilter_conntrack
2>> config.log
) \
387 if [ ! -x $TMPDIR/nfcttest
] ; then
390 tools_remove
"flowtop"
398 echo -n "[*] Checking libz ... "
400 cat > $TMPDIR/ztest.c
<< EOF
405 gzFile fp = gzopen("foo.gz", "rb");
409 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
410 if [ ! -x $TMPDIR/ztest
] ; then
412 echo "CONFIG_LIBZ=0" >> Config
414 tools_remove
"astraceroute"
415 tools_remove
"flowtop"
418 echo "CONFIG_LIBZ=1" >> Config
425 echo -n "[*] Checking liburcu ... "
427 cat > $TMPDIR/urcutest.c
<< EOF
437 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
438 if [ ! -x $TMPDIR/urcutest
] ; then
441 tools_remove
"flowtop"
449 echo -n "[*] Checking libpcap ... "
451 cat > $TMPDIR/pcaptest.c
<< EOF
456 struct bpf_program bpf;
457 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
461 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
462 if [ ! -x $TMPDIR/pcaptest
] ; then
464 echo "CONFIG_LIBPCAP=0" >> Config
466 tools_remove
"mausezahn"
469 echo "CONFIG_LIBPCAP=1" >> Config
476 echo -n "[*] Checking hw timestamping ... "
478 cat > $TMPDIR/hwtstest.c
<< EOF
480 #include <arpa/inet.h>
481 #include <sys/ioctl.h>
482 #include <sys/types.h>
483 #include <sys/socket.h>
484 #include <linux/sockios.h>
485 #include <linux/net_tstamp.h>
486 #include <linux/if_packet.h>
487 #include <linux/if_ether.h>
488 #include <linux/if.h>
492 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
493 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
494 struct hwtstamp_config hwconfig;
497 memset(&hwconfig, 0, sizeof(hwconfig));
498 hwconfig.tx_type = HWTSTAMP_TX_OFF;
499 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
501 memset(&ifr, 0, sizeof(ifr));
502 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
503 ifr.ifr_data = &hwconfig;
505 ioctl(sock, SIOCSHWTSTAMP, &ifr);
506 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
511 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
512 if [ ! -x $TMPDIR/hwtstest
] ; then
514 echo "CONFIG_HWTSTAMP=0" >> Config
517 echo "CONFIG_HWTSTAMP=1" >> Config
524 echo -n "[*] Checking libcli ... "
526 cat > $TMPDIR/clitest.c
<< EOF
527 #include <sys/time.h>
532 struct cli_def *cli = cli_init();
536 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
537 if [ ! -x $TMPDIR/clitest
] ; then
540 tools_remove
"mausezahn"
548 echo -n "[*] Checking libnet ... "
550 cat > $TMPDIR/nettest.c
<< EOF
555 char err_buf[LIBNET_ERRBUF_SIZE];
556 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
560 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
561 if [ ! -x $TMPDIR/nettest
] ; then
564 tools_remove
"mausezahn"
570 gen_version_appendix
()
574 git rev-parse
> /dev
/null
2>&1
575 if [ "$?" == "0" ] ; then
576 if [ ! "`git describe --always`" == \
577 "`git describe --abbrev=0 --tags`" ] ; then
582 echo "CONFIG_RC=\"$_appendix\"" >> Config
588 local _have_libpcap
=""
589 local _have_libgeoip
=""
594 echo "[*] Generating config.h ..."
596 git rev-parse
> /dev
/null
2>&1
597 if [ "$?" == "0" ] ; then
598 _version
="`git describe --always`"
603 if [ "$HAVE_LIBPCAP" == "1" ] ; then
604 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
607 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
608 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
611 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
612 _have_libgeoip
="#define HAVE_GEOIP 1"
615 if [ "$HAVE_LIBZ" == "1" ] ; then
616 _have_libz
="#define HAVE_LIBZ 1"
619 if [ "$HAVE_TPACKET3" == "1" ] ; then
620 _have_tp3
="#define HAVE_TPACKET3 1"
623 cat > config.h
<< EOF
626 #define FILE_CLIENTS ".curvetun/clients"
627 #define FILE_SERVERS ".curvetun/servers"
628 #define FILE_PRIVKEY ".curvetun/priv.key"
629 #define FILE_PUBKEY ".curvetun/pub.key"
630 #define FILE_USERNAM ".curvetun/username"
631 #define GITVERSION "$_version"
637 #endif /* CONFIG_H */
643 echo "# This file is autogenerated by the configure script" > Config
646 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
647 echo "[!] One or more of the toolchain tools couldn't be found in your"
648 echo " \$PATH. Please check the file config.log for details."
672 if [ "$MISSING_DEFS" == "1" ] ; then
673 echo "[!] Some libraries or header definitions are missing or too old. Thus"
674 echo " certain tools will not be built (see below). Please refer to the"
675 echo " INSTALL file for the libraries needed to build the complete"
676 echo " netsniff-ng toolkit."
679 if [ "$MISSING_NACL" == "1" ] ; then
680 echo "[!] The NaCl crypto library is currently not present on your system or"
681 echo " could not be found. Either install it from your distro or build it"
682 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
683 echo " NACL_LIB_DIR environment variables are set appropriately."
686 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
687 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
688 echo "[*] The following tools will be built: $TOOLS"
690 echo "[*] Looks good! All tools will be built!"
693 if [ -s config.log
] ; then
694 echo "[!] There were errors in the configure script. Please check the file"
695 echo " config.log for details."
698 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
699 echo "CONFIG_GEOIP=1" >> Config
701 echo "CONFIG_GEOIP=0" >> Config
704 echo "CONFIG_TOOLS=$TOOLS" >> Config
705 echo "CONFIG_OK=1" >> Config