lc-configure.in 20.5 KB
Newer Older
1
dnl -*- mode: shell-script -*-
eddietwo's avatar
eddietwo committed
2
dnl Process this file with autoconf to produce a configure script.
eddietwo's avatar
eddietwo committed
3 4 5 6 7 8 9 10 11 12 13
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, subject to the conditions
dnl listed in the Click LICENSE file. These conditions include: you must
dnl preserve this copyright notice, and you cannot mention the copyright
dnl holders in advertising related to the Software without their permission.
dnl The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
dnl notice is a summary of the Click LICENSE file; the license in that file is
dnl legally binding.

Eddie Kohler's avatar
Eddie Kohler committed
14
AC_INIT([libclick], [1.8.0])
15
AC_PREREQ(2.60)
16
AC_CONFIG_HEADER(include/click/config.h:config.h.in include/click/pathvars.h:pathvars.h.in include/click/config-userlevel.h:config-userlevel.h.in)
eddietwo's avatar
eddietwo committed
17

18
CLICK_VERSION=$PACKAGE_VERSION
eddietwo's avatar
eddietwo committed
19 20

AC_SUBST(ac_configure_args)
21
AC_DEFINE_UNQUOTED([CLICK_VERSION], ["$CLICK_VERSION"])
eddietwo's avatar
eddietwo committed
22 23
AC_SUBST(CLICK_VERSION)

24 25
CLICK_INIT('$(top_srcdir)')

eddietwo's avatar
eddietwo committed
26 27 28 29 30 31 32
dnl support for cross compiling
AC_CANONICAL_SYSTEM

dnl This is wrong!!
AC_CHECK_TOOL(CC, gcc)
AC_CHECK_TOOL(CXX, g++)

33
CLICK_PROG_CC
eddietwo's avatar
eddietwo committed
34
AC_PROG_CPP
eddietwo's avatar
eddietwo committed
35
AC_C_INLINE
eddietwo's avatar
eddietwo committed
36

37
CLICK_PROG_CXX
eddietwo's avatar
eddietwo committed
38 39
AC_PROG_CXXCPP

40
ac_preset_ar="$AR"
eddietwo's avatar
eddietwo committed
41 42 43 44 45
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(LD, ld)
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(STRIP, strip, :)

46 47
conf_auxdir='$(top_srcdir)'
AC_SUBST(conf_auxdir)
eddietwo's avatar
eddietwo committed
48

eddietwo's avatar
eddietwo committed
49
test -z "$AR_CREATEFLAGS" && AR_CREATEFLAGS=cru
50
AC_SUBST(AR_CREATEFLAGS)
51

52

53 54 55
dnl userlevel driver and features

AC_ARG_ENABLE(user-multithread, [[    --enable-user-multithread support userlevel multithreading (EXPERIMENTAL)]], :, [enable_user_multithread=no])
56 57 58 59

PTHREAD_LIBS=""
AC_SUBST(PTHREAD_LIBS)

60
if test "x$enable_user_multithread" = xyes; then
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    SAVE_LIBS="$LIBS"
    AC_SEARCH_LIBS([pthread_create], [pthread], [ac_have_libpthread=yes], [ac_have_libpthread=no])
    AC_CHECK_HEADERS([pthread.h], [ac_have_pthread_h=yes], [ac_have_pthread_h=no])
    if test "$ac_have_libpthread$ac_have_pthread_h" = yesyes; then
	AC_DEFINE(HAVE_USER_MULTITHREAD)
	if echo "$LIBS" | grep -e -lpthread >/dev/null 2>&1; then
	    PTHREAD_LIBS="-lpthread"
	fi
    else
	AC_MSG_ERROR([
=========================================

Can't find -lpthread and/or <pthread.h>, so I can't compile with
--enable-user-multithread.

=========================================])
    fi
    LIBS="$SAVE_LIBS"
79 80
fi

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
AC_ARG_ENABLE(select, [    --enable-select=[[select|poll|kqueue]] set select() mechanism], :, enable_select=)

if test "$enable_select" = select; then
    AC_DEFINE([HAVE_USE_SELECT], [1], [Define if select() should be used to wait for file descriptor events.])
elif test "$enable_select" = poll; then
    AC_DEFINE([HAVE_USE_POLL], [1], [Define if poll() should be used to wait for file descriptor events.])
