configure.ac 29.6 KB
Newer Older
1
AC_PREREQ([2.59])
's avatar
committed
2
AC_INIT([mapi], [2.0-beta1], [mapi@uninett.no])
3
AM_CONFIG_HEADER(config.h)
4 5
AC_CONFIG_SRCDIR([src/mapid.c])
AC_CONFIG_AUX_DIR(config)
6
AM_INIT_AUTOMAKE(foreign no-dependencies no-installinfo)
7 8 9 10

# Checks for programs
AC_PROG_CC
AC_PROG_INSTALL
's avatar
committed
11 12 13 14 15 16 17
AC_PATH_PROG(ac_mapi_groupadd, groupadd, no, $PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/ucb)
if test $ac_mapi_groupadd = no ; then
	AC_MSG_WARN("groupadd not found, so a MAPI group will not be created.")
else
	GROUPADD="$ac_mapi_groupadd"
	AC_SUBST(GROUPADD)
fi
18 19 20 21 22 23 24 25 26 27 28 29 30

AC_MSG_NOTICE([libtool -----------------------------------------------------])
# Turn off static libraries during beta-testing, since they
# make the build process take too long.
AC_DISABLE_STATIC
# Check for dlopen support
AC_LIBTOOL_DLOPEN
# Configure libtool
AC_PROG_LIBTOOL

# Checks for C headers
AC_MSG_NOTICE([header files ------------------------------------------------])
AC_HEADER_STDC
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
AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/socket.h sys/time.h syslog.h unistd.h zlib.h sys/ethernet.h net/ethernet.h])

# Checks for data types
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short int, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long int, 4)
AC_CHECK_SIZEOF(long long int, 8)

AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
		[ ac_cv_have_intxx_t="yes" ],
		[ ac_cv_have_intxx_t="no" ]
	)
])
if test "x$ac_cv_have_intxx_t" = "xyes" ; then
	AC_DEFINE(HAVE_INT8_T, 1, [Data type])
	AC_DEFINE(HAVE_INT16_T, 1, [Data type])
	AC_DEFINE(HAVE_INT32_T, 1, [Data type])
	have_intxx_t=1
fi

if (test -z "$have_intxx_t" && test "x$ac_cv_header_stdint_h" = "xyes")
then
    AC_MSG_CHECKING([for intXX_t types in stdint.h])
	AC_TRY_COMPILE(
		[ #include <stdint.h> ], 
		[ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
		[
			AC_DEFINE(HAVE_INT8_T, 1, [Data type])
			AC_DEFINE(HAVE_INT16_T, 1, [Data type])
			AC_DEFINE(HAVE_INT32_T, 1, [Data type])
			AC_MSG_RESULT(yes)
		],
		[ AC_MSG_RESULT(no) ]
	)
fi

AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ int64_t a; a = 1;], 
		[ ac_cv_have_int64_t="yes" ],
		[ ac_cv_have_int64_t="no" ]
	)
])
if test "x$ac_cv_have_int64_t" = "xyes" ; then
	AC_DEFINE(HAVE_INT64_T, 1, [Data type])
	have_int64_t=1
fi
	
if test -z "$have_int64_t" ; then
    AC_MSG_CHECKING([for int64_t type in sys/socket.h])
	AC_TRY_COMPILE(
		[ #include <sys/socket.h> ], 
		[ int64_t a; a = 1],
		[
			AC_DEFINE(HAVE_INT64_T, 1, [Data type])
			AC_MSG_RESULT(yes)
		],
		[ AC_MSG_RESULT(no) ]
	)
fi

AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
		[ ac_cv_have_u_intxx_t="yes" ],
		[ ac_cv_have_u_intxx_t="no" ]
	)
])
if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
	AC_DEFINE(HAVE_U_INT8_T, 1, [Data type])
	AC_DEFINE(HAVE_U_INT16_T, 1, [Data type])
	AC_DEFINE(HAVE_U_INT32_T, 1, [Data type])
	have_u_intxx_t=1
fi

if test -z "$have_u_intxx_t" ; then
    AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
	AC_TRY_COMPILE(
		[ #include <sys/socket.h> ], 
		[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
		[
			AC_DEFINE(HAVE_U_INT8_T, 1, [Data type])
			AC_DEFINE(HAVE_U_INT16_T, 1, [Data type])
			AC_DEFINE(HAVE_U_INT32_T, 1, [Data type])
			AC_MSG_RESULT(yes)
		],
		[ AC_MSG_RESULT(no) ]
	)
fi

AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ u_int64_t a; a = 1;], 
		[ ac_cv_have_u_int64_t="yes" ],
		[ ac_cv_have_u_int64_t="no" ]
	)
])
if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
	AC_DEFINE(HAVE_U_INT64_T, 1, [Data type])
	have_u_int64_t=1
fi

if test -z "$have_u_intxx_t" ; then
	AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
		AC_TRY_COMPILE(
			[ #include <sys/types.h> ], 
			[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ], 
			[ ac_cv_have_uintxx_t="yes" ],
			[ ac_cv_have_uintxx_t="no" ]
		)
	])
	if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
		AC_DEFINE(HAVE_UINT8_T, 1, [Data type])
		AC_DEFINE(HAVE_UINT16_T, 1, [Data type])
		AC_DEFINE(HAVE_UINT32_T, 1, [Data type])
	fi
