File: configure.in

package info (click to toggle)
libtrace3 3.0.21-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 4,356 kB
  • ctags: 3,791
  • sloc: ansic: 24,422; sh: 11,372; cpp: 1,811; makefile: 464; yacc: 96; lex: 50
file content (715 lines) | stat: -rw-r--r-- 21,943 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# Process this file with autoconf to produce a configure script.

# Now you only need to update the version number in two places - below,
# and in the README

AC_INIT([libtrace],[3.0.21],[contact@wand.net.nz],[libtrace])

LIBTRACE_MAJOR=3
LIBTRACE_MID=0
LIBTRACE_MINOR=21

# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
# searched by default - add it to LDFLAGS so we at least have a chance of 
# finding it
if test -d "/usr/gnu/lib"; then
	LDFLAGS+=" -L/usr/gnu/lib"
fi

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(lib/trace.c)
AM_INIT_AUTOMAKE([subdir-objects])

# Make sure we use the relatively silent automake output
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

# Define our libtrace version number externally so we can use it in the source
# as well, if needed.
AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version])
AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version])
AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version])

# These are all the files we want to be built for us by configure
AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile
	tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile 
	tools/tracemerge/Makefile tools/tracereport/Makefile
	tools/tracertstats/Makefile tools/tracesplit/Makefile
	tools/tracestats/Makefile tools/tracetop/Makefile
	tools/tracereplay/Makefile tools/tracediff/Makefile
	tools/traceends/Makefile
	examples/Makefile examples/skeleton/Makefile examples/rate/Makefile
	examples/stats/Makefile examples/tutorial/Makefile
	docs/libtrace.doxygen 
	lib/libtrace.h libwandio/Makefile libwandio/tools/wandiocat/Makefile
	])


# Function that checks if the C++ compiler actually works - there's a bit of
# oversight in autoconf that will set the C++ compiler to g++ if no compiler
# is found, even if g++ is not present! So we need an extra test to make sure
# that the compiler works :(

AC_DEFUN([rw_PROG_CXX_WORKS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_CACHE_CHECK([whether the C++ compiler works],
	[rw_cv_prog_cxx_works],
	[AC_LANG_PUSH([C++])
	AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
		[rw_cv_prog_cxx_works=yes],
		[rw_cv_prog_cxx_works=no])
	AC_LANG_POP([C++])])
])

# Put all our automake definitions in config.h
AM_CONFIG_HEADER([config.h])

# Checks for C and C++ compilers
AC_PROG_CC
AC_PROG_CXX
rw_PROG_CXX_WORKS

if test "$rw_cv_prog_cxx_works" = "no"; then
	AC_MSG_ERROR("Failed to find working C++ compiler")
fi

# Checking for 'install'
AC_PROG_INSTALL

# Checking for bison and flex
AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc) 
AM_PROG_LEX

# All our source files for function replacements are in lib/
AC_CONFIG_LIBOBJ_DIR(lib)

# Check for various "replacement" functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC

# *BSD doesn't have strndup. Currently provide our own.
AC_REPLACE_FUNCS(strndup)


# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_SYS_LARGEFILE

LIBPKTDUMP_LIBS="-ltrace "
ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/libwandio -L\$(abs_top_srcdir)/lib" 
LIBTRACE_LIBS="-lwandio"
TOOLS_LIBS=""
LIBWANDIO_LIBS=""

CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1"

# Check for -fvisibility
gl_VISIBILITY

gcc_PACKED
gcc_DEPRECATED
gcc_UNUSED
gcc_PURE
gcc_FORMAT
	
# Check for libtool
AC_PROG_LIBTOOL

# Checks for library functions.
AC_PROG_GCC_TRADITIONAL

# Fail if any of these functions are missing
AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf)

AC_CHECK_SIZEOF([long int])


# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(pcap.h pcap-int.h pcap-bpf.h net/bpf.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h sys/prctl.h)


# OpenSolaris puts ncurses.h in /usr/include/ncurses rather than /usr/include,
# so check for that
AC_CHECK_HEADERS(ncurses.h,,[missing_ncurses=true])

if test "x$missing_ncurses" = xtrue; then
	if test -f "/usr/include/ncurses/ncurses.h"; then
		AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Has nested ncurses header])
	fi
fi


# Check for the presence of various networking headers and define appropriate
# macros
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netpacket/packet.h,[
	libtrace_netpacket_packet_h=true
	AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net])
])
AC_CHECK_HEADER(net/if.h,
	AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[
 #include <sys/types.h>
 #include <sys/socket.h>
])