elif test "$enable_select" = kqueue; then
    AC_DEFINE([HAVE_USE_KQUEUE], [1], [Define if kqueue() should be used to wait for file descriptor events.])
elif test -n "$enable_select"; then
    AC_MSG_WARN([
=========================================

Unexpected --enable-select type ignored.

=========================================])
fi

98

eddietwo's avatar
eddietwo committed
99 100 101 102 103 104 105 106 107 108 109 110
dnl
dnl element collections
dnl

AC_ARG_ENABLE(all-elements, [  --enable-all-elements   include all provided element groups])

dnl ELEMENTS_ARG_ENABLE(COLLECTION, HELP-STRING, DEFAULT-VALUE)
element_groups=""
AC_SUBST(element_groups)
AC_DEFUN([ELEMENTS_ARG_ENABLE],
[AC_ARG_ENABLE($1, [  --]builtin(substr, builtin(ifelse, [$3], yes, dis, en)[able-$1              ], 0, 21)[ ]builtin(ifelse, [$3], yes, [do not ], [])[$2], ,
[enable_]patsubst([$1], -, _)=$3)dnl
111
test "x$enable_all_elements" = xyes -a \( ["x$enable_]patsubst([$1], -, _)["] = xNO -o ["x$enable_]patsubst([$1], -, _)["] = x \) && [enable_]patsubst([$1], -, _)[=yes]
eddietwo's avatar
eddietwo committed
112 113 114 115 116
if test ["x$enable_]patsubst([$1], -, _)["] = xyes; then
    :
    $4
fi])

117 118 119
ELEMENTS_ARG_ENABLE(ip6, [include IPv6 elements (EXPERIMENTAL)], NO, AC_DEFINE(HAVE_IP6))
ELEMENTS_ARG_ENABLE(ipsec, [include IP security elements], NO, AC_DEFINE(HAVE_IPSEC))
AC_ARG_ENABLE(experimental, [  --enable-experimental   enable experimental elements in normal groups], :, enable_experimental=no)
eddietwo's avatar
eddietwo committed
120 121


122 123 124 125
dnl
dnl check whether target is Linux
dnl

126 127
AC_CACHE_CHECK([whether we are compiling for Linux], [ac_cv_under_linux],
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __linux__
eddietwo's avatar
eddietwo committed
128 129
#error "fuckers! fuckers!"
#endif
130
return 0;]])], ac_cv_under_linux=yes, ac_cv_under_linux=no)])
eddietwo's avatar
eddietwo committed
131

132

eddietwo's avatar
eddietwo committed
133 134 135 136
dnl
dnl functions
dnl

137
AC_LANG_C
eddietwo's avatar
eddietwo committed
138
AC_REPLACE_FUNCS(strerror)
139
AC_CHECK_FUNCS(random snprintf strnlen strtoul tcgetpgrp vsnprintf)
140
AC_LANG_CPLUSPLUS
eddietwo's avatar
eddietwo committed
141

142

eddietwo's avatar
eddietwo committed
143
dnl
144
dnl integer types, endianness, int64, addressable va_list
eddietwo's avatar
eddietwo committed
145 146 147 148
dnl

AC_ARG_ENABLE(int64, [  --disable-int64         disable 64-bit integer support], :, enable_int64=yes)

eddietwo's avatar
eddietwo committed
149 150
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
151
AC_CHECK_SIZEOF(size_t)
152
AC_CHECK_SIZEOF([void *])
153
CLICK_CHECK_INTEGER_TYPES
154
CLICK_CHECK_ALIGNMENT
eddietwo's avatar
eddietwo committed
155
if test "x$enable_int64" = xyes; then
156
    AC_CHECK_SIZEOF(long long)
157
    CLICK_CHECK_INT64_TYPES
eddietwo's avatar
eddietwo committed
158
fi
159
CLICK_CHECK_ENDIAN
160
CLICK_CHECK_SIGNED_SHIFT
161
CLICK_CHECK_ADDRESSABLE_VA_LIST
162
CLICK_CHECK_COMPILER_INTRINSICS
eddietwo's avatar
eddietwo committed
163

164

165
dnl
166
dnl timestamps
167 168
dnl