fi

if test -z "$have_uintxx_t" ; then
    AC_MSG_CHECKING([for uintXX_t types in stdint.h])
	AC_TRY_COMPILE(
		[ #include <stdint.h> ], 
		[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;], 
		[
			AC_DEFINE(HAVE_UINT8_T, 1, [Data type])
			AC_DEFINE(HAVE_UINT16_T, 1, [Data type])
			AC_DEFINE(HAVE_UINT32_T, 1, [Data type])
			AC_MSG_RESULT(yes)
		],
		[ AC_MSG_RESULT(no) ]
	)
fi
170

's avatar
committed
171 172 173
# $prefix stores the value of the --prefix command line option, or NONE if
# the option wasn't set. In the latter case, set it to the default, so that
# we can use it to expand directories now.
174 175 176 177
if test "x$prefix" = "xNONE"; then
	prefix=$ac_default_prefix
fi

178
AC_MSG_NOTICE([MAPI options ------------------------------------------------])
179

's avatar
committed
180
AC_DEFINE(CONF_FILE, "mapi.conf", [configuration file])
181 182
AC_DEFINE(MAPICOMMD_SSL_KEY_FILE, "mapicommd_key.pem", [mapicommd SSL key])
AC_DEFINE(MAPICOMMD_SSL_CERT_FILE, "mapicommd_cert.pem", [mapicommd SSL certificate])
183 184 185 186
# development defines - leave them enabled for now
AC_DEFINE(DEBUG, 1, [keep debugging on during beta testing])
AC_DEFINE(VALGRIND, 1, [easier debugging using valgrind])

187 188 189 190 191 192 193
# mapi user group name
AC_ARG_VAR(MAPI_GROUP, [Name of the MAPI user group (default: 'mapi')])
if test x$MAPI_GROUP = x; then
	MAPI_GROUP=mapi;
fi
AC_DEFINE_UNQUOTED(MAPI_GROUP_NAME, "${MAPI_GROUP}", [mapi group name])

194
# in the end will contain all the enabled MAPI function libraries
195 196
MAPI_FUNC_LIBS="stdflib.so"

197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
# DiMAPI
AC_MSG_CHECKING([if distributed monitoring (DiMAPI) is enabled])
AC_ARG_ENABLE(dimapi,
AS_HELP_STRING([--enable-dimapi], [Enable support for distributed monitoring (DiMAPI)]),
[case "${enableval}" in
	yes) dimapi=true ;;
	no)  dimapi=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-dimapi) ;;
esac], [dimapi=false])
AM_CONDITIONAL(BINARY_DIMAPI, test x$dimapi = xtrue)
if test x$dimapi = xtrue; then
	AC_DEFINE(DIMAPI, 1, [Support for distributed monitoring])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
# Reconnection
AC_MSG_CHECKING([if reconnection of client is enabled])
AC_ARG_ENABLE(reconnect,
AS_HELP_STRING([--enable-reconnect], [Enable support for reconnection of client after connection to mapicommd or mapid breaks down]),
[case "${enableval}" in
	yes) reconnect=true ;;
	no)  reconnect=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-reconnect) ;;
esac], [reconnect=false])
AM_CONDITIONAL(BINARY_RECONNECT, test x$reconnect = xtrue)
if test x$reconnect = xtrue; then
	AC_DEFINE(RECONNECT, 1, [Support for reconnect of client after connection to mapicommd or mapid breaks down])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi
230 231
# for etc/Makefile.am
AM_CONDITIONAL(RECONNECTION_IS_ENABLED, test x$reconnect = xtrue)
232

233 234 235 236 237 238 239 240
# SSL sockets (only for DiMAPI)
if test x$dimapi = xtrue; then
	AC_MSG_CHECKING([if SSL for DiMAPI is enabled])
fi
AC_ARG_ENABLE(ssl,
	AS_HELP_STRING([--enable-ssl], [Enable encryption of DiMAPI traffic]),
	[
		if test x$dimapi = xfalse; then
241 242 243
			if test x$enableval = xyes; then
				AC_MSG_ERROR(Please use --enable-ssl only in conjunction with --enable-dimapi. You don't need to enable SSL if you are not going to use DiMAPI)
			fi
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
		fi
		case "${enableval}" in
			yes) ssl=true ;;
			no)  ssl=false ;;
			*) AC_MSG_ERROR(bad value ${enableval} for --enable-ssl) ;;
		esac
	],
	[
		ssl=false
	]
)
if test x$dimapi = xtrue; then
	if test x$ssl = xtrue; then
		AC_DEFINE(DIMAPISSL, 1, [SSL support for DiMAPI])
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
	fi
fi
# for etc/Makefile.am
AM_CONDITIONAL(SSL_IS_ENABLED, test x$ssl = xtrue)