AC_CHECK_HEADER(netinet/ether.h,
	AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <net/if.h>
])

AC_CHECK_HEADER(netinet/if_ether.h,
	AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <net/if.h>
])

AC_CHECK_HEADER(net/if_arp.h,
	AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <net/if.h>
])

# Check for sdl_len in sockaddr_dl - sockaddr_dl is used on BSD systems
if test "$libtrace_netpacket_packet_h" != "true"; then
	AC_CHECK_MEMBER([struct sockaddr_dl.sdl_len], 
		AC_DEFINE(HAVE_SDL_LEN,1,[Has sdl_len in sockaddr_dl]),,[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <net/if_dl.h>
		])
fi

# Checking for the right bpf header to include
AC_CHECK_HEADER(pcap-bpf.h)
AC_CHECK_HEADER(net/bpf.h)

# Checking for libgdc
AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))

# Check for libpcap
AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
AC_CHECK_LIB(pcap,pcap_create,pcapcreate=1,pcapcreate=0)
AC_CHECK_DECLS([BIOCSETIF],,,[
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <net/bpf.h>
])

# Configure options for man pages
AC_ARG_WITH(man,
	    AS_HELP_STRING(--with-man,install man pages by default),[
	     if test "$withval" = yes
	     then
		     MANPAGES="docs/man/man3/[a-zA-Z]*.3"
	     else
		     MANPAGES=""
	     fi
])

# Complain if we didn't find a suitable libpcap
if test "$pcapfound" = 0; then
	AC_MSG_ERROR(libpcap0.8 or greater is required to compile libtrace. If you have installed it in a non-standard location please use LDFLAGS to specify the location of the library)
else
	TOOL_LIBS="$TOOL_LIBS -lpcap"
	LIBTRACE_LIBS="$LIBTRACE_LIBS -lpcap"
	AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
	AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support])

	LIBS="-lpcap"
	AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
	LIBS=""

fi

if test "$pcapcreate" = 1; then
	AC_DEFINE([HAVE_PCAP_CREATE],1,[compile with libpcap 1.0 support])
fi

# Configure options for use of DAG cards
# Originally borrowed from libpcap, but extended quite a bit :)
# More details on how this check works: 
#	http://wand.net.nz/trac/libtrace/wiki/DAGNotes

AC_ARG_WITH(dag, 
	    AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
[
        if test "$withval" = no
        then
                want_dag=no
        elif test "$withval" = yes
        then
                want_dag=yes
                dag_root=/usr/local/dag
        else
                want_dag=yes
                dag_root=$withval
        fi
],[
        #
        # Use DAG API if present, otherwise don't
        #
        want_dag=ifpresent
        dag_root=/usr/local/dag
])

# DAG 3.0 actually puts header files and shared libraries into sensible
# places now, so we should be able to do a simple CHECK_LIB to see if
# they're there!

# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
# DAG 3.0 and libtrace will use the same format_dagXX source for both
libtrace_dag=false
libtrace_dag_version=none

if test "$with_dag" != no; then
	AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
	if test "$dag_found" = 1; then
		ADD_LIBS="$ADD_LIBS -ldag"
		LIBTRACE_LIBS="$LIBTRACE_LIBS -ldag"
		AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
		AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
		libtrace_dag=true
		
		AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
		libtrace_dag_version=25
	fi
fi

# TODO: turn the test part of the next block into a function, so it can be 
# called multiple times for $dag_root, /root/dag, /usr/local/lib
dag_drv_v="DAG not present"

# Now check for 2.4 DAG drivers which don't install as cleanly!
if test "$with_dag" != no -a "$libtrace_dag" = false; then
        AC_MSG_CHECKING(whether we have DAG 2.4 API instead)

	if test -r "$dag_root/lib"; then
		dag_lib_dir="$dag_root/lib"
	else
		dag_lib_dir="$dag_root"
	fi
	
	if test -r "$dag_root/include"; then
		dag_tools_dir="$dag_root/tools"
                dag_include_dir="$dag_root/include"
        else
                dag_tools_dir="$dag_root"
                dag_include_dir="$dag_root"
	fi

        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; 
	then
                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
		ADD_LIBS="$ADD_LIBS -ldag"
		ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
		DAG_TOOLS_DIR=$dag_tools_dir
		AC_SUBST([DAG_TOOLS_DIR])
                libtrace_dag=true
                
		AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
		AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
		AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
		libtrace_dag_version=24
        else
                if test "$want_dag" = yes; then
                        AC_MSG_ERROR(DAG API not found under directory $dag_root
; use --without-dag)
                fi
                libtrace_dag=false
        fi
        AC_MSG_RESULT($libtrace_dag)