169 170 171 172 173 174 175 176
AC_CHECK_HEADERS(time.h)
AC_CHECK_SIZEOF([struct timeval])
AC_CHECK_TYPES([struct timespec], have_timespec=yes, have_timespec=no)
if test "x$have_timespec" = xyes; then
    AC_CHECK_SIZEOF([struct timespec])
fi
CLICK_CHECK_POSIX_CLOCKS

177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
AC_ARG_ENABLE(nanotimestamp, [  --enable-nanotimestamp  enable nanosecond timestamps])
# Default to nanosecond-precision timestamps if clock_gettime is available.
if test "x$enable_nanotimestamp" = x -a "x$have_clock_gettime" = xyes; then
    enable_nanotimestamp=yes
fi
if test "x$enable_nanotimestamp" = xyes; then
    AC_DEFINE([HAVE_NANOTIMESTAMP_ENABLED], [1], [Define if nanosecond-granularity timestamps are enabled.])
fi


dnl
dnl check forms of port transfer
dnl

AC_ARG_ENABLE(bound-port-transfer,
  [[  --enable-bound-port-transfer  enable port transfer function ptr optimization]],
  :, enable_bound_port_transfer=no)

if test "$enable_bound_port_transfer" = yes; then
  AC_DEFINE([HAVE_BOUND_PORT_TRANSFER], [1], [Define if Port::push/Port::pull should use bound function pointers.])
  CXXFLAGS="$CXXFLAGS -Wno-pmf-conversions"
fi

200

eddietwo's avatar
eddietwo committed
201
dnl
202
dnl headers, event detection, dynamic linking
eddietwo's avatar
eddietwo committed
203 204
dnl

205
AC_CHECK_HEADERS(termio.h netdb.h sys/event.h pwd.h grp.h execinfo.h)
206
CLICK_CHECK_POLL_H
207
AC_CHECK_FUNCS(pselect sigaction)
eddietwo's avatar
eddietwo committed
208 209 210 211 212 213 214 215 216 217 218 219

AC_CHECK_FUNCS(kqueue, have_kqueue=yes)
if test "x$have_kqueue" = xyes; then
    AC_CACHE_CHECK([whether EV_SET last argument is void *], [ac_cv_ev_set_udata_pointer],
	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>]], [[struct kevent kev; EV_SET(&kev, 1, EVFILT_WRITE, EV_ADD, 0, 0, (void *) &kev);]])], [ac_cv_ev_set_udata_pointer=yes], [ac_cv_ev_set_udata_pointer=no])])
    if test $ac_cv_ev_set_udata_pointer = yes; then
	AC_DEFINE([HAVE_EV_SET_UDATA_POINTER], [1], [Define if the last argument to EV_SET has pointer type.])
    fi
fi

220
AC_ARG_ENABLE(dynamic-linking, [  --disable-dynamic-linking disable dynamic linking], :, enable_dynamic_linking=yes)
eddietwo's avatar
eddietwo committed
221 222 223 224

if test "x$enable_dynamic_linking" = xyes; then
    CLICK_CHECK_DYNAMIC_LINKING
fi
eddietwo's avatar
eddietwo committed
225 226 227 228 229 230


dnl
dnl sockets
dnl

231
AC_LANG_C
eddietwo's avatar
eddietwo committed
232
SOCKET_LIBS=
233
dnl if test "$enable_userlevel" = yes; then
234 235
    savelibs="$LIBS"; LIBS=
    AC_SEARCH_LIBS(gethostbyname, nsl, , , $savelibs)
236
    AC_SEARCH_LIBS(connect, socket, , , $savelibs)
237
    SOCKET_LIBS="$LIBS"; LIBS="$savelibs"
eddietwo's avatar
eddietwo committed
238 239 240 241 242 243 244 245 246

    AC_CACHE_CHECK([whether accept() uses socklen_t], [ac_cv_accept_socklen_t],
	    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/socket.h>
]], [[socklen_t sl; (void) accept(0, (struct sockaddr *) 0, &sl);]])],
	ac_cv_accept_socklen_t=yes, ac_cv_accept_socklen_t=no)])
    if test "$ac_cv_accept_socklen_t" = yes; then
	AC_DEFINE([HAVE_ACCEPT_SOCKLEN_T], [1], [Define if accept() uses socklen_t.])
    fi
