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 [ -z $STRIP ] && STRIP
="${CROSS_COMPILE}strip"
26 if [ "x$SYSROOT" != "x" ] ; then
27 PKG_CONFIG_PATH
="$SYSROOT/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
29 [ -z $PKG_CONFIG ] && PKG_CONFIG
="${CROSS_COMPILE}pkg-config"
31 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
32 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
39 for tool
in $_tools ; do
44 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
46 *) TOOLS
="$TOOLS $tool" ;;
51 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
56 if [ "x$CROSS_COMPILE" != "x" ] ; then
57 echo "[*] Cross-compiling for $($CC -print-multiarch)"
58 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
61 echo -n "[*] Checking compiler $CC ... "
62 if [ "x$(which $CC 2>> config.log)" == "x" ] ; then
67 echo "CC=$CC" >> Config
70 echo -n "[*] Checking linker $LD ... "
71 if [ "x$(which $LD 2>> config.log)" == "x" ] ; then
76 echo "LD=$LD" >> Config
79 echo -n "[*] Checking $PKG_CONFIG ... "
80 if [ "x$(which $PKG_CONFIG 2>> config.log)" == "x" ] ; then
85 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
86 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
89 echo -n "[*] Checking $STRIP ... "
90 if [ "x$(which $STRIP 2>> config.log)" == "x" ] ; then
95 echo "STRIP=$STRIP" >> Config
102 echo -n "[*] Checking flex ... "
104 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
107 tools_remove
"trafgen"
116 echo -n "[*] Checking bison ... "
118 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
121 tools_remove
"trafgen"
130 echo -n "[*] Checking nacl ... "
132 cat > $TMPDIR/nacltest.c
<< EOF
133 #include "crypto_hash_sha512.h"
134 #include "crypto_verify_32.h"
135 #include "crypto_hash_sha512.h"
136 #include "crypto_box_curve25519xsalsa20poly1305.h"
137 #include "crypto_scalarmult_curve25519.h"
138 #include "crypto_auth_hmacsha512256.h"
143 if [ -z $NACL_INC_DIR ] ; then
144 NACL_INC_DIR
="/usr/include/nacl"
147 if [ -z $NACL_LIB_DIR ] ; then
148 NACL_LIB_DIR
="/usr/lib"
151 if [ -z $NACL_LIB ] ; then
155 LDFLAGS
="-L $NACL_LIB_DIR"
156 CFLAGS
="-I $NACL_INC_DIR"
158 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
159 if [ ! -x $TMPDIR/nacltest
] ; then
162 tools_remove
"curvetun"
165 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
166 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
167 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
173 echo -n "[*] Checking libnl ... "
175 cat > $TMPDIR/libnltest.c
<< EOF
176 #include <netlink/genl/genl.h>
177 #include <netlink/genl/family.h>
178 #include <netlink/genl/ctrl.h>
179 #include <netlink/msg.h>
180 #include <netlink/attr.h>
181 #include <netlink/version.h>
183 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
184 # error incompatible libnl version
189 struct nl_sock *sock = nl_socket_alloc();
190 struct nl_cache *nl_cache;
191 int ret = genl_connect(sock);
193 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
198 $
($PKG_CONFIG --cflags libnl-3.0
2>> config.log
) \
199 $
($PKG_CONFIG --cflags libnl-genl-3.0
2>> config.log
) \
200 -o $TMPDIR/libnltest \
201 $TMPDIR/libnltest.c \
202 $
($PKG_CONFIG --libs libnl-3.0
2>> config.log
) \
203 $
($PKG_CONFIG --libs libnl-genl-3.0
2>> config.log
) \
205 if [ ! -x $TMPDIR/libnltest
] ; then
208 tools_remove
"trafgen"
209 tools_remove
"netsniff-ng"
217 echo -n "[*] Checking tpacket_v3 ... "
219 cat > $TMPDIR/tpacketv3test.c
<< EOF
221 #include <linux/if_packet.h>
225 struct tpacket3_hdr *hdr;
230 printf("%d\n", hdr->tp_status);
234 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
235 if [ ! -x $TMPDIR/tpacketv3test
] ; then
246 echo -n "[*] Checking tpacket_v2 ... "
248 cat > $TMPDIR/tpacketv2test.c
<< EOF
250 #include <linux/if_packet.h>
254 struct tpacket2_hdr *hdr;
257 TP_STATUS_SEND_REQUEST,
263 printf("%d\n", hdr->tp_status);
267 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
268 if [ ! -x $TMPDIR/tpacketv2test
] ; then
271 tools_remove
"netsniff-ng"
272 tools_remove
"trafgen"
281 echo -n "[*] Checking ncurses ... "
283 cat > $TMPDIR/ncursestest.c
<< EOF
288 WINDOW *screen = initscr();
293 $
($PKG_CONFIG --cflags ncurses
2>> config.log
) \
294 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
295 $
($PKG_CONFIG --libs ncurses
2>> config.log \
296 ||
echo '-lncurses' ) \
298 if [ ! -x $TMPDIR/ncursestest
] ; then
301 tools_remove
"flowtop"
310 echo -n "[*] Checking libGeoIP ... "
312 cat > $TMPDIR/geoiptest.c
<< EOF
314 #include <GeoIPCity.h>
319 GEOIP_CITY_EDITION_REV1,
320 GEOIP_CITY_EDITION_REV1_V6,
321 GEOIP_COUNTRY_EDITION,
322 GEOIP_COUNTRY_EDITION_V6,
324 GEOIP_ASNUM_EDITION_V6,
326 GeoIP *geoip = GeoIP_new(0);
330 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
331 if [ ! -x $TMPDIR/geoiptest
] ; then
342 echo -n "[*] Checking libnetfilter-conntrack ... "
344 cat > $TMPDIR/nfcttest.c
<< EOF
345 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
346 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
347 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
348 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
352 struct nf_conntrack *ct;
353 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
357 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> config.log
2>&1
358 if [ ! -x $TMPDIR/nfcttest
] ; then
361 tools_remove
"flowtop"
369 echo -n "[*] Checking libz ... "
371 cat > $TMPDIR/ztest.c
<< EOF
376 gzFile fp = gzopen("foo.gz", "rb");
380 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
381 if [ ! -x $TMPDIR/ztest
] ; then
383 echo "CONFIG_LIBZ=0" >> Config
385 tools_remove
"astraceroute"
386 tools_remove
"flowtop"
389 echo "CONFIG_LIBZ=1" >> Config
396 echo -n "[*] Checking liburcu ... "
398 cat > $TMPDIR/urcutest.c
<< EOF
408 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
409 if [ ! -x $TMPDIR/urcutest
] ; then
412 tools_remove
"flowtop"
420 echo -n "[*] Checking libpcap ... "
422 cat > $TMPDIR/pcaptest.c
<< EOF
427 struct bpf_program bpf;
428 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
432 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
433 if [ ! -x $TMPDIR/pcaptest
] ; then
435 echo "CONFIG_LIBPCAP=0" >> Config
437 tools_remove
"mausezahn"
440 echo "CONFIG_LIBPCAP=1" >> Config
447 echo -n "[*] Checking hw timestamping ... "
449 cat > $TMPDIR/hwtstest.c
<< EOF
451 #include <arpa/inet.h>
452 #include <sys/ioctl.h>
453 #include <sys/types.h>
454 #include <sys/socket.h>
455 #include <linux/sockios.h>
456 #include <linux/net_tstamp.h>
457 #include <linux/if_packet.h>
458 #include <linux/if_ether.h>
459 #include <linux/if.h>
463 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
464 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
465 struct hwtstamp_config hwconfig;
468 memset(&hwconfig, 0, sizeof(hwconfig));
469 hwconfig.tx_type = HWTSTAMP_TX_OFF;
470 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
472 memset(&ifr, 0, sizeof(ifr));
473 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
474 ifr.ifr_data = &hwconfig;
476 ioctl(sock, SIOCSHWTSTAMP, &ifr);
477 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
482 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
483 if [ ! -x $TMPDIR/hwtstest
] ; then
485 echo "CONFIG_HWTSTAMP=0" >> Config
488 echo "CONFIG_HWTSTAMP=1" >> Config
495 echo -n "[*] Checking libcli ... "
497 cat > $TMPDIR/clitest.c
<< EOF
498 #include <sys/time.h>
503 struct cli_def *cli = cli_init();
507 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
508 if [ ! -x $TMPDIR/clitest
] ; then
511 tools_remove
"mausezahn"
519 echo -n "[*] Checking libnet ... "
521 cat > $TMPDIR/nettest.c
<< EOF
526 char err_buf[LIBNET_ERRBUF_SIZE];
527 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
531 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
532 if [ ! -x $TMPDIR/nettest
] ; then
535 tools_remove
"mausezahn"
541 gen_version_appendix
()
545 git rev-parse
> /dev
/null
2>&1
546 if [ "$?" == "0" ] ; then
547 if [ ! "`git describe --always`" == \
548 "`git describe --abbrev=0 --tags`" ] ; then
553 echo "CONFIG_RC=\"$_appendix\"" >> Config
559 local _have_libpcap
=""
560 local _have_libgeoip
=""
565 echo "[*] Generating config.h ..."
567 git rev-parse
> /dev
/null
2>&1
568 if [ "$?" == "0" ] ; then
569 _version
="`git describe --always`"
574 if [ "$HAVE_LIBPCAP" == "1" ] ; then
575 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
578 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
579 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
582 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
583 _have_libgeoip
="#define HAVE_GEOIP 1"
586 if [ "$HAVE_LIBZ" == "1" ] ; then
587 _have_libz
="#define HAVE_LIBZ 1"
590 if [ "$HAVE_TPACKET3" == "1" ] ; then
591 _have_tp3
="#define HAVE_TPACKET3 1"
594 cat > config.h
<< EOF
597 #define FILE_CLIENTS ".curvetun/clients"
598 #define FILE_SERVERS ".curvetun/servers"
599 #define FILE_PRIVKEY ".curvetun/priv.key"
600 #define FILE_PUBKEY ".curvetun/pub.key"
601 #define FILE_USERNAM ".curvetun/username"
602 #define GITVERSION "$_version"
608 #endif /* CONFIG_H */
614 echo "# This file is autogenerated by the configure script" > Config
617 if [ "$MISSING_TOOLCHAIN" == "1" ] ; then
618 echo "[!] One or more of the toolchain tools couldn't be found in your"
619 echo " \$PATH. Please check the file config.log for details."
642 if [ "$MISSING_DEFS" == "1" ] ; then
643 echo "[!] Some libraries or header definitions are missing or too old. Thus"
644 echo " certain tools will not be built (see below). Please refer to the"
645 echo " INSTALL file for the libraries needed to build the complete"
646 echo " netsniff-ng toolkit."
649 if [ "$MISSING_NACL" == "1" ] ; then
650 echo "[!] The NaCl crypto library is currently not present on your system or"
651 echo " could not be found. Either install it from your distro or build it"
652 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
653 echo " NACL_LIB_DIR environment variables are set appropriately."
656 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
657 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
658 echo "[*] The following tools will be built: $TOOLS"
660 echo "[*] Looks good! All tools will be built!"
663 if [ -s config.log
] ; then
664 echo "[!] There were errors in the configure script. Please check the file"
665 echo " config.log for details."
668 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
669 echo "CONFIG_GEOIP=1" >> Config
671 echo "CONFIG_GEOIP=0" >> Config
674 echo "CONFIG_TOOLS=$TOOLS" >> Config
675 echo "CONFIG_OK=1" >> Config