fi

# Try to determine the DAG driver version
#if test x"$libtrace_dag" = xtrue; then
#       dag_drv_v="Unknown"
#	files=`locate /usr/*dag*/VERSION`
#       file_count=0
#
#       for i in $files; do
#                if $file_count > 0; then
#                        dag_drv_v="Indeterminate"
#                        break
#                fi
#                dag_drv_v=`cat $i`
#                file_count=$file_count+1
#        done
#fi
#DAG_VERSION_NUM=$dag_drv_v

# Check for DPDK 
AC_ARG_WITH(dpdk,
	    AS_HELP_STRING(--with-dpdk,include DPDK live capture support (Must set RTE_SDK/_TARGET environment variable)),
[
        if test "$withval" = no
        then
            want_dpdk=no
        else
            want_dpdk=ifpresent
        fi
],[
        # Default to building without DPDK format
        want_dpdk=no
])

libtrace_dpdk=false
if test "$want_dpdk" != no; then
    saved_ldflags="$LDFLAGS"
    # Add to our libpath location
    LDFLAGS="$LDFLAGS -L$RTE_SDK/$RTE_TARGET/lib/"
    # Test that the library exists, we cannot be sure of what extra library flags need to be added
    # this could change in the next version which would make the test fail
    #AC_CHECK_LIB(intel_dpdk, rte_eal_init, dpdk_found=1, dpdk_found=0, -lpthread -lm -lrt)

    # So instead simply check for existence
    AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found=1, dpdk_found=0)
    # Revert back
    LDFLAGS="$saved_ldflags"
    if test "$dpdk_found" = 1; then
        # Save these now so that they can be re-exported later
		AC_SUBST([RTE_TARGET])
        AC_SUBST([RTE_SDK])
        # Force dpdk library to be statically linked to allow compiler optimisations
        LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l:libintel_dpdk.a -Wl,--no-whole-archive -Wl,-lm"
		AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support])
		libtrace_dpdk=true
	fi
fi

# Checks for various "optional" libraries
AC_CHECK_LIB(pthread, pthread_create, have_pthread=1, have_pthread=0)

# Check for ncurses

# These libraries have to be explicitly linked in OpenSolaris
AC_SEARCH_LIBS(getservent, socket, have_socket=1, have_socket=0, -lnsl)
LIBS=

AC_SEARCH_LIBS(inet_ntop, nsl, have_nsl=1, have_nsl=0, -lsocket)
LIBS=

# Check to see if we have libdl - *BSD has built-in libdl
AC_SEARCH_LIBS(dlopen,dl, dlfound=1,dlfound=0 )
LIBS=

# Check for clock_gettime
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=1, have_clock_gettime=0)
LIBS=

if test "$dlfound" = 0; then
	AC_MSG_ERROR("Unable to find dlopen. Please use LDFLAGS to specify the location of libdl and re-run configure")
fi

if test "$ac_cv_search_dlopen" != "none required"; then 
	LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen"
fi

if test "$have_pthread" = 1; then
	LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lpthread"
	AC_DEFINE(HAVE_LIBPTHREAD, 1, [Set to 1 if pthreads are supported])
fi


if test "$have_nsl" = 1; then
	if test "$ac_cv_search_inet_ntop" != "none required"; then
		LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_inet_ntop"
		LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_inet_ntop"
	fi
fi

if test "$have_socket" = 1; then
	if test "$ac_cv_search_getservent" != "none required"; then
		LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_getservent"
		LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_getservent"
	fi 
fi


if test "$have_clock_gettime" = 1; then
    LIBTRACE_LIBS="$LIBTRACE_LIBS -lrt"
fi


# Stupid AC_SEARCH_LIB appends stuff to LIBS even when I don't want it to, so
# just set libs to null here to avoid linking against them by default
LIBS=

# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
# rough around the edges :(
AC_ARG_WITH([llvm],
	[AC_HELP_STRING([--with-llvm],
		[support Just In Time compiler])],
	use_llvm="yes",
	use_llvm="no")
JIT=no