247
dnl fi
eddietwo's avatar
eddietwo committed
248
AC_SUBST(SOCKET_LIBS)
249
AC_LANG_CPLUSPLUS
eddietwo's avatar
eddietwo committed
250

251

eddietwo's avatar
eddietwo committed
252 253 254 255 256 257 258
dnl
dnl large file support
dnl

CLICK_CHECK_LARGE_FILE_SUPPORT


eddietwo's avatar
eddietwo committed
259 260 261 262 263
dnl
dnl mmap
dnl

AC_LANG_C
264
AC_CHECK_HEADERS(sys/mman.h)
eddietwo's avatar
eddietwo committed
265 266
AC_FUNC_MMAP
AC_LANG_CPLUSPLUS
267
AC_CHECK_FUNCS(madvise)
268 269 270 271
AC_CHECK_DECLS(madvise, [], [], [#if HAVE_SYS_MMAN_H
#include <sys/types.h>
#include <sys/mman.h>
#endif])
eddietwo's avatar
eddietwo committed
272

273

eddietwo's avatar
eddietwo committed
274
dnl
eddietwo's avatar
eddietwo committed
275
dnl kernel features
eddietwo's avatar
eddietwo committed
276 277
dnl

eddietwo's avatar
eddietwo committed
278
    AC_DEFINE_UNQUOTED(NUM_CLICK_CPUS, 1)
eddietwo's avatar
eddietwo committed
279

280

eddietwo's avatar
eddietwo committed
281 282 283 284 285 286 287
dnl
dnl objects required by element collections
dnl

EXTRA_DRIVER_OBJS=
EXTRA_TOOL_OBJS=
if test "x$enable_ip6" = xyes; then
288 289
    EXTRA_DRIVER_OBJS="ip6address.o ip6flowid.o ip6table.o $EXTRA_DRIVER_OBJS"
    EXTRA_TOOL_OBJS="ip6address.o $EXTRA_TOOL_OBJS"
eddietwo's avatar
eddietwo committed
290 291 292 293 294 295
fi
AC_SUBST(EXTRA_DRIVER_OBJS)
AC_SUBST(EXTRA_TOOL_OBJS)


dnl
296
dnl more features
eddietwo's avatar
eddietwo committed
297 298
dnl

299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
dnl statistics

AC_ARG_ENABLE(stats, [[  --enable-stats[=LEVEL]  enable statistics collection]], :, enable_stats=no)
if test "$enable_stats" = no; then enable_stats=0; fi
if test "$enable_stats" = yes; then enable_stats=1; fi
if test "$enable_stats" -ge 0 > /dev/null 2>&1; then
    AC_DEFINE_UNQUOTED([CLICK_STATS], $enable_stats)
else
    AC_MSG_ERROR([
=========================================

--enable-stats takes an integer, "yes", or "no".

=========================================])
fi

dnl type of scheduling

eddietwo's avatar
eddietwo committed
317 318
AC_ARG_ENABLE(stride, [  --disable-stride        disable stride scheduler], :, enable_stride=yes)
if test $enable_stride = yes; then
319 320
    AC_DEFINE(HAVE_STRIDE_SCHED)
fi
eddietwo's avatar
eddietwo committed
321 322

AC_ARG_ENABLE(task-heap, [  --enable-task-heap      use heap for task list], :, enable_task_heap=no)
323
if test $enable_task_heap = yes -a $enable_stride = yes; then
eddietwo's avatar
eddietwo committed
324
    AC_DEFINE(HAVE_TASK_HEAP)
325 326 327 328 329 330 331
elif test $enable_task_heap = yes; then
	AC_MSG_WARN([
=========================================

Ignoring --enable-task-heap, which is incompatible with --disable-stride.

=========================================])
eddietwo's avatar
eddietwo committed
332
fi
333

eddietwo's avatar
eddietwo committed
334 335 336 337 338

dnl debugging malloc

AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        enable debugging malloc], :, enable_dmalloc=no)
if test $enable_dmalloc = yes; then
339
    AC_DEFINE(CLICK_DMALLOC)
eddietwo's avatar
eddietwo committed
340 341 342
fi


343 344 345 346 347 348 349 350 351 352 353 354 355
dnl valgrind debugging support

