AC_INIT(spread.c) AC_CONFIG_AUX_DIR(buildtools) AC_CONFIG_HEADER(config.h) AC_CANONICAL_HOST case "$host" in mips-sgi-irix* ) CC=cc CFLAGS="-n32 -signed" ;; esac AC_PROG_CC AC_C_BIGENDIAN # Checks for programs. AC_PROG_CPP AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_YACC AC_PATH_PROG(LEX, flex) AC_SUBST(LEX) AC_PATH_PROG(AR, ar) AC_PATH_PROGS(PERL, perl5 perl) AC_SUBST(PERL) if test -z "$AR" ; then AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***]) fi if test -z "$LD" ; then LD=$CC fi AC_SUBST(LD) # C Compiler features AC_C_INLINE if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall" fi # Allow user to specify flags AC_ARG_WITH(cflags, [ --with-cflags Specify additional flags to pass to compiler], [ if test "x$withval" != "xno" ; then CFLAGS="$CFLAGS $withval" fi ] ) AC_ARG_WITH(cppflags, [ --with-cppflags Specify additional flags to pass to preprocessor] , [ if test "x$withval" != "xno"; then CPPFLAGS="$CPPFLAGS $withval" fi ] ) AC_ARG_WITH(ldflags, [ --with-ldflags Specify additional flags to pass to linker], [ if test "x$withval" != "xno" ; then LDFLAGS="$LDFLAGS $withval" fi ] ) AC_ARG_WITH(libs, [ --with-libs Specify additional libraries to link with], [ if test "x$withval" != "xno" ; then LIBS="$LIBS $withval" fi ] ) # Checks for libraries. OLDLDFLAGS=$LDFLAGS LDFLAGS= AC_PTHREAD_FREEBSD THLDFLAGS=$LDFLAGS AC_SUBST(THLDFLAGS) LDFLAGS=$OLDLDFLAGS OLDLIBS=$LIBS LIBS= AC_CHECK_LIB(pthread, pthread_create, , ) AC_CHECK_LIB(thread, thr_create, , ) AC_CHECK_LIB(posix4, sem_wait, , ) THLIBS=$LIBS AC_SUBST(THLIBS) LIBS=$OLDLIBS AC_CHECK_LIB(nsl, gethostbyaddr, , ) AC_CHECK_LIB(socket, socket, , ) AC_FUNC_STRFTIME # Checks for header files. AC_CHECK_HEADERS(arpa/inet.h assert.h errno.h grp.h limits.h netdb.h netinet/in.h netinet/tcp.h process.h pthread.h pwd.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/inttypes.h sys/ioctl.h sys/param.h sys/socket.h sys/stat.h sys/time.h sys/timeb.h sys/types.h sys/uio.h sys/un.h sys/filio.h time.h unistd.h windows.h winsock.h) dnl Checks for library functions. AC_CHECK_FUNCS(bcopy inet_aton inet_ntoa inet_ntop memmove setsid snprintf strerror lrand48) dnl Checks for time functions AC_CHECK_FUNCS(gettimeofday time) # Check for broken snprintf if test "x$ac_cv_func_snprintf" = "xyes" ; then AC_MSG_CHECKING([whether snprintf correctly terminates long strings]) AC_TRY_RUN( [ #include int main(void){char b[5];snprintf(b,5,"123456789");return(b[4]!='\0');} ], [AC_MSG_RESULT(yes)], [ AC_MSG_RESULT(no) AC_DEFINE(BROKEN_SNPRINTF) AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor]) ] ) fi # Cheap hack to ensure NEWS-OS libraries are arranged right. if test ! -z "$SONY" ; then LIBS="$LIBS -liberty"; fi # 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) # More checks for data types AC_CACHE_CHECK([for windows arch], ac_cv_arch_win, [ AC_TRY_COMPILE( [ #include ], [ CRITICAL_SECTION mutex; InitializeCriticalSection(mutex); ], [ ac_cv_arch_win="yes" ], [ ac_cv_arch_win="no" ] ) ]) if test "x$ac_cv_arch_win" = "xyes" ; then AC_DEFINE(ARCH_PC_WIN95) fi AC_CACHE_CHECK([for struct timezone type], ac_cv_have_struct_timezone, [ AC_TRY_COMPILE( [ #include #include ], [ struct timezone opt; ], [ ac_cv_have_struct_timezone="yes" ], [ ac_cv_have_struct_timezone="no" ] ) ]) if test "x$ac_cv_have_struct_timezone" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_TIMEZONE) fi AC_CACHE_CHECK([for struct sockopt_len_t type], ac_cv_have_sockopt_len_t, [ AC_TRY_COMPILE( [ #include #include ], [ static sockopt_len_t opt; opt=0; ], [ ac_cv_have_sockopt_len_t="yes" ], [ ac_cv_have_sockopt_len_t="no" ] ) ]) if test "x$ac_cv_have_sockopt_len_t" = "xyes" ; then AC_DEFINE(HAVE_SOCKOPT_LEN_T) fi AC_CACHE_CHECK([for struct msghdr type], ac_cv_have_struct_msghdr, [ AC_TRY_COMPILE( [ #include #include ], [ static struct msghdr msg; msg.msg_namelen = 1; ], [ ac_cv_have_struct_msghdr="yes" ], [ ac_cv_have_struct_msghdr="no" ] ) ]) if test "x$ac_cv_have_struct_msghdr" = "xno" ; then AC_DEFINE(ARCH_SCATTER_NONE) else have_scatter="no" AC_CACHE_CHECK([for struct msghdr accrights], ac_cv_have_struct_msghdr_acc, [ AC_TRY_COMPILE( [ #include #include ], [ static struct msghdr msg; msg.msg_accrightslen = 0; ], [ ac_cv_have_struct_msghdr_acc="yes" ], [ ac_cv_have_struct_msghdr_acc="no" ] ) ]) if test "x$ac_cv_have_struct_msghdr_acc" = "xyes" ; then AC_DEFINE(ARCH_SCATTER_ACCRIGHTS) have_scatter="yes" fi if test "x$have_scatter" = "xno" ; then AC_CACHE_CHECK([for struct msghdr control], ac_cv_have_struct_msghdr_ctl, [ AC_TRY_COMPILE( [ #include #include ], [ static struct msghdr msg; msg.msg_controllen = 0; ], [ ac_cv_have_struct_msghdr_ctl="yes" ], [ ac_cv_have_struct_msghdr_ctl="no" ] ) ]) if test "x$ac_cv_have_struct_msghdr_ctl" = "xyes" ; then AC_DEFINE(ARCH_SCATTER_CONTROL) have_scatter="yes" fi fi if test "x$have_scatter" = "xno" ; then AC_MSG_ERROR([*** cannot determine which scatter type to use ***]) fi fi AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [ AC_TRY_COMPILE( [ #include ], [ u_int a; a = 1;], [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no" ] ) ]) if test "x$ac_cv_have_u_int" = "xyes" ; then AC_DEFINE(HAVE_U_INT) have_u_int=1 fi AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [ AC_TRY_COMPILE( [ #include ], [ 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_INTXX_T) have_intxx_t=1 fi AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [ AC_TRY_COMPILE( [ #include ], [ 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) have_int64_t=1 fi AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [ AC_TRY_COMPILE( [ #include ], [ 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_INTXX_T) have_u_intxx_t=1 fi AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [ AC_TRY_COMPILE( [ #include ], [ 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) have_u_int64_t=1 fi if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \ test "x$ac_cv_header_sys_bitypes_h" = "xyes") then AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h]) AC_TRY_COMPILE( [ #include ], [ int8_t a; int16_t b; int32_t c; u_int8_t e; u_int16_t f; u_int32_t g; a = b = c = e = f = g = 1; ], [ AC_DEFINE(HAVE_U_INTXX_T) AC_DEFINE(HAVE_INTXX_T) AC_MSG_RESULT(yes) ], [AC_MSG_RESULT(no)] ) 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 ], [ 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_UINTXX_T) fi fi AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [ AC_TRY_COMPILE( [ #include #include ], [socklen_t foo; foo = 1235;], [ ac_cv_have_socklen_t="yes" ], [ ac_cv_have_socklen_t="no" ] ) ]) if test "x$ac_cv_have_socklen_t" = "xyes" ; then AC_DEFINE(HAVE_SOCKLEN_T) fi AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [ AC_TRY_COMPILE( [ #include ], [ size_t foo; foo = 1235; ], [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no" ] ) ]) if test "x$ac_cv_have_size_t" = "xyes" ; then AC_DEFINE(HAVE_SIZE_T) fi AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [ AC_TRY_COMPILE( [ #include ], [ ssize_t foo; foo = 1235; ], [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no" ] ) ]) if test "x$ac_cv_have_ssize_t" = "xyes" ; then AC_DEFINE(HAVE_SSIZE_T) fi AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [ AC_TRY_COMPILE( [ #include ], [ clock_t foo; foo = 1235; ], [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no" ] ) ]) if test "x$ac_cv_have_clock_t" = "xyes" ; then AC_DEFINE(HAVE_CLOCK_T) fi AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [ AC_TRY_COMPILE( [ #include #include ], [ sa_family_t foo; foo = 1235; ], [ ac_cv_have_sa_family_t="yes" ], [ AC_TRY_COMPILE( [ #include #include #include ], [ sa_family_t foo; foo = 1235; ], [ ac_cv_have_sa_family_t="yes" ], [ ac_cv_have_sa_family_t="no" ] )] ) ]) if test "x$ac_cv_have_sa_family_t" = "xyes" ; then AC_DEFINE(HAVE_SA_FAMILY_T) fi AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [ AC_TRY_COMPILE( [ #include #include ], [ struct sockaddr_storage s; ], [ ac_cv_have_struct_sockaddr_storage="yes" ], [ ac_cv_have_struct_sockaddr_storage="no" ] ) ]) if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE) fi AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [ AC_TRY_COMPILE( [ #include #include ], [ struct sockaddr_in6 s; s.sin6_family = 0; ], [ ac_cv_have_struct_sockaddr_in6="yes" ], [ ac_cv_have_struct_sockaddr_in6="no" ] ) ]) if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6) fi AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [ AC_TRY_COMPILE( [ #include #include ], [ struct in6_addr s; s.s6_addr[0] = 0; ], [ ac_cv_have_struct_in6_addr="yes" ], [ ac_cv_have_struct_in6_addr="no" ] ) ]) if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_IN6_ADDR) fi AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [ AC_TRY_COMPILE( [ #include #include #include ], [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ], [ ac_cv_have_struct_addrinfo="yes" ], [ ac_cv_have_struct_addrinfo="no" ] ) ]) if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_ADDRINFO) fi AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [ AC_TRY_COMPILE( [ #include ], [ struct timeval tv; tv.tv_sec = 1;], [ ac_cv_have_struct_timeval="yes" ], [ ac_cv_have_struct_timeval="no" ] ) ]) if test "x$ac_cv_have_struct_timeval" = "xyes" ; then AC_DEFINE(HAVE_STRUCT_TIMEVAL) have_struct_timeval=1 fi AC_CACHE_CHECK([for sun_len field in struct sockaddr_un], ac_cv_have_sun_len_in_struct_sockaddr_un, [ AC_TRY_COMPILE( [ #include #include ], [ struct sockaddr_un s; s.sun_len = 1; ], [ ac_cv_have_sun_len_in_struct_sockaddr_un="yes" ], [ ac_cv_have_sun_len_in_struct_sockaddr_un="no" ], ) ]) if test "x$ac_cv_have_sun_len_in_struct_sockaddr_un" = "xyes" ; then AC_DEFINE(HAVE_SUN_LEN_IN_SOCKADDR_UN) fi AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage], ac_cv_have_ss_family_in_struct_ss, [ AC_TRY_COMPILE( [ #include #include ], [ struct sockaddr_storage s; s.ss_family = 1; ], [ ac_cv_have_ss_family_in_struct_ss="yes" ], [ ac_cv_have_ss_family_in_struct_ss="no" ], ) ]) if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then AC_DEFINE(HAVE_SS_FAMILY_IN_SS) fi AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage], ac_cv_have___ss_family_in_struct_ss, [ AC_TRY_COMPILE( [ #include #include ], [ struct sockaddr_storage s; s.__ss_family = 1; ], [ ac_cv_have___ss_family_in_struct_ss="yes" ], [ ac_cv_have___ss_family_in_struct_ss="no" ] ) ]) if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then AC_DEFINE(HAVE___SS_FAMILY_IN_SS) fi AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [ AC_TRY_COMPILE( [ #include ], [ pid_t foo; foo = 1235; ], [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no" ] ) ]) if test "x$ac_cv_have_pid_t" = "xyes" ; then AC_DEFINE(HAVE_PID_T) fi AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [ AC_TRY_LINK([], [ extern char *__progname; printf("%s", __progname); ], [ ac_cv_libc_defines___progname="yes" ], [ ac_cv_libc_defines___progname="no" ] ) ]) if test "x$ac_cv_libc_defines___progname" = "xyes" ; then AC_DEFINE(HAVE___PROGNAME) fi AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ AC_TRY_LINK([], [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);], [ ac_cv_libc_defines_sys_errlist="yes" ], [ ac_cv_libc_defines_sys_errlist="no" ] ) ]) if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then AC_DEFINE(HAVE_SYS_ERRLIST) fi AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ AC_TRY_LINK([], [ extern int sys_nerr; printf("%i", sys_nerr);], [ ac_cv_libc_defines_sys_nerr="yes" ], [ ac_cv_libc_defines_sys_nerr="no" ] ) ]) if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then AC_DEFINE(HAVE_SYS_NERR) fi for i in `grep "SP_....._VERSION" ${srcdir}/spread_params.h | sed -e 's/#define//g' -e 's/[ ]//g' -e 's/VERSION/VERSION=/g;'` do eval $i done AC_MSG_CHECKING([Check Spread's major version]) AC_MSG_RESULT($SP_MAJOR_VERSION) AC_SUBST(SP_MAJOR_VERSION) AC_MSG_CHECKING([Check Spread's minor version]) AC_MSG_RESULT($SP_MINOR_VERSION) AC_SUBST(SP_MINOR_VERSION) AC_MSG_CHECKING([Check Spread's patch version]) AC_MSG_RESULT($SP_PATCH_VERSION) AC_SUBST(SP_PATCH_VERSION) # Options from here on. Some of these are preset by platform above AC_ARG_WITH(catman, [ --with-mantype=man|cat|doc Set man page type], [ case "$withval" in man|cat|doc) MANTYPE=$withval ;; *) AC_MSG_ERROR(invalid man type: $withval) ;; esac ] ) if test -z "$MANTYPE"; then AC_PATH_PROGS(NROFF, nroff awf, /bin/false, /usr/bin:/usr/ucb) if ${NROFF} -mdoc ${srcdir}/docs/spread.1 >/dev/null 2>&1; then MANTYPE=doc elif ${NROFF} -man ${srcdir}/docs/spread.1 >/dev/null 2>&1; then MANTYPE=man else MANTYPE=cat fi fi AC_SUBST(MANTYPE) if test "$MANTYPE" = "doc"; then mansubdir=man; else mansubdir=$MANTYPE; fi AC_SUBST(mansubdir) # Where to place spread.pid piddir=/var/run AC_ARG_WITH(pid-dir, [ --with-pid-dir=PATH Specify location of spread.pid file], [ if test "x$withval" != "xno" ; then piddir=$withval fi ] ) # make sure the directory exists if test ! -d $piddir ; then piddir=`eval echo ${sysconfdir}` case $piddir in NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;; esac fi AC_DEFINE_UNQUOTED(_PATH_SPREAD_PIDDIR, "$piddir") AC_SUBST(piddir) # Where to find spread.conf and other config files etcdir=`eval echo ${sysconfdir}` case $etcdir in NONE/*) etcdir=`echo $etcdir | sed "s~NONE~$ac_default_prefix~"` ;; esac AC_DEFINE_UNQUOTED(SPREAD_ETCDIR, "$etcdir") AC_EXEEXT LIBSPSO=none LIBTSPSO=none case "$host" in *-*-darwin*) SHCC=$CC SHCFLAGS="$CFLAGS -fPIC" SHCPPFLAGS="$CPPFLAGS" SHLD="$CC -dynamiclib" SHLDFLAGS="$SHLDFLAGS $LDFLAGS" SHLIBS=$LIBS LIBSPSO="libspread.dylib" LIBTSPSO="libtspread.dylib" ;; mips-sgi-irix*) LIBSPSO=none LIBTSPSO=none ;; *-*-*) SHCC=$CC SHCFLAGS="$CFLAGS -fPIC" SHCPPFLAGS="$CPPFLAGS" SHLD="$CC -shared" SHLDFLAGS="$SHLDFLAGS $LDFLAGS" SHLIBS=$LIBS LIBSPSO="libspread.so" LIBTSPSO="libtspread.so" ;; esac AC_SUBST(SHCC) AC_SUBST(SHCFLAGS) AC_SUBST(SHCPPFLAGS) AC_SUBST(SHLD) AC_SUBST(SHLDFLAGS) AC_SUBST(SHLIBS) AC_SUBST(LIBSPSO) AC_SUBST(LIBTSPSO) AC_OUTPUT(Makefile) # Print summary of options # Someone please show me a better way :) A=`eval echo ${prefix}` ; A=`eval echo ${A}` B=`eval echo ${bindir}` ; B=`eval echo ${B}` C=`eval echo ${sbindir}` ; C=`eval echo ${C}` D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}` E=`eval echo ${libdir}` ; E=`eval echo ${E}` F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}` G=`eval echo ${piddir}` ; G=`eval echo ${G}` H=`eval echo ${LIBSPSO}`; H=`eval echo ${H}` I=`eval echo ${LIBTSPSO}`; I=`eval echo ${I}` J=`eval echo ${includedir}`; J=`eval echo ${J}` echo "" echo "Spread has been configured with the following options:" echo " User binaries: $B" echo " System binaries: $C" echo " Configuration files: $D" echo " User libraries: $E" echo " Shared Spread Library: $H" echo "Shared Thread-safe Spread Library: $I" echo " Header files: $J" echo " Manual pages: $F" echo " PID file: $G" echo " Manpage format: $MANTYPE" echo "" echo " Host: ${host}" echo " Compiler: ${CC}" echo " Compiler flags: ${CFLAGS}" echo "Preprocessor flags: ${CPPFLAGS}" echo " Linker flags: ${LDFLAGS}" echo " Libraries: ${LIBS}" echo ""