Debian Codegraph @

configure

raw
1 #!/bin/bash
2 # This isn't a configure generated by autoconf!
3 # netsniff-ng build system
4 # Copyright 2013-2016 Tobias Klauser <[email protected]>
5 # Copyright 2013 Daniel Borkmann <[email protected]>
6 # Subject to the GNU GPL, version 2.
7
8 MISSING_TOOLCHAIN=0
9 MISSING_DEFS=0
10 MISSING_NACL=0
11
12 TOOLS="netsniff-ng trafgen astraceroute flowtop ifpps bpfc curvetun mausezahn"
13 TOOLS_NOBUILD=""
14
15 HAVE_LIBNL=0
16 HAVE_LIBPCAP=0
17 HAVE_HWTSTAMP=0
18 HAVE_LIBGEOIP=0
19 HAVE_LIBZ=0
20 HAVE_TPACKET3=0
21
22 DISABLE_LIBNL=0
23 DISABLE_GEOIP=0
24 DISABLE_ZLIB=0
25 ENABLE_DEBUG=0
26
27 PREFIX="/usr/local"
28 SYSCONF_DIR="/etc"
29
30 usage()
31 {
32 echo "Usage: ./configure [OPTION]... [VAR=VALUE]..."
33 echo ""
34 echo " -h, --help Display this help and exit"
35 echo ""
36 echo "Installation directories:"
37 echo " --prefix=PREFIX install architecture-independent files in PREFIX"
38 echo " [$PREFIX]"
39 echo " --sysconfdir=DIR read-only single-machine data [$SYSCONF_DIR]"
40 echo ""
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'."
45 echo ""
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)"
51 echo ""
52 echo "Some influential environment variables:"
53 echo " CC C compiler command"
54 echo " CROSS_COMPILE C cross-compiler prefix"
55
56 exit 0
57 }
58
59 while [ $# -gt 0 ] ; do
60 case "$1" in
61 -h|--help)
62 usage
63 ;;
64 --prefix=*)
65 PREFIX="${1#*=}"
66 ;;
67 --sysconfdir=*)
68 SYSCONF_DIR="${1#*=}"
69 ;;
70 --disable-libnl)
71 DISABLE_LIBNL=1
72 ;;
73 --disable-geoip)
74 DISABLE_GEOIP=1
75 ;;
76 --disable-zlib)
77 DISABLE_ZLIB=1
78 ;;
79 --enable-debug)
80 ENABLE_DEBUG=1
81 ;;
82 *)
83 echo "[!] Unrecognized option: '$1'. Try './configure --help' for more information"
84 exit 1
85 ;;
86 esac
87 shift
88 done
89
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"
94 fi
95 [ -z $PKG_CONFIG ] && PKG_CONFIG="${CROSS_COMPILE}pkg-config"
96
97 TMPDIR=$(mktemp -d config.XXXXXX)
98 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
99
100 tools_remove()
101 {
102 local _tools=$TOOLS
103 local _todel=$1
104 TOOLS=""
105 for tool in $_tools ; do
106 case "$tool" in
107 $_todel)
108 case $_todel in
109 $TOOLS_NOBUILD) ;;
110 *) TOOLS_NOBUILD="$TOOLS_NOBUILD $tool" ;;
111 esac ;;
112 *) TOOLS="$TOOLS $tool" ;;
113 esac
114 done
115
116 TOOLS=${TOOLS# }
117 TOOLS_NOBUILD=${TOOLS_NOBUILD# }
118 }
119
120 check_command()
121 {
122 local cmd="$1"
123
124 [ "x$(which "$cmd" 2>> config.log)" == "x" ]
125 }
126
127 check_toolchain()
128 {
129 if [ "x$CROSS_COMPILE" != "x" ] ; then
130 echo "[*] Cross-compiling for $($CC -print-multiarch)"
131 echo "CROSS_COMPILE=$CROSS_COMPILE" >> Config
132 fi
133
134 echo -n "[*] Checking compiler $CC ... "
135 if check_command $CC ; then
136 echo "[NO]"
137 MISSING_TOOLCHAIN=1
138 else
139 echo "[YES]"
140 echo "CC=$CC" >> Config
141 fi
142
143 echo -n "[*] Checking linker $LD ... "
144 if check_command $LD ; then
145 echo "[NO]"
146 MISSING_TOOLCHAIN=1
147 else
148 echo "[YES]"
149 echo "LD=$LD" >> Config
150 fi
151
152 echo -n "[*] Checking $PKG_CONFIG ... "
153 if check_command $PKG_CONFIG ; then
154 echo "[NO]"
155 MISSING_TOOLCHAIN=1
156 else
157 echo "[YES]"
158 echo "PKG_CONFIG=$PKG_CONFIG" >> Config
159 echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> Config
160 fi
161 }
162
163 check_flex()
164 {
165 echo -n "[*] Checking flex ... "
166
167 if check_command flex ; then
168 echo "[NO]"
169 MISSING_DEFS=1
170 tools_remove "trafgen"
171 tools_remove "bpfc"
172 else
173 echo "[YES]"
174 fi
175 }
176
177 check_bison()
178 {
179 echo -n "[*] Checking bison ... "
180
181 if check_command bison ; then
182 echo "[NO]"
183 MISSING_DEFS=1
184 tools_remove "trafgen"
185 tools_remove "bpfc"
186 else
187 echo "[YES]"
188 fi
189 }
190
191 check_nacl()
192 {
193 echo -n "[*] Checking nacl/sodium ... "
194
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"
202
203 int main(void) { }
204 EOF
205
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"
210 else
211 NACL_INC_DIR="$NACL_INC_DIR/sodium"
212 NACL_LIB="sodium"
213 fi
214 fi
215
216 if [ -z $NACL_LIB_DIR ] ; then
217 NACL_LIB_DIR="$SYSROOT/usr/lib"
218 fi
219
220 if [ -z $NACL_LIB ] ; then
221 NACL_LIB="nacl"
222 fi
223
224 LDFLAGS="-L $NACL_LIB_DIR"
225 CFLAGS="-I $NACL_INC_DIR"
226
227 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest $TMPDIR/nacltest.c >> config.log 2>&1
228 if [ ! -x $TMPDIR/nacltest ] ; then
229 echo "[NO]"
230 MISSING_NACL=1
231 tools_remove "curvetun"
232 else
233 echo "[YES]"
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
237 fi
238 }
239
240 check_libnl()
241 {
242 echo -n "[*] Checking libnl ... "
243
244 if [ "$DISABLE_LIBNL" == "1" ] ; then
245 echo "[DISABLED]"
246 return
247 fi
248
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>
256
257 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
258 # error incompatible libnl version
259 #endif
260
261 int main(void)
262 {
263 struct nl_sock *sock = nl_socket_alloc();
264 struct nl_cache *nl_cache;
265 int ret = genl_connect(sock);
266
267 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
268 }
269 EOF
270
271 $CC \
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) \
278 >> config.log 2>&1
279 if [ ! -x $TMPDIR/libnltest ] ; then
280 echo "[NO]"
281 MISSING_DEFS=1
282 else
283 echo "[YES]"
284 HAVE_LIBNL=1
285 fi
286 }
287
288 check_libnl_route()
289 {
290 echo -n "[*] Checking libnl-route ... "
291
292 if [ "$DISABLE_LIBNL" == "1" ] ; then
293 echo "[DISABLED]"
294 return
295 fi
296
297 if [ "$HAVE_LIBNL" == "0" ] ; then
298 echo "[SKIPPED]"
299 return
300 fi
301
302 cat > $TMPDIR/libnlroutetest.c << EOF
303 #include <netlink/route/link.h>
304 #include <netlink/route/addr.h>
305
306 int main(void)
307 {
308 char str[100];
309
310 rtnl_addr_flags2str(1, str, sizeof(str));
311 rtnl_link_flags2str(1, str, sizeof(str));
312 rtnl_link_operstate2str(1, str, sizeof(str));
313
314 return 0;
315 }
316 EOF
317
318 $CC \
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) \
323 >> config.log 2>&1
324 if [ ! -x $TMPDIR/libnlroutetest ] ; then
325 echo "[NO]"
326 MISSING_DEFS=1
327 HAVE_LIBNL=0
328 else
329 echo "[YES]"
330 # HAVE_LIBNL already set by check_libnl()
331 fi
332 }
333
334 check_tpacket_v3()
335 {
336 echo -n "[*] Checking tpacket_v3 ... "
337
338 cat > $TMPDIR/tpacketv3test.c << EOF
339 #include <stdio.h>
340 #include <linux/if_packet.h>
341
342 int main(void)
343 {
344 struct tpacket3_hdr *hdr;
345 int foo[] = {
346 TP_STATUS_BLK_TMO,
347 };
348
349 printf("%d\n", hdr->tp_status);
350 }
351 EOF
352
353 $CC -o $TMPDIR/tpacketv3test $TMPDIR/tpacketv3test.c >> config.log 2>&1
354 if [ ! -x $TMPDIR/tpacketv3test ] ; then
355 echo "[NO]"
356 MISSING_DEFS=1
357 else
358 echo "[YES]"
359 HAVE_TPACKET3=1
360 fi
361 }
362
363 check_tpacket_v2()
364 {
365 echo -n "[*] Checking tpacket_v2 ... "
366
367 cat > $TMPDIR/tpacketv2test.c << EOF
368 #include <stdio.h>
369 #include <linux/if_packet.h>
370
371 int main(void)
372 {
373 struct tpacket2_hdr *hdr;
374 int foo[] = {
375 TP_STATUS_AVAILABLE,
376 TP_STATUS_SEND_REQUEST,
377 TP_STATUS_SENDING,
378 TP_STATUS_KERNEL,
379 TP_STATUS_USER,
380 };
381
382 printf("%d\n", hdr->tp_status);
383 }
384 EOF
385
386 $CC -o $TMPDIR/tpacketv2test $TMPDIR/tpacketv2test.c >> config.log 2>&1
387 if [ ! -x $TMPDIR/tpacketv2test ] ; then
388 echo "[NO]"
389 MISSING_DEFS=1
390 tools_remove "netsniff-ng"
391 tools_remove "trafgen"
392 else
393 echo "[YES]"
394 fi
395 }
396
397 check_fopencookie()
398 {
399 echo -n "[*] Checking fopencookie ... "
400
401 cat > $TMPDIR/fopencookietest.c << EOF
402 #define _GNU_SOURCE
403 #include <stdio.h>
404
405 static cookie_io_functions_t cookie_fns;
406
407 int main(void)
408 {
409 FILE *f = fopencookie(NULL, "w", cookie_fns);
410 }
411 EOF
412
413 $CC -o $TMPDIR/fopencookietest $TMPDIR/fopencookietest.c >> config.log 2>&1
414 if [ ! -x $TMPDIR/fopencookietest ] ; then
415 echo "[NO]"
416 MISSING_DEFS=1
417 tools_remove "curvetun"
418 else
419 echo "[YES]"
420 fi
421 }
422
423 check_ncurses()
424 {
425 echo -n "[*] Checking ncurses ... "
426
427 cat > $TMPDIR/ncursestest.c << EOF
428 #include <curses.h>
429
430 int main(void)
431 {
432 WINDOW *screen = initscr();
433 }
434 EOF
435
436 $CC \
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' ) \
441 >> config.log 2>&1
442 if [ ! -x $TMPDIR/ncursestest ] ; then
443 echo "[NO]"
444 MISSING_DEFS=1
445 tools_remove "flowtop"
446 tools_remove "ifpps"
447 else
448 echo "[YES]"
449 fi
450 }
451
452 check_libgeoip()
453 {
454 echo -n "[*] Checking libGeoIP ... "
455
456 if [ "$DISABLE_GEOIP" == "1" ] ; then
457 echo "[DISABLED]"
458 return
459 fi
460
461 cat > $TMPDIR/geoiptest.c << EOF
462 #include <GeoIP.h>
463 #include <GeoIPCity.h>
464
465 int main(void)
466 {
467 int dbs[] = {
468 GEOIP_CITY_EDITION_REV1,
469 GEOIP_CITY_EDITION_REV1_V6,
470 GEOIP_COUNTRY_EDITION,
471 GEOIP_COUNTRY_EDITION_V6,
472 GEOIP_ASNUM_EDITION,
473 GEOIP_ASNUM_EDITION_V6,
474 };
475 GeoIP *geoip = GeoIP_new(0);
476 }
477 EOF
478
479 $CC -o $TMPDIR/geoiptest $TMPDIR/geoiptest.c -lGeoIP >> config.log 2>&1
480 if [ ! -x $TMPDIR/geoiptest ] ; then
481 echo "[NO]"
482 MISSING_DEFS=1
483 else
484 echo "[YES]"
485 HAVE_LIBGEOIP=1
486 fi
487 }
488
489 check_libnf_ct()
490 {
491 echo -n "[*] Checking libnetfilter-conntrack ... "
492
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>
498
499 int main(void)
500 {
501 struct nf_conntrack *ct;
502 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
503 }
504 EOF
505
506 $CC \
507 $($PKG_CONFIG --cflags libnetfilter_conntrack 2>> config.log) \
508 -o $TMPDIR/nfcttest \
509 $TMPDIR/nfcttest.c \
510 $($PKG_CONFIG --libs libnetfilter_conntrack 2>> config.log) \
511 >> config.log 2>&1
512 if [ ! -x $TMPDIR/nfcttest ] ; then
513 echo "[NO]"
514 MISSING_DEFS=1
515 tools_remove "flowtop"
516 else
517 echo "[YES]"
518 fi
519 }
520
521 check_zlib()
522 {
523 echo -n "[*] Checking libz ... "
524
525 if [ "$DISABLE_ZLIB" == "1" ] ; then
526 echo "[DISABLED]"
527 return
528 fi
529
530 cat > $TMPDIR/ztest.c << EOF
531 #include "zlib.h"
532
533 int main(void)
534 {
535 gzFile fp = gzopen("foo.gz", "rb");
536 }
537 EOF
538
539 $CC -o $TMPDIR/ztest $TMPDIR/ztest.c -lz >> config.log 2>&1
540 if [ ! -x $TMPDIR/ztest ] ; then
541 echo "[NO]"
542 echo "CONFIG_LIBZ=0" >> Config
543 MISSING_DEFS=1
544 tools_remove "astraceroute"
545 tools_remove "flowtop"
546 else
547 echo "[YES]"
548 echo "CONFIG_LIBZ=1" >> Config
549 HAVE_LIBZ=1
550 fi
551 }
552
553 check_urcu()
554 {
555 echo -n "[*] Checking liburcu ... "
556
557 cat > $TMPDIR/urcutest.c << EOF
558 #include <urcu.h>
559
560 int main(void)
561 {
562 rcu_init();
563 synchronize_rcu();
564 }
565 EOF
566
567 $CC -o $TMPDIR/urcutest $TMPDIR/urcutest.c -lurcu >> config.log 2>&1
568 if [ ! -x $TMPDIR/urcutest ] ; then
569 echo "[NO]"
570 MISSING_DEFS=1
571 tools_remove "flowtop"
572 else
573 echo "[YES]"
574 fi
575 }
576
577 check_libpcap()
578 {
579 echo -n "[*] Checking libpcap ... "
580
581 cat > $TMPDIR/pcaptest.c << EOF
582 #include <pcap.h>
583
584 int main(void)
585 {
586 struct bpf_program bpf;
587 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
588 }
589 EOF
590
591 $CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c \
592 $($PKG_CONFIG --libs libpcap 2>> config.log) \
593 >> config.log 2>&1
594 if [ ! -x $TMPDIR/pcaptest ] ; then
595 echo "[NO]"
596 echo "CONFIG_LIBPCAP=0" >> Config
597 MISSING_DEFS=1
598 tools_remove "mausezahn"
599 else
600 echo "[YES]"
601 echo "CONFIG_LIBPCAP=1" >> Config
602 HAVE_LIBPCAP=1
603 fi
604 }
605
606 check_hwtstamp()
607 {
608 echo -n "[*] Checking hw timestamping ... "
609
610 cat > $TMPDIR/hwtstest.c << EOF
611 #include <string.h>
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>
621
622 int main(void)
623 {
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;
627 struct ifreq ifr;
628
629 memset(&hwconfig, 0, sizeof(hwconfig));
630 hwconfig.tx_type = HWTSTAMP_TX_OFF;
631 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
632
633 memset(&ifr, 0, sizeof(ifr));
634 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
635 ifr.ifr_data = &hwconfig;
636
637 ioctl(sock, SIOCSHWTSTAMP, &ifr);
638 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, &timesource,
639 sizeof(timesource));
640 }
641 EOF
642
643 $CC -o $TMPDIR/hwtstest $TMPDIR/hwtstest.c >> config.log 2>&1
644 if [ ! -x $TMPDIR/hwtstest ] ; then
645 echo "[NO]"
646 echo "CONFIG_HWTSTAMP=0" >> Config
647 else
648 echo "[YES]"
649 echo "CONFIG_HWTSTAMP=1" >> Config
650 HAVE_HWTSTAMP=1
651 fi
652 }
653
654 check_libcli()
655 {
656 echo -n "[*] Checking libcli ... "
657
658 cat > $TMPDIR/clitest.c << EOF
659 #include <sys/time.h>
660 #include <libcli.h>
661
662 int main(void)
663 {
664 struct cli_def *cli = cli_init();
665 }
666 EOF
667
668 $CC -o $TMPDIR/clitest $TMPDIR/clitest.c -lcli >> config.log 2>&1
669 if [ ! -x $TMPDIR/clitest ] ; then
670 echo "[NO]"
671 MISSING_DEFS=1
672 tools_remove "mausezahn"
673 else
674 echo "[YES]"
675 fi
676 }
677
678 check_libnet()
679 {
680 echo -n "[*] Checking libnet ... "
681
682 cat > $TMPDIR/nettest.c << EOF
683 #include <libnet.h>
684
685 int main(void)
686 {
687 char err_buf[LIBNET_ERRBUF_SIZE];
688 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
689 }
690 EOF
691
692 $CC -o $TMPDIR/nettest $TMPDIR/nettest.c -lnet >> config.log 2>&1
693 if [ ! -x $TMPDIR/nettest ] ; then
694 echo "[NO]"
695 MISSING_DEFS=1
696 tools_remove "mausezahn"
697 else
698 echo "[YES]"
699 fi
700 }
701
702 gen_version_appendix()
703 {
704 local _appendix=""
705
706 git rev-parse > /dev/null 2>&1
707 if [ "$?" == "0" ] ; then
708 if [ ! "`git describe --always`" == \
709 "`git describe --abbrev=0 --tags`" ] ; then
710 _appendix="+"
711 fi
712 fi
713
714 echo "CONFIG_RC=\"$_appendix\"" >> Config
715 }
716
717 gen_config_hdr()
718 {
719 local _version=""
720 local _have_libpcap=""
721 local _have_libgeoip=""
722 local _have_libnl=""
723 local _have_libz=""
724 local _have_hwts=""
725 local _have_tp3=""
726
727 echo "[*] Generating config.h ..."
728
729 git rev-parse > /dev/null 2>&1
730 if [ "$?" == "0" ] ; then
731 _version="`git describe --always`"
732 else
733 _version="(none)"
734 fi
735
736 if [ "$HAVE_LIBNL" == "1" ] ; then
737 _have_libnl="#define HAVE_LIBNL 1"
738 else
739 _have_libnl="/* HAVE_LIBNL is not defined */"
740 fi
741
742 if [ "$HAVE_LIBPCAP" == "1" ] ; then
743 _have_libpcap="#define HAVE_TCPDUMP_LIKE_FILTER 1"
744 else
745 _have_libpcap="/* HAVE_TCPDUMP_LIKE_FILTER is not defined */"
746 fi
747
748 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
749 _have_hwts="#define HAVE_HARDWARE_TIMESTAMPING 1"
750 else
751 _have_hwts="/* HAVE_HARDWARE_TIMESTAMPING is not defined */"
752 fi
753
754 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
755 _have_libgeoip="#define HAVE_GEOIP 1"
756 else
757 _have_libgeoip="/* HAVE_GEOIP is not defined */"
758 fi
759
760 if [ "$HAVE_LIBZ" == "1" ] ; then
761 _have_libz="#define HAVE_LIBZ 1"
762 else
763 _have_libz="/* HAVE_LIBZ is not defined */"
764 fi
765
766 if [ "$HAVE_TPACKET3" == "1" ] ; then
767 _have_tp3="#define HAVE_TPACKET3 1"
768 else
769 _have_tp3="/* HAVE_TPACKET3 is not defined */"
770 fi
771
772 cat > config.h << EOF
773 #ifndef CONFIG_H
774 #define CONFIG_H
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"
781 $_have_libnl
782 $_have_libpcap
783 $_have_libgeoip
784 $_have_libz
785 $_have_hwts
786 $_have_tp3
787 #endif /* CONFIG_H */
788 EOF
789 }
790
791 rm -f config.log
792
793 echo "# This file is autogenerated by the configure script" > Config
794 check_toolchain
795
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."
799 exit 1
800 fi
801
802 # external tools
803 check_flex
804 check_bison
805
806 # kernel features
807 check_tpacket_v2
808 check_tpacket_v3
809 check_hwtstamp
810
811 # libc features
812 check_fopencookie
813
814 # libraries
815 check_libcli
816 check_libgeoip
817 check_libnet
818 check_libnf_ct
819 check_libnl
820 check_libnl_route
821 check_libpcap
822 check_nacl
823 check_ncurses
824 check_urcu
825 check_zlib
826
827 gen_config_hdr
828 gen_version_appendix
829
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"
835 fi
836
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."
842 fi
843
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"
847 else
848 echo "[*] Looks good! All tools will be built!"
849 fi
850
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."
854 fi
855
856 echo "CONFIG_LIBNL=$HAVE_LIBNL" >> Config
857
858 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
859 echo "CONFIG_GEOIP=1" >> Config
860 else
861 echo "CONFIG_GEOIP=0" >> Config
862 fi
863
864 echo "CONFIG_PREFIX=$PREFIX" >> Config
865 echo "CONFIG_ETCDIR=$SYSCONF_DIR" >> Config
866
867 echo "CONFIG_DEBUG=$ENABLE_DEBUG" >> Config
868 echo "CONFIG_TOOLS=$TOOLS" >> Config
869 echo "CONFIG_OK=1" >> Config
870
871 exit 0