AC_ARG_ENABLE(valgrind, [  --enable-valgrind       extra support for debugging with valgrind], :, enable_valgrind=no)
if test $enable_valgrind = yes; then
    AC_CHECK_HEADERS(valgrind/memcheck.h, ac_found_valgrind_memcheck_h=yes, ac_found_valgrind_memcheck_h=no)
    if test $ac_found_valgrind_memcheck_h = no; then
	AC_MSG_ERROR([
=========================================

Can't find Valgrind header file 'valgrind/memcheck.h'.
Try again without '--enable-valgrind'.

=========================================])
356
	dnl ' fix syntax highlighting
357 358 359 360 361
    fi
    AC_DEFINE(HAVE_VALGRIND)
fi


362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
dnl Click debugging support

AC_ARG_ENABLE(schedule-debugging, [[  --enable-schedule-debugging[=WHAT] enable Click scheduler debugging
                          (no/yes/extra) [yes]]], :, enable_schedule_debugging=no)
value=0
if test "$enable_schedule_debugging" = yes; then
    value=1
elif test "$enable_schedule_debugging" = extra; then
    value=2
fi
if test "$value" != 0; then
    AC_DEFINE_UNQUOTED([CLICK_DEBUG_SCHEDULING], [$value], [Define to enable debugging support for Click scheduling.])
fi


eddietwo's avatar
eddietwo committed
377 378 379 380 381 382 383 384
dnl use Intel-specific machine instructions

AC_ARG_ENABLE(intel-cpu, [  --enable-intel-cpu      enable Intel-specific machine instructions], :, enable_intel_cpu=no)
if test $enable_intel_cpu = yes; then
    AC_DEFINE(HAVE_INTEL_CPU)
fi


385 386 387
dnl pcap library
dnl note: no longer need pcap under Linux

eddietwo's avatar
eddietwo committed
388 389
dnl if test "$enable_userlevel" = yes; then
    CLICK_CHECK_LIBPCAP
390 391 392 393 394 395 396 397 398 399
    if test "$HAVE_PCAP" != yes -a "$ac_cv_under_linux" != yes; then
	AC_MSG_WARN([
=========================================

pcap.h and/or -lpcap not found; user-level driver can't steal packets.

=========================================])
	dnl ' fix syntax highlighting
    fi
    DRIVERS="$DRIVERS userlevel"
eddietwo's avatar
eddietwo committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
    AC_DEFINE(HAVE_USERLEVEL_DRIVER)
    HAVE_USERLEVEL_DRIVER=1
dnl fi


dnl other user-level specifics

AC_CACHE_CHECK([whether struct if_data has ifi_datalen], [ac_cv_if_data_ifi_datalen],
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <net/if.h>
#include <net/if_var.h>
]], [[struct if_msghdr ifm; ifm.ifm_data.ifi_datalen = 0;]])], ac_cv_if_data_ifi_datalen=yes, ac_cv_if_data_ifi_datalen=no)])
if test "x$ac_cv_if_data_ifi_datalen" = xyes; then
    AC_DEFINE([HAVE_IF_DATA_IFI_DATALEN], [1], [Define if 'struct if_data' has an 'ifi_datalen' member.])
fi

AC_CACHE_CHECK([whether struct sockaddr_in has sin_len], [ac_cv_sockaddr_in_sin_len],
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>
#include <netinet/in.h>
]], [[struct sockaddr_in sin; sin.sin_len = 0;]])], ac_cv_sockaddr_in_sin_len=yes, ac_cv_sockaddr_in_sin_len=no)])
if test "x$ac_cv_sockaddr_in_sin_len" = xyes; then
    AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN], [1], [Define if 'struct sockaddr_in' has a 'sin_len' member.])
fi
422