266 267 268 269 270 271 272 273 274 275
# DAG support
AC_MSG_CHECKING(if DAG cards support is enabled)
AC_ARG_ENABLE(dag,
AS_HELP_STRING([--enable-dag], [Enable support for Endace's DAG cards]),
[case "${enableval}" in
	yes) dag=true ;;
	no)  dag=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-dag) ;;
esac], [dag=false])
AM_CONDITIONAL(DRIVER_DAG, test x$dag = xtrue)
276
AM_CONDITIONAL(BINARY_DAGFLIB, test x$dag = xtrue)
277
AM_CONDITIONAL(PRECLASSIFICATION, test x$dag = xtrue)
278 279
if test x$dag = xtrue; then
	MAPI_CONF_DAG_ENTRY=$srcdir/config/mapi.conf.dag.entry
280
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:dagflib.so"
281 282
	AC_DEFINE(PRECLASSIFICATION, 1, [hardware preliminary packet classification])
	AC_DEFINE(WITH_DAG, 1, [if DAG cards are supported])
283 284 285 286 287 288 289
	AC_MSG_RESULT(yes)
else
	MAPI_CONF_DAG_ENTRY=/dev/null
	AC_MSG_RESULT(no)
fi
AC_SUBST_FILE(MAPI_CONF_DAG_ENTRY)

290 291 292 293 294 295 296 297 298 299 300 301
# ENP2611 support
AC_MSG_CHECKING(if ENP2611 cards support is enabled)
AC_ARG_ENABLE(enp2611,
AS_HELP_STRING([--enable-enp2611], [Enable support for ENP2611 cards]),
[case "${enableval}" in
	yes) enp2611=true ;;
	no)  enp2611=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-enp2611) ;;
esac], [enp2611=false])
AM_CONDITIONAL(DRIVER_ENP2611, test x$enp2611 = xtrue)
AM_CONDITIONAL(BINARY_ENP2611FLIB, test x$enp2611 = xtrue)

302 303 304 305 306 307 308 309 310 311
# NAPATECH support
AC_MSG_CHECKING(if NAPATECH cards support is enabled)
AC_ARG_ENABLE(napatech,
AS_HELP_STRING([--enable-napatech], [Enable support for NAPATECH cards]),
[case "${enableval}" in
        yes) napatech=true ;;
        no)  napatech=false ;;
        *) AC_MSG_ERROR(bad value ${enableval} for --enable-napatech) ;;
esac], [napatech=false])
AM_CONDITIONAL(DRIVER_NAPATECH, test x$napatech = xtrue)
's avatar
 
committed
312
AM_CONDITIONAL(BINARY_NAPATECHFLIB, test x$napatech = xtrue)
313 314
# AM_CONDITIONAL(PRECLASSIFICATION, test x$dag = xtrue)
if test x$napatech = xtrue; then
315
        MAPI_CONF_NAPATECH_ENTRY=$srcdir/config/mapi.conf.napatech.entry
316
        MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:napatechflib.so"
317 318 319 320 321 322 323
        # AC_DEFINE(PRECLASSIFICATION, 1, [hardware preliminary packet classification])
        AC_DEFINE(WITH_NAPATECH, 1, [if NAPATECH cards are supported])
        AC_MSG_RESULT(yes)
else
        MAPI_CONF_NAPATECH_ENTRY=/dev/null
        AC_MSG_RESULT(no)
fi
324
AC_SUBST_FILE(MAPI_CONF_NAPATECH_ENTRY)
325

326

327 328 329 330 331 332 333 334 335 336 337 338 339 340
# optional MAPI function libraries

# trackflib
AC_MSG_CHECKING(if the traffic characterization library is enabled)
AC_ARG_ENABLE(trackflib,
AS_HELP_STRING([--enable-trackflib], [Build the traffic characterization library]),
[case "${enableval}" in
	yes) trackflib=true ;;
	no)  trackflib=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-trackflib) ;;
esac], [trackflib=false])
AM_CONDITIONAL(BINARY_TRACKFLIB, test x$trackflib = xtrue)
if test x$trackflib = xtrue; then
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:trackflib.so"
341
	AC_DEFINE(TRACKFLIB_COMPILED, 1, [trackflib is enabled in the build])
342 343 344 345 346
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

's avatar
 
committed
347 348 349 350 351 352 353 354 355
# rulerflib
AC_MSG_CHECKING(if the Ruler interface library is enabled)
AC_ARG_ENABLE(rulerflib,
AS_HELP_STRING([--enable-rulerflib], [Build the Ruler interface library]),
[case "${enableval}" in
	yes) rulerflib=true ;;
	no)  rulerflib=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-rulerflib) ;;
esac], [rulerflib=false])
's avatar
 
committed
356
AM_CONDITIONAL(BINARY_RULERFLIB, test x$rulerflib = xtrue)
's avatar
 
committed
357 358
if test x$rulerflib = xtrue; then
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:rulerflib.so"
's avatar
 
committed
359
	AC_DEFINE(WITH_MODIFY_PKTS, 1, [support for functions that modify packets])
's avatar
 
committed
360 361 362 363 364 365
	AC_DEFINE(RULERFLIB_COMPILED, 1, [rulerflib is enabled in the build])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