# Search for LLVM and the libraries that it requires
if (test "$use_llvm" != "no"); then
	AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)

	# XXX Hard coding the path is REALLY bad.
	# llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
	# if you've installed it somewhere custom.
	# Hopefully in future we can replace this with clang, which may or may
	# not be installed somewhere intelligent.
	AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)

	AC_LANG_PUSH([C++])
	AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
	AC_LANG_POP([C++])

		
	if test "$boost" = "no"; then
		AC_MSG_NOTICE([Unabled to find boost libraries.  JIT support disabled.])
		JIT=no
	elif test "$LLVM_CONFIG" = "no" ; then
		AC_MSG_NOTICE([Unable to find llvm-config.  JIT support disabled.])
		JIT=no
	elif test "$LLVM_GCC" = "no"; then
		AC_MSG_NOTICE([Unable to find llvm-gcc.  JIT support disabled.])
		JIT=no
	else
		LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
		LIBTRACE_LIBS="$LIBRACE_LIBS `$LLVM_CONFIG --libs all`";
		LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
		JIT=yes
		AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
	fi
fi

AC_ARG_WITH([ncurses],
	AC_HELP_STRING([--with-ncurses], [build tracetop (requires ncurses)]))

AS_IF([test "x$with_ncurses" != "xno"],
	[AC_SEARCH_LIBS(mvprintw, ncurses, have_ncurses=yes, have_ncurses=no)
	 LIBS=
	], [have_ncurses=no])

AS_IF([test "x$have_ncurses" = "xyes"], [
	if test "$ac_cv_search_mvprintw" != "none required"; then
		TOOLS_LIBS="$TOOLS_LIBS $ac_cv_search_mvprintw"
	fi
	AC_DEFINE(HAVE_NCURSES, 1, "Compiled with ncurses support")
	with_ncurses=yes],

	
	[AS_IF([test "x$with_ncurses" = "xyes"],
		[AC_MSG_ERROR([ncurses requested but not found])])
	AC_DEFINE(HAVE_NCURSES, 0, "Compiled with ncurses support")
	with_ncurses=no]
)
			
AC_ARG_WITH([bzip2],
	AC_HELP_STRING([--with-bzip2], [build with support for bzip2 compressed files]))

AS_IF([test "x$with_bzip2" != "xno"],
	[
	AC_CHECK_LIB(bz2, BZ2_bzDecompressInit, have_bzip=yes, have_bzip=no)
	], [have_bzip=no])

AS_IF([test "x$have_bzip" = "xyes"], [
	if test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" != "none required"; then
		LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lbz2"
	fi
	with_bzip2=yes
	AC_DEFINE(HAVE_LIBBZ2, 1, "Compiled with bzip2 support")],
	
	[AS_IF([test "x$with_bzip2" = "xyes"],
		[AC_MSG_ERROR([bzip2 requested but not found])])
	AC_DEFINE(HAVE_LIBBZ2, 0, "Compiled with bzip2 support")
	with_bzip2=no]
)

AC_ARG_WITH([zlib],
	AC_HELP_STRING([--with-zlib], [build with support for zlib compressed files]))

AS_IF([test "x$with_zlib" != "xno"],
	[
	AC_CHECK_LIB(z, deflate, have_zlib=yes, have_zlib=no)
	], [have_zlib=no])

AS_IF([test "x$have_zlib" = "xyes"], [
	if test "$ac_cv_lib_z_deflate" != "none required"; then
		LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lz"
	fi
	AC_DEFINE(HAVE_LIBZ, 1, "Compiled with zlib support")
	with_zlib=yes],

	
	[AS_IF([test "x$with_zlib" = "xyes"],
		[AC_MSG_ERROR([zlib requested but not found])])
	AC_DEFINE(HAVE_LIBZ, 0, "Compiled with zlib support")
	with_zlib=no]
)

AC_ARG_WITH([lzo],
	AC_HELP_STRING([--with-lzo], [build with support for writing lzo compressed files]))

AS_IF([test "x$with_lzo" != "xno"],
	[
	AC_CHECK_LIB(lzo2, lzo1x_1_compress, have_lzo=yes, have_lzo=no)
	], [have_lzo=no])

AS_IF([test "x$have_lzo" = "xyes"], [
	if test "$ac_cv_lib_lzo2_lzo1x_1_compress" != "none required"; then
		LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzo2"
	fi
	AC_DEFINE(HAVE_LIBLZO2, 1, "Compiled with lzo2 support")
	with_lzo=yes],

	
	[AS_IF([test "x$with_lzo" = "xyes"],
		[AC_MSG_ERROR([lzo requested but not found])])
	AC_DEFINE(HAVE_LIBLZO2, 0, "Compiled with lzo2 support")
	with_lzo=no]
)

AC_ARG_WITH([lzma],
	AC_HELP_STRING([--with-lzma], [build with support for lzma compressed files]))