423 424 425 426 427 428 429
AC_CACHE_CHECK([offset of ifr_addr in struct ifreq], [ac_cv_offsetof_ifr_addr_ifreq],
    [AC_COMPUTE_INT([ac_cv_offsetof_ifr_addr_ifreq], [offsetof(struct ifreq, ifr_addr)], [#include <stddef.h>
#include <net/if.h>
], [ac_cv_offsetof_ifr_addr_ifreq=0])])
AC_DEFINE_UNQUOTED([OFFSETOF_IFR_ADDR_IFREQ], $ac_cv_offsetof_ifr_addr_ifreq, [The offset of ifr_addr within `struct ifreq', as computed by offsetof.])
dnl '` fix syntax highlighting

430

431 432 433 434 435 436 437 438 439 440 441 442 443 444
dnl PlanetLab "Privileged Operations" library

explicit_proper=yes
AC_ARG_WITH(proper, [[  --with-proper[=PREFIX]  use PlanetLab Proper library (optional)]],
  [properprefix=$withval; if test -z "$withval" -o "$withval" = yes; then properprefix=; fi],
  [properprefix=no; explicit_proper=no])
if test "$properprefix" != no; then
    dnl Proper requires libcurl
    dnl AC_CHECK_HEADER(curl/curl.h, have_curl_h=yes, have_curl_h=no)
    dnl AC_CHECK_LIB(curl, curl_easy_init)

    saveflags="$CPPFLAGS"; test -n "$properprefix" && CPPFLAGS="$CPPFLAGS -I$properprefix/include"
    AC_CHECK_HEADER(prop.h, have_prop_h=yes, have_prop_h=no)
    CPPFLAGS="$saveflags"
445

446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
    AC_LANG_C
    saveflags="$LDFLAGS"; test -n "$properprefix" && LDFLAGS="$LDFLAGS -L$properprefix/lib"
    AC_CHECK_LIB(proper, prop_open, have_libproper=yes, have_libproper=no)
    LDFLAGS="$saveflags"
    AC_LANG_CPLUSPLUS

    if test $have_prop_h = yes -a $have_libproper = yes; then
	AC_DEFINE(HAVE_PROPER)
	test -n "$properprefix" && PROPER_INCLUDES="-I$properprefix/include" && PROPER_LIBS="-L$properprefix/lib"
	PROPER_LIBS="$PROPER_LIBS -lproper"
    elif test $explicit_proper = yes; then
	PROPER_INCLUDES= PROPER_LIBS=
	AC_MSG_ERROR([
=========================================

461 462
You explicitly specified --with-proper, but the proper headers and/or
libraries are not where you said they would be.  Run again supplying
463 464 465 466 467 468 469 470 471
--without-proper or --with-proper=PREFIX.

=========================================])
    fi
fi
AC_SUBST(PROPER_INCLUDES)
AC_SUBST(PROPER_LIBS)


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
dnl expat library

explicit_expat=yes
AC_ARG_WITH(expat, [[  --with-expat[=PREFIX]   locate expat XML library (optional)]],
  [expatprefix=$withval; if test -z "$withval" -o "$withval" = yes; then expatprefix=; fi],
  expatprefix=; explicit_expat=no)

XML2CLICK=
if test "$expatprefix" != no; then
    saveflags="$CPPFLAGS"; test -n "$expatprefix" && CPPFLAGS="$CPPFLAGS -I$expatprefix/include"
    AC_CHECK_HEADER(expat.h, have_expat_h=yes, have_expat_h=no)
    CPPFLAGS="$saveflags"

    AC_LANG_C
    saveflags="$LDFLAGS"; test -n "$expatprefix" && LDFLAGS="$LDFLAGS -L$expatprefix/lib"
    AC_CHECK_LIB(expat, XML_ParserCreateNS, have_libexpat=yes, have_libexpat=no)
    LDFLAGS="$saveflags"

    if test $have_expat_h = yes -a $have_libexpat = yes; then
	AC_DEFINE(HAVE_EXPAT)
	XML2CLICK=xml2click
	test -n "$expatprefix" && EXPAT_INCLUDES="-I$expatprefix/include" && EXPAT_LIBS="-L$expatprefix/lib"
	EXPAT_LIBS="$EXPAT_LIBS -lexpat"
    elif test $explicit_expat = yes; then
	EXPAT_INCLUDES= EXPAT_LIBS=
	AC_MSG_ERROR([
=========================================

You explicitly specified --with-expat, but the expat headers and/or libraries
are not where you said they would be.  Run again supplying --without-expat
or --with-expat=PREFIX.

=========================================])
    fi
fi
AC_SUBST(XML2CLICK)
AC_SUBST(EXPAT_INCLUDES)
AC_SUBST(EXPAT_LIBS)


eddietwo's avatar
eddietwo committed
512
dnl
513
dnl programs needed for build process
eddietwo's avatar
eddietwo committed
514 515
dnl

516 517 518 519
CLICK_PROG_INSTALL
CLICK_PROG_GMAKE
CLICK_PROG_AUTOCONF
CLICK_PROG_PERL5
520 521 522
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_EGREP
eddietwo's avatar
eddietwo committed
523

524 525 526 527
if test -z "$GMAKE"; then
    AC_MSG_ERROR([
==============================================

528
Can't find GNU make.  Either put 'gmake' on your PATH and
eddietwo's avatar
eddietwo committed
529
rerun './configure', or set the GMAKE environment variable to
530 531 532 533 534 535 536
GNU make's pathname.

==============================================])
fi


dnl
537
dnl Makeinfo, texi2dvi, install-info, pod2man
538 539 540 541 542
dnl

AC_MSG_CHECKING(for working makeinfo)
MAKEINFO=${MAKEINFO-makeinfo}
if ($MAKEINFO --version) < /dev/null > conftest.out 2>&1; then
543
    if test `head -n 1 conftest.out | sed 's/^.* \([[0-9]][[0-9]]*\).*$/\1/'` -ge 4; then
544 545 546 547 548
	AC_MSG_RESULT(found)
    else
	MAKEINFO='$(conf_auxdir)/missing makeinfo'
	AC_MSG_RESULT(old)
    fi
549
else
550 551
    MAKEINFO='$(conf_auxdir)/missing makeinfo'
    AC_MSG_RESULT(missing)
552 553 554 555 556
fi

AC_MSG_CHECKING(for working texi2dvi)
TEXI2DVI=${TEXI2DVI-texi2dvi}
if ($TEXI2DVI --version) < /dev/null > conftest.out 2>&1; then
557
    dnl Search for a good version of texi2dvi
558
    if test `head -n 1 conftest.out | sed 's/.*Texinfo \([[0-9]][[0-9]]*\).*/\1/'` -ge 4; then
559 560 561 562 563
	AC_MSG_RESULT(found)
    else
	TEXI2DVI='$(conf_auxdir)/missing texi2dvi'
	AC_MSG_RESULT(old)
    fi
564
else
565 566
    TEXI2DVI='$(conf_auxdir)/missing texi2dvi'
    AC_MSG_RESULT(missing)
567 568 569 570
fi

dnl Assume any version of install-info is OK
if test ${INSTALL_INFO-xxx} = xxx; then
571
    AC_PATH_PROG(INSTALL_INFO, install-info, '$(conf_auxdir)/missing install-info',
572 573 574 575
	$PATH:/sbin:/usr/sbin:/usr/local/sbin)
fi
AC_MSG_CHECKING(for working install-info)
if ($INSTALL_INFO --version) < /dev/null > conftest.out 2>&1; then
576
    AC_MSG_RESULT(found)
577
else
578 579
    INSTALL_INFO='$(conf_auxdir)/missing install-info'
    AC_MSG_RESULT(missing)
580 581
fi

582 583 584 585 586 587 588 589 590
AC_MSG_CHECKING(for working pod2man)
POD2MAN=${POD2MAN-pod2man}
if ($POD2MAN --help) < /dev/null > conftest.out 2>&1 && grep pod2man conftest.out >/dev/null 2>&1; then
    AC_MSG_RESULT(found)
else
    POD2MAN='$(conf_auxdir)/missing pod2man'
    AC_MSG_RESULT(missing)
fi

591 592 593 594

AC_SUBST(MAKEINFO)
AC_SUBST(TEXI2DVI)
AC_SUBST(INSTALL_INFO)
595
AC_SUBST(POD2MAN)
596

eddietwo's avatar
eddietwo committed
597 598

dnl
599
dnl set path variables
eddietwo's avatar
eddietwo committed
600 601 602
dnl

shell_expand () {
603
    val=`eval echo '$'"$1"`
604
    while echo "x$val" | grep '\$' >/dev/null 2>&1; do val=`eval echo "$val"`; done
605
    eval "$1='$val'"
eddietwo's avatar
eddietwo committed
606 607 608 609 610 611 612 613
}

dnl Preset $prefix and $exec_prefix.
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

dnl Expand 'infodir' to check for Red Hat
if test x$infodir = 'x${prefix}/info'; then
614
    test ! -d ${prefix}/info && test -d ${prefix}/share/info && infodir='${prefix}/share/info'
eddietwo's avatar
eddietwo committed
615 616 617
fi

shell_expand bindir
eddietwo's avatar
eddietwo committed
618
shell_expand sbindir
eddietwo's avatar
eddietwo committed
619
shell_expand libdir
620
shell_expand datarootdir
eddietwo's avatar
eddietwo committed
621
shell_expand datadir
eddietwo's avatar
eddietwo committed
622 623 624 625
shell_expand includedir

clickdatadir="$datadir/click"
AC_SUBST(clickdatadir)
eddietwo's avatar
eddietwo committed
626 627 628

AC_DEFINE_UNQUOTED(CLICK_BINDIR, "$bindir")
AC_DEFINE_UNQUOTED(CLICK_LIBDIR, "$libdir")
eddietwo's avatar
eddietwo committed
629
AC_DEFINE_UNQUOTED(CLICK_DATADIR, "$clickdatadir")
630

eddietwo's avatar
eddietwo committed
631

632 633 634 635 636 637 638
dnl
dnl Provisions
dnl

dnl start out with CPU
provisions="$target_cpu"
case "$target_cpu" in
639 640 641
    i386) :;;
    i486|i586) provisions="$provisions i386";;
    i686|i786) provisions="$provisions i386 i586";;