366 367 368 369 370 371 372 373 374 375 376 377
# anonflib
AC_MSG_CHECKING(if the anonymization library is enabled)
AC_ARG_ENABLE(anonflib,
AS_HELP_STRING([--enable-anonflib], [Build the traffic anonymization library]),
[case "${enableval}" in
	yes) anonflib=true ;;
	no)  anonflib=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-anonflib) ;;
esac], [anonflib=false])
AM_CONDITIONAL(BINARY_ANONFLIB, test x$anonflib = xtrue)
if test x$anonflib = xtrue; then
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:anonflib.so"
378
	AC_DEFINE(WITH_MODIFY_PKTS, 1, [support for functions that modify packets])
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

# ipfixflib
AC_MSG_CHECKING(if the ipfix library is enabled)
AC_ARG_ENABLE(ipfixflib,
AS_HELP_STRING([--enable-ipfixflib], [Build the NetFlow export library]),
[case "${enableval}" in
	yes) ipfixflib=true ;;
	no)  ipfixflib=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-ipfixflib) ;;
esac], [ipfixflib=false])
AM_CONDITIONAL(BINARY_IPFIXFLIB, test x$ipfixflib = xtrue)
if test x$ipfixflib = xtrue; then
395
	MAPI_CONF_IPFIXFLIB_ENTRY=$srcdir/config/mapi.conf.ipfixflib.entry
396 397 398
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:ipfixflib.so"
	AC_MSG_RESULT(yes)
else
399
	MAPI_CONF_IPFIXFLIB_ENTRY=/dev/null
400 401
	AC_MSG_RESULT(no)
fi
402
AC_SUBST_FILE(MAPI_CONF_IPFIXFLIB_ENTRY)
403

404 405 406 407
# extraflib
AC_MSG_CHECKING(if the extra functions library is enabled)
AC_ARG_ENABLE(extraflib,
AS_HELP_STRING([--enable-extraflib], [Build the extra functions library]),
408
[case "${enableval}" in
409 410 411 412 413 414 415 416
	yes) extraflib=true ;;
	no)  extraflib=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-extraflib) ;;
esac], [extraflib=false])
AM_CONDITIONAL(BINARY_EXTRAFLIB, test x$extraflib = xtrue)
if test x$extraflib = xtrue; then
	MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:extraflib.so"
	# needed by cooking
417 418 419 420 421 422
	AC_DEFINE(WITH_MODIFY_PKTS, 1, [support for functions that modify packets])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

423 424 425
# a string with all the compiled MAPI function libraries
AC_SUBST(MAPI_FUNC_LIBS)

's avatar
committed
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
# Authentication
AC_MSG_CHECKING([if authentication is enabled])
AC_ARG_ENABLE(authentication,
AS_HELP_STRING([--enable-authentication], [Enable support for authentication]),
[
	if test x$dimapi = xfalse; then
		if test x$enableval = xyes; then
			AC_MSG_ERROR(Please use --enable-authentication only in conjunction with --enable-dimapi. You don't need to enable authentication if you are not going to use DiMAPI)
		fi
	fi
	if test x$anonflib = xfalse; then
		if test x$enableval = xyes; then
			AC_MSG_ERROR(Please use --enable-anonflib with authentication because it is neccessary for anonymization functions)
		fi
	fi
	case "${enableval}" in
		yes) authentication=true ;;
		no)	 authentication=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-authentication) ;;
	esac
], [authentication=false])
AM_CONDITIONAL(BINARY_AUTHENTICATION, test x$authentication = xtrue)
if test x$authentication = xtrue; then
	AC_DEFINE(WITH_AUTHENTICATION, 1, [support for authentication])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi
454 455 456

# misc options

457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
# function statistics
AC_MSG_CHECKING(if function statistics are enabled)
AC_ARG_ENABLE(funcstats,
AS_HELP_STRING([--enable-funcstats], [Enable function statistics. This option enables packet counters for each applied function]),
[case "${enableval}" in
	yes) funcstats=true ;;
	no)  funcstats=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-funcstats) ;;
esac], [funcstats=false])
if test x$funcstats = xtrue; then
	AC_DEFINE(WITH_FUNCT_STATS, 1, [enable function statistics])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

473
#No locking in mapidlib
474 475 476 477 478 479 480 481
AC_MSG_CHECKING(if locking is enabled in mapidlib)
AC_ARG_ENABLE(locking,
   AS_HELP_STRING([--enable-locking], 
   [Enable locking inside mapidlib. May be disabled to increase performance.]),
   enable_locking="$enableval",
   enable_locking=yes)
if test x$enable_locking = xyes; then
	AC_DEFINE(WITH_LOCKING, 1, [enable mapidlib locking])
482 483 484 485 486
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

487

488 489 490
# Checks for libraries
AC_MSG_NOTICE([libraries ---------------------------------------------------])