AS_IF([test "x$with_lzma" != "xno"],
	[
	AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no)
	], [have_lzma=no])

AS_IF([test "x$have_lzma" = "xyes"], [
	if test "$ac_cv_lib_lzma_code" != "none required"; then
		LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzma"
	fi
	AC_DEFINE(HAVE_LIBLZMA, 1, "Compiled with lzma support")
	with_lzma=yes],

	
	[AS_IF([test "x$with_lzma" = "xyes"],
		[AC_MSG_ERROR([lzma requested but not found])])
	AC_DEFINE(HAVE_LIBLZMA, 0, "Compiled with lzma support")
	with_lzma=no]
)

# Define automake conditionals for use in our Makefile.am files
AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
AM_CONDITIONAL([HAVE_DPDK], [test "$libtrace_dpdk" = true])
AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
AM_CONDITIONAL([HAVE_NCURSES], [test "x$with_ncurses" != "xno"])
AM_CONDITIONAL([HAVE_BZLIB], [test "x$with_bzip2" != "xno"])
AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"])
AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"])
AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"])

# Check for miscellaneous programs
AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])

AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])

# Set all our output variables
AC_SUBST([LIBTRACE_LIBS])
AC_SUBST([LIBPKTDUMP_LIBS])
AC_SUBST([LIBWANDIO_LIBS])
AC_SUBST([TOOLS_LIBS])
#AC_SUBST([ADD_LIBS])
AC_SUBST([ADD_LDFLAGS])
AC_SUBST([ADD_INCLS])
AC_SUBST([LTLIBOBJS])
AC_SUBST([MANPAGES])
AC_SUBST([PACKAGE_VERSION])
AC_SUBST([LIBTRACE_MAJOR])
AC_SUBST([LIBTRACE_MID])
AC_SUBST([LIBTRACE_MINOR])
AC_SUBST([DAG_VERSION_NUM])
AC_SUBST([HAVE_BPF_CAPTURE])
AC_SUBST([HAVE_LIBGDC])
AC_SUBST([HAVE_LLVM])
AC_SUBST([HAVE_NCURSES])
AC_SUBST([LIBCFLAGS])
AC_SUBST([LIBCXXFLAGS])


# Finally, output our Makefiles
AC_OUTPUT

# Function for reporting whether an option was set or not
reportopt() {
	if test x"$2" = xtrue -o x"$2" = xyes; then
		AC_MSG_NOTICE([$1: Yes])
	else 
		AC_MSG_NOTICE([$1: No])
	fi
}


# Report which configure options were set
echo
AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
if test "$pcapcreate" = 1; then
	AC_MSG_NOTICE([Compiled with PCAP support: >= 1.0])
else
	AC_MSG_NOTICE([Compiled with PCAP support: < 1.0])
fi

reportopt "Compiled with compressed trace (zlib) support" $with_zlib
reportopt "Compiled with compressed trace (bz2) support" $with_bzip2
reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo
reportopt "Compiled with compressed trace (lzma) support" $with_lzma
if test x"$libtrace_dag" = xtrue; then
	if test "$libtrace_dag_version" = 24; then
		AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
	elif test "$libtrace_dag_version" = 30; then
		AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
	else
		AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
	fi	
else
	AC_MSG_NOTICE([Compiled with DAG live capture support: No])
fi

if test x"$libtrace_dpdk" = xtrue; then
    AC_MSG_NOTICE([Compiled with DPDK live capture support: Yes])
elif test x"$want_dpdk" != "xno"; then
#   We don't officially support DPDK so only report failure if the user
#   explicitly asked for DPDK. That way, we can hopefully keep it hidden
#   from most users for now...
	
    AC_MSG_NOTICE([Compiled with DPDK live capture support: No])
    AC_MSG_NOTICE([Note: Requires DPDK v1.5 or newer])
fi
reportopt "Compiled with LLVM BPF JIT support" $JIT
reportopt "Building man pages/documentation" $libtrace_doxygen
reportopt "Building tracetop (requires libncurses)" $with_ncurses

# Report any errors relating to missing bison, flex, etc.
echo 
ac_cv_errcount=0;
if test -z "$YACC"; then
	AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
	ac_cv_errcount=$((ac_cv_errcount + 1))
fi

if test "x$LEX" != xflex -a "x$LEX" != xlex; then
	AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
	ac_cv_errcount=$((ac_cv_errcount + 1))
fi

if test $ac_cv_errcount -gt 0; then
	AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
fi