642 643
esac

eddietwo's avatar
eddietwo committed
644 645 646 647 648
dnl add 'analysis' if analysis elements are available
if test "x$enable_analysis" = xyes; then
    provisions="$provisions analysis"
fi

649 650 651 652 653
dnl add 'experimental' if --enable-experimental was supplied
if test "x$enable_experimental" = xyes; then
    provisions="$provisions experimental"
fi

eddietwo's avatar
eddietwo committed
654
dnl add 'int64' if 64-bit integers are available
655
if test "x$have_int64_types" = xyes; then
eddietwo's avatar
eddietwo committed
656
    provisions="$provisions int64"
657 658
fi

eddietwo's avatar
eddietwo committed
659
dnl add 'ip6' if ip6 elements are available
660
if test "x$enable_ip6" = xyes; then
eddietwo's avatar
eddietwo committed
661 662 663 664 665 666 667 668 669 670 671 672 673
    provisions="$provisions ip6"
fi

dnl add 'linux' if compiling under linux
if test "x$ac_cv_under_linux" = xyes; then
    provisions="$provisions linux"
fi

dnl add 'pcap' if libpcap is available
if test "x$HAVE_PCAP" = xyes; then
    provisions="$provisions pcap"
fi

674 675 676 677 678
dnl add 'umultithread' if compiled with --enable-user-multithread
if test "x$enable_user_multithread" = xyes; then
    provisions="$provisions umultithread"
