# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.62)
AC_INIT(istgt, 0.4)
AC_CONFIG_SRCDIR([src/istgt.c])
AC_CONFIG_HEADERS([src/config.h])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_SED
# Checks for libraries.
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([crypto], [MD5_Update])
AC_CHECK_LIB([cam], [cam_open_spec_device])
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_ST_BLOCKS
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([ftruncate memset realpath socket strcasecmp strchr strncasecmp strspn strtol strtoull])
# check compatibility
AC_SYS_LARGEFILE
AC_CHECK_HEADERS([aio.h sched.h uuid.h sys/disk.h sys/disklabel.h])
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([pthread_np.h], [], [],
[#if HAVE_PTHREAD_H
#include <pthread.h>
#endif
])
AC_CHECK_FUNCS([strlcpy arc4random srandomdev pthread_yield sched_yield])
AC_CHECK_FUNCS([pthread_set_name_np setproctitle])
AC_SUBST(MKDEP)
AC_PATH_PROG(MKDEP, "mkdep")
#if test -z "$MKDEP"; then
# AC_PATH_PROG(MKDEP, "makedepend")
#fi
# paths
configdir="$ac_default_prefix/etc/istgt"
mediadir="/var/istgt"
if test "$prefix" != "NONE"; then
configdir="$prefix/etc/istgt"
fi
AC_ARG_WITH(configdir,
[ --with-configdir=DIR (default $ac_default_prefix/etc/istgt)],
[case $withval in
yes|no)
;;
*)
configdir="$withval"
;;
esac])
AC_SUBST(configdir)
AC_ARG_WITH(mediadir,
[ --with-mediadir=DIR (default /var/istgt)],
[case $withval in
yes|no)
;;
*)
mediadir="$withval"
;;
esac])
AC_SUBST(mediadir)
# test for -Wall
saved_CFLAGS="$CFLAGS"
AC_MSG_CHECKING([whether the C compiler accepts -Wall])
CFLAGS="$CFLAGS -Wall"
AC_TRY_COMPILE(,,
AC_MSG_RESULT(yes); saved_CFLAGS="$CFLAGS",
AC_MSG_RESULT(no))
CFLAGS="$saved_CFLAGS"
# check enable features
AC_MSG_CHECKING([whether to use debug mode])
AC_ARG_ENABLE(debug,
[ --enable-debug enable debug(logging) ],
AC_MSG_RESULT(yes); AC_DEFINE(DEBUG, 1, [Define if enable debug]),
AC_MSG_RESULT(no))
AC_SUBST(DEBUG)
AC_MSG_CHECKING([which syslog facility to use])
AC_ARG_WITH(logfacility,
[ --with-logfacility syslog facility to log with (default "local7")],
[case $with_logfacility in
daemon|auth|authpriv|local0|local1|local2|local3|local4|local5|local6|local7)
logfacility=$with_logfacility
;;
*) AC_MSG_ERROR(["unsupported facility $with_logfacility"])
;;
esac],
[logfacility="local7"])
AC_DEFINE_UNQUOTED(DEFAULT_LOG_FACILITY, "$logfacility", [syslog facility])
AC_MSG_RESULT("$logfacility")
AC_MSG_CHECKING([which syslog priority to use])
AC_ARG_WITH(logpriority,
[ --with-logpriority syslog priority to log with (default "info")],
[case $with_logpriority in
emerg|alert|crit|err|warning|notice|info|debug)
logpriority=$with_logpriority
;;
*) AC_MSG_ERROR(["unsupported priority $with_logpriority"])
;;
esac],
[logpriority="info"])
AC_DEFINE_UNQUOTED(DEFAULT_LOG_PRIORITY, "$logpriority", [syslog priority])
AC_MSG_RESULT("$logpriority")
#AC_MSG_CHECKING([whether to use asynchronous io])
#AC_ARG_WITH(aio,
# [ --with-aio use aio (default "no")],
# [case $with_aio in
# yes)
# AC_DEFINE(USE_AIO, 1, [use aio])
# AC_MSG_RESULT(yes)
# ;;
# *)
# AC_MSG_RESULT(no)
# ;;
# esac],
# AC_MSG_RESULT(no))
#AC_SUBST(USE_AIO)
AC_CHECK_HEADERS([sys/types.h])
AC_CHECK_HEADERS([machine/atomic.h], [], [],
[#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
])
AC_CHECK_HEADERS([sys/atomic.h])
# for FeeeBSD
#AC_CHECK_FUNCS([atomic_store_rel_int atomic_load_acq_int])
#AC_CHECK_FUNCS([atomic_cmpset_ptr atomic_cmpset_64 atomic_cmpset_32])
# for NetBSD
#AC_CHECK_FUNCS([atomic_swap_uint atomic_or_uint_nv])
#AC_CHECK_FUNCS([atomic_cas_ptr atomic_cas_64 atomic_cas_32])
atomic="no"
AC_MSG_CHECKING([for atomic operations])
AC_TRY_LINK([#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <machine/atomic.h>
],
[
int x, y;
atomic_store_rel_int(&x, 1);
y = atomic_load_acq_int(&x);
],
[AC_DEFINE(USE_ATOMIC, [1], [Use atomic])
AC_DEFINE(HAVE_ATOMIC_STORE_REL_INT, [1], [Define 1 if you have the function.])
AC_DEFINE(HAVE_ATOMIC_LOAD_ACQ_INT, [1], [Define 1 if you have the function.])
atomic="yes"]
)
if test $atomic = "no"; then
AC_TRY_LINK([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/atomic.h>
],
[
unsigned int x, y;
atomic_swap_uint(&x, 1);
y = atomic_or_uint_nv(&x, 0);
],
[AC_DEFINE(USE_ATOMIC, [1], [Use atomic])
AC_DEFINE(HAVE_ATOMIC_SWAP_UINT, [1], [Define 1 if you have the function.])
AC_DEFINE(HAVE_ATOMIC_OR_UINT_NV, [1], [Define 1 if you have the function.])
atomic="yes"]
)
fi
AC_TRY_LINK([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/atomic.h>
],
[
membar_producer();
],
[AC_DEFINE(HAVE_MEMBAR_PRODUCER, [1], [Define 1 if you have the function.])]
)
AC_MSG_RESULT($atomic)
AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile doc/Makefile])
AC_CONFIG_FILES([src/build.h])
AC_OUTPUT
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>