491
#
492
# libpcap
493
#
494 495 496 497 498 499 500 501 502 503 504 505 506
AC_MSG_CHECKING([for libpcap])
AC_ARG_WITH(libpcap,
AS_HELP_STRING([--with-libpcap=DIR], [Manual libpcap path configuration, in case the configuration script can't find it. Search for libpcap in DIR/lib, and for the header file in DIR/include]),
[ case "$withval" in
  yes|no)
     AC_MSG_RESULT(no)
     ;;
  *)
     AC_MSG_RESULT($withval)
     if test -f $withval/pcap.h -a -f $withval/libpcap.a; then
        owd=`pwd`
        if cd $withval; then withval=`pwd`; cd $owd; fi
	PCAPINC="-I$withval -I$withval/bpf"
507
	PCAPLIB="-L$withval $withval/libpcap.a"
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
     else
        AC_MSG_ERROR(pcap.h or libpcap.a not found in $withval)
     fi
     ;;
  esac ],
[ if test -f ${prefix}/include/pcap.h; then
     PCAPINC="-I${prefix}/include"
     PCAPLIB="-L${prefix}/lib -lpcap"
  elif test -f /usr/include/pcap/pcap.h; then
     PCAPINC="-I/usr/include/pcap"
     PCAPLIB="-lpcap"
  elif test -f /usr/include/pcap.h; then
     PCAPLIB="-lpcap"
  else
     AC_MSG_RESULT(no)
     AC_MSG_ERROR([libpcap not found - go get it from http://www.tcpdump.org or use the --with-libpcap option if you have installed it in an unusual place])
  fi
  AC_MSG_RESULT(yes) ]
)
AC_SUBST(PCAPINC)
AC_SUBST(PCAPLIB)

530
#
531
# libdag (only for --enable-dag)
532
#
533 534
AC_MSG_CHECKING([for libdag])
AC_ARG_WITH(libdag,
535
AS_HELP_STRING([--with-libdag=DIR], [Manual libdag path configuration, in case the configuration script can't find it. Search for libdag in DIR/lib, and for the header file in DIR/include. Effective only if --enable-dag has been previously specified]),
536 537 538 539 540 541
[ case "$withval" in
	yes|no)
		AC_MSG_RESULT(no)
		;;
	*)
		if test x$dag = xfalse; then
542
        	AC_MSG_ERROR(Please use --with-libdag only in conjunction with --enable-dag. You don't need to configure libdag if you are not going to use a DAG card.)
543 544 545 546 547 548
		else
			AC_MSG_RESULT($withval)
			if test -f $withval/include/dagapi.h -a -f $withval/lib/libdag.a; then
				owd=`pwd`
				if cd $withval; then withval=`pwd`; cd $owd; fi
				DAGINC="-I$withval/include"
Jon Kåre Hellan's avatar
Jon Kåre Hellan committed
549
				DAGLIB="-L$withval/lib -ldag -ldagconf -ldagdsm -ladt -lm -ldagema -lpthread"
550 551 552 553 554 555 556
			else
				AC_MSG_ERROR(dagapi.h or libdag.a not found in $withval/include and $withval/lib)
			fi
	 	fi
		;;
  esac ],
[ if test x$dag = xtrue; then
557 558
	if test -f ${prefix}/include/dagapi.h -a -f ${prefix}/lib/libdag.a; then
		DAGINC="-I${prefix}/include"
Jon Kåre Hellan's avatar
Jon Kåre Hellan committed
559
		DAGLIB="-L${prefix}/lib -ldag -ldagconf -ldagdsm -ladt -lm -ldagema -lpthread"
560
	elif test -f /usr/local/include/dagapi.h -a -f /usr/local/lib/libdag.a; then
561
		DAGINC="-I${prefix}/include"
Jon Kåre Hellan's avatar
Jon Kåre Hellan committed
562
		DAGLIB="-L${prefix}/lib -ldag -ldagconf -ldagdsm -ladt -lm -ldagema -lpthread"
563 564
	elif test -f /usr/include/dag/dagapi.h; then
		DAGINC="-I/usr/include/dag"
Jon Kåre Hellan's avatar
Jon Kåre Hellan committed
565
		DAGLIB="-ldag -ldagconf -ldagdsm -ladt -lm -ldagema -lpthread"
566
	elif test -f /usr/include/dagapi.h; then
Jon Kåre Hellan's avatar
Jon Kåre Hellan committed
567
		DAGLIB="-ldag -ldagconf -ldagdsm -ladt -lm -ldagema -lpthread"
568 569 570 571 572 573 574 575 576 577 578 579
	else
		AC_MSG_RESULT(no)
		AC_MSG_ERROR([libdag not found])
	fi
	AC_MSG_RESULT(yes)
  else
	AC_MSG_RESULT(no)
  fi ]
)
AC_SUBST(DAGINC)
AC_SUBST(DAGLIB)

580

581 582 583 584 585
#
# libnapatech (only for --enable-napatech)
#
AC_MSG_CHECKING([for libnapatech])
AC_ARG_WITH(libnapatech,
586
AS_HELP_STRING([--with-libnapatech=DIR], [Manual libnapatech path configuration, in case the configuration script can't find it. Search for libnapatech in DIR/lib, and for the header file in DIR/include and DIR/include/napatech. Effective only if --enable-napatech has been previously specified]),
587 588 589 590 591 592 593 594 595
[ case "$withval" in
	yes|no)
		AC_MSG_RESULT(no)
		;;
	*)
		if test x$napatech = xfalse; then
        	AC_MSG_ERROR(Please use --with-libnapatech only in conjunction with --enable-napatech. You don't need to configure libnapatech if you are not going to use a Napatech card.)
		else
			AC_MSG_RESULT($withval)
596 597 598 599 600 601 602
			incdir=""
			if test -f $withval/include/NTCommonInterface.h; then
			        incdir=$withval/include
			elif test -f $withval/include/napatech/NTCommonInterface.h; then
			        incdir=$withval/include/napatech
			fi
			if test "x$incdir" != "x"  -a -f $withval/lib/libntcommoninterface.so; then
603 604
				owd=`pwd`
				if cd $withval; then withval=`pwd`; cd $owd; fi
605
				NAPATECHINC="-I$incdir -D_NT_OS_TYPE=_NT_OS_TYPE_LINUX"
606 607 608 609 610 611 612 613 614 615 616 617 618 619
				NAPATECHLIB="-L$withval/lib -lntcommoninterface"
			else
				AC_MSG_ERROR(NTCommonInterface.h or libntcommoninterface.so not found in $withval/include and $withval/lib)
			fi
	 	fi
		;;
  esac ],
[ if test x$napatech = xtrue; then
	if test -f ${prefix}/include/NTCommonInterface.h -a -f ${prefix}/lib/libntcommoninterface.so; then
		NAPATECHINC="-I${prefix}/include"
		NAPATECHLIB="-L${prefix}/lib -lntcommoninterface"
	elif test -f /opt/napatech/include/NTCommonInterface.h -a -f /opt/napatech/lib/libntcommoninterface.so; then
		NAPATECHINC="-I/opt/napatech/include"
		NAPATECHLIB="-L/opt/napatech/lib -lntcommoninterface"
620 621 622
	elif test -f /opt/napatech/include/napatech/NTCommonInterface.h -a -f /opt/napatech/lib/libntcommoninterface.so; then
		NAPATECHINC="-I/opt/napatech/include/napatech"
		NAPATECHLIB="-L/opt/napatech/lib -lntcommoninterface"
623
	elif test -f /usr/local/include/NTCommonInterface.h -a -f /usr/local/lib/libntcommoninterface.so; then
624 625 626 627 628
		NAPATECHINC="-I/usr/local/include"
		NAPATECHLIB="-L/usr/local/lib -lntcommoninterface"
	elif test -f /usr/local/include/napatech/NTCommonInterface.h -a -f /usr/local/lib/libntcommoninterface.so; then
		NAPATECHINC="-I/usr/local/include/napatech"
		NAPATECHLIB="-L/usr/local/lib -lntcommoninterface"
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
	elif test -f /usr/include/napatech/NTCommonInterface.h; then
		NAPATECHINC="-I/usr/include/napatech"
		NAPATECHLIB="-lntcommoninterface"
	elif test -f /usr/include/NTCommonInterface.h; then
		NAPATECHLIB="NTCommonInterface.h"
	else
		AC_MSG_RESULT(no)
		AC_MSG_ERROR([libnapatech not found])
	fi
	AC_MSG_RESULT(yes)
  else
	AC_MSG_RESULT(no)
  fi ]
)
AC_SUBST(NAPATECHINC)
AC_SUBST(NAPATECHLIB)



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 716 717 718 719 720 721 722 723 724
#
# libnids >= 1.21 (only for --enable-extraflib)
#
echo " -----------LIBNIDS -------------------------------"
AC_ARG_WITH(libnids_includes, 
	AS_HELP_STRING([--with-libnids-includes=DIR], [Search for libnids headers in DIR. Effective only if --enable-extraflib has been previously specified]),
	[with_libnids_includes="$withval"],[with_libnids_includes=no])

AC_ARG_WITH(libnids_libraries,
    AS_HELP_STRING([--with-libnids-libraries=DIR], [Search for libnids library in DIR. Effective only if --enable-extraflib has been previously specified]),
	[with_libnids_libraries="$withval"],[with_libnids_libraries=no])

#If any of the above libnids options has been specified,
#check that --enable-extraflib has been specified too
if test x$extraflib != xtrue; then
	if test "$with_libnids_includes" != "no"; then
		AC_MSG_ERROR(Please use --with-libnids-includes only in conjunction with --with-extraflib. You don't need to configure libnids if you are not going to use it)
	fi
	if test "$with_libnids_libraries" != "no"; then
		AC_MSG_ERROR(Please use --with-libnids-libraries only in conjunction with --with-extraflib. You don't need configure libnids if you are not going to use it)
	fi
fi

if test x$extraflib = xtrue; then
echo " with extraflib, looking for nids... "
	save_CPPFLAGS=$CPPFLAGS
	save_LDFLAGS=$LDFLAGS 
	save_LIBS=$LIBS

	if test "$with_libnids_includes" != "no"; then
		NIDSINC="-I${with_libnids_includes}"
		CPPFLAGS="${CPPFLAGS} ${NIDSINC}"
	fi

	if test "$with_libnids_libraries" != "no"; then
	   NIDSLIB="-L${with_libnids_libraries} "
	fi

	NIDSLIB="${NIDSLIB} -lnids"
	LDFLAGS="${LDFLAGS} ${NIDSLIB}"

	echo ${LDFLAGS}
	echo ${CPPFLAGS}

	# Verify that we have the headers
	NIDS_H=""
	AC_CHECK_HEADER(nids.h,, NIDS_H="no")
	if test "$NIDS_H" = "no"; then
	  echo "   ERROR!  Libnids header not found, go get it "
	  exit 1
	fi

	# Verify that we have the library
	#if test -f "${with_libnids_libraries}/libnids.a"; then
	#	echo "libnids.a exists"
	#else
	#	echo "libnids.a does not exist"
	#fi

	NIDS_L=""
	AC_CHECK_LIB(nids, nids_pcap_handler, ,NIDS_L="no")
	if test "$NIDS_L" = "no"; then
		echo "    ERROR!  Libnids library not found or < 1.21 , go get it"
		exit 1
	fi

	CPPFLAGS=$save_CPPFLAGS
	LDFLAGS=$save_LDFLAGS 
	LIBS=$save_LIBS

	AC_SUBST(NIDSINC)
	AC_SUBST(NIDSLIB)

fi
echo " ----------------------END LIBNIDS---------------------------------"
#end of libnids ...

725
#
726
# libpcre  (only for --enable-extraflib) - based on Snort's configure.in
727
#
728
AC_ARG_WITH(libpcre_includes,
729
	AS_HELP_STRING([--with-libpcre-includes=DIR], [Search for libpcre headers in DIR. Effective only if --enable-extraflib has been previously specified]),
730 731 732
	[with_libpcre_includes="$withval"],[with_libpcre_includes=no])

AC_ARG_WITH(libpcre_libraries,
733
	AS_HELP_STRING([--with-libpcre-libraries=DIR], [Search for libpcre library in DIR. Effective only if --enable-extraflib has been previously specified]),
734 735
	[with_libpcre_libraries="$withval"],[with_libpcre_libraries=no])

736 737 738 739 740
wants_pcre=false
if test x$extraflib = xtrue || test x$anonflib = xtrue; then
	wants_pcre=true
fi

741
# if any of the above pcre options has been specified,
742 743
#check that --enable-extraflib or --enable-anonflib has been specified too
if test x$wants_pcre != xtrue; then
744
	if test "$with_libpcre_includes" != "no"; then
745
		AC_MSG_ERROR(Please use --with-libpcre-includes only in conjunction with --with-extraflib or --with-anonflib. You don't need to configure libpcre if you are not going to use any of them)
746 747
	fi
	if test "$with_libpcre_libraries" != "no"; then
748
		AC_MSG_ERROR(Please use --with-libpcre-libraries only in conjunction with --with-extraflib or --with-anonflib. You don't need configure libpcre if you are not going to use any of them)
749
	fi
750 751
fi

752 753
# check for libpcre only if --enable-extraflib or --enable-anonflib has been specified
if test x$wants_pcre = xtrue; then
754

755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
	save_CPPFLAGS=$CPPFLAGS
	save_LDFLAGS=$LDFLAGS 
	save_LIBS=$LIBS

	if test "$with_libpcre_includes" != "no"; then
		PCREINC="-I${with_libpcre_includes}"
		CPPFLAGS="${CPPFLAGS} ${PCREINC}"
	else	
		PCREINC="`pcre-config --cflags`"
		CPPFLAGS="${CPPFLAGS} ${PCREINC}"
	fi

	if test "$with_libpcre_libraries" != "no"; then
	   PCRELIB="-L${with_libpcre_libraries} -lpcre"
	   LDFLAGS="${LDFLAGS} ${PCRELIB}"
	else
		# this should give something like "-L/usr/lib -lpcre"
		PCRELIB="`pcre-config --libs`"
		LDFLAGS="${LDFLAGS} ${PCRELIB}"
	fi

	# PCRE configuration (required)
	# Verify that we have the headers
	PCRE_H=""
	AC_CHECK_HEADER(pcre.h,, PCRE_H="no")
	if test "$PCRE_H" = "no"; then
	  echo
	  echo "   ERROR!  Libpcre header not found, go get it from"
	  echo "   http://www.pcre.org"
	  exit 1
	fi

	# Verify that we have the library
	PCRE_L=""
	AC_CHECK_LIB(pcre, pcre_compile, ,PCRE_L="no")
	if test "$PCRE_L" = "no"; then
		echo 
		echo "    ERROR!  Libpcre library not found, go get it from"
		echo "    http://www.pcre.org"
		echo
		exit 1
	fi

	CPPFLAGS=$save_CPPFLAGS
	LDFLAGS=$save_LDFLAGS 
	LIBS=$save_LIBS

	AC_SUBST(PCREINC)
	AC_SUBST(PCRELIB)

fi # test x$extraflib = xtrue
806

807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
#
# SSL - based on stunnel's configure.ac (only for --enable-ssl)
#
checkssldir() { :
    if test -f "$1/include/openssl/ssl.h"
    then AC_DEFINE([HAVE_OPENSSL], 1, [whether we are using openssl])
        ssldir="$1"
        return 0
    fi
    if test -f "$1/include/ssl.h"
    then ssldir="$1"
        return 0
    fi
    return 1
}

if test x$ssl = xtrue; then
	AC_MSG_CHECKING([for SSL directory]);
fi
AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=DIR], [Location of installed SSL libraries/include files]),
	[
		# Check the specified localtion only
		if test x$ssl = xtrue; then
			checkssldir "$withval"
		else
832
			AC_MSG_ERROR(Please use --with-ssl only in conjunction with --enable-dimapi and --enable-ssl. You don't need to configure SSL if you are not going to use DiMAPI with secure sockets.)
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
		fi
	],
	[
		if test x$ssl = xtrue; then
			# Search default localtions of SSL library
			for maindir in /usr/local /usr/lib /usr/pkg /usr /var/ssl /opt; do
				for dir in $maindir $maindir/openssl $maindir/ssl; do
					checkssldir $dir && break 2
				done
			done
		fi
	]
)
if test x$ssl = xtrue; then
	if test -z "$ssldir"; then
		AC_MSG_RESULT([Not found])
		echo
		echo "Couldn't find your SSL library installation dir"
		echo "Use --with-ssl option to fix this problem"
		echo
		exit 1
	fi
	AC_MSG_RESULT([$ssldir])
	SSLINC="-I$ssldir/include"
	SSLLIB="-L$ssldir/lib -lssl"
	AC_SUBST(SSLINC)
	AC_SUBST(SSLLIB)
fi
861

862
#
863
# misc libs
864
#
865
save_LIBS=$LIBS
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
AC_CHECK_LIB(m, floor,,)
AC_CHECK_LIB(rt, sem_wait,,)
LIBS=$save_LIBS


# these checks will be good only if the special cases are handled
# appropriately in the code

# Checks for typedefs, structures, and compiler characteristics.
#AC_C_CONST
#AC_C_INLINE
#AC_TYPE_SIZE_T
#AC_HEADER_TIME
#AC_TYPE_UID_T
#AC_C_VOLATILE
# Checks for library functions
#AC_FUNC_ALLOCA
#AC_FUNC_ERROR_AT_LINE
#AC_FUNC_MALLOC
#AC_FUNC_MEMCMP
#AC_FUNC_REALLOC
#AC_FUNC_SELECT_ARGTYPES
#AC_TYPE_SIGNAL
#AC_FUNC_STRNLEN
#AC_FUNC_VPRINTF
#AC_CHECK_FUNCS([bzero getcwd gethostbyname gettimeofday memmove memset select socket strchr strdup strerror strrchr strstr strtol])

CONFDIR=`eval echo $sysconfdir/mapi`
AC_DEFINE_DIR(CONFDIR, CONFDIR, [configuration directory])
DATADIR=`eval echo $datadir/mapi`
AC_DEFINE_DIR(DATADIR, DATADIR, [directory for drivers and function librarues])

898
CFLAGS=-g
's avatar
committed
899
if test "$GCC" = "yes"; then
's avatar
committed
900
	CFLAGS="$CFLAGS -W -Wall -Wcast-align -Wpointer-arith"
's avatar
committed
901
fi
902

903 904 905 906 907 908 909 910 911
AC_MSG_NOTICE([generating files --------------------------------------------])
AC_CONFIG_FILES([
	Makefile
	src/Makefile
	src/common/Makefile
	src/lib/Makefile
	src/drivers/Makefile
	src/stdflib/Makefile
	src/trackflib/Makefile
's avatar
 
committed
912
	src/rulerflib/Makefile
913 914
	src/ipfixflib/Makefile
	src/anonflib/Makefile
915 916
	src/bpfcompiler/Makefile
	src/bpfcompiler/pcap/Makefile
917
	src/dagflib/Makefile
918
	src/napatechflib/Makefile
919
	src/extraflib/Makefile
920 921 922
	applications/Makefile
	applications/appmon/Makefile
	applications/mapidump/Makefile
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
	doc/Makefile
	etc/Makefile
	etc/mapi.conf
])
AC_OUTPUT

echo ""
echo "Configuration:"
echo "Install path:              ${prefix}"
echo "Binaries:                  ${prefix}/sbin"
echo "libmapi:                   ${prefix}/lib"
echo "Headers:                   ${prefix}/include"
echo "Configuration files:       ${CONFDIR}"
echo "drivers/functions/misc:    ${DATADIR}"
echo "MAPI function libraries:   ${MAPI_FUNC_LIBS}"
938
echo "mapid user group:          ${MAPI_GROUP}"
939 940 941
if test x$dimapi = xtrue; then
echo "option:                    DiMAPI"
fi
942 943 944
if test x$ssl = xtrue; then
echo "option:                    SSL"
fi
945 946 947
if test x$dag = xtrue; then
echo "option:                    support for DAG cards"
fi
948 949 950
if test x$napatech = xtrue; then
echo "option:                    support for Napatech cards"
fi
's avatar
committed
951 952 953
if test x$authentication = xtrue; then
echo "option:                    authentication on"
fi
954 955 956
if test x$reconnect = xtrue; then
echo "option:                    RECONNECTION"
fi