fi

eddietwo's avatar
eddietwo committed
679 680 681
dnl add 'wifi' if wifi elements are available
if test "x$enable_wifi" = xyes; then
    provisions="$provisions wifi"
682 683 684
fi

AC_SUBST(provisions)
685

eddietwo's avatar
eddietwo committed
686 687 688 689
dnl
dnl Output
dnl

Eddie Kohler's avatar
Eddie Kohler committed
690
config_files="Makefile click-buildtool libsrc/Makefile"
eddietwo's avatar
eddietwo committed
691
for ac_dir in include; do
692
    test ! -d "$ac_dir" && mkdir "$ac_dir"
eddietwo's avatar
eddietwo committed
693
done
eddietwo's avatar
eddietwo committed
694

695
AC_OUTPUT_COMMANDS([for ac_file in $CONFIG_HEADERS; do
696
    test $ac_file = include/click/config.h:config.h.in && echo > stamp-h
eddietwo's avatar
eddietwo committed
697 698
done
for ac_file in $CONFIG_FILES; do
699 700
    test $ac_file = click-buildtool && chmod +x click-buildtool
    test -z "$GMAKE" && echo $ac_file | grep Makefile >/dev/null && $ac_given_srcdir/missing gmake $ac_file
701
done], GMAKE="$GMAKE")
eddietwo's avatar
eddietwo committed
702
AC_OUTPUT($config_files)