AC_PREREQ([2.57]) m4_define([milkway_major], 0) m4_define([milkway_minor], 0) m4_define([milkway_micro], 1) m4_define([milkway_version],[milkway_major.milkway_minor.milkway_micro]) AC_INIT(milkway, milkway_version, "Luo Jinghua ", milkway) AM_INIT_AUTOMAKE([dist-bzip2]) AM_CONFIG_HEADER(config.h) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") AC_PROG_CC AM_PROG_CC_C_O AC_PROG_LIBTOOL AC_CHECK_FUNCS([getisax]) AC_C_BIGENDIAN AC_C_INLINE m4_define([lt_current], [milkway_minor]) m4_define([lt_revision], [milkway_micro]) m4_define([lt_age], [milkway_minor]) LT_VERSION_INFO="lt_current:lt_revision:lt_age" MILKWAY_VERSION_MAJOR=milkway_major() AC_SUBST(MILKWAY_VERSION_MAJOR) MILKWAY_VERSION_MINOR=milkway_minor() AC_SUBST(MILKWAY_VERSION_MINOR) MILKWAY_VERSION_MICRO=milkway_micro() AC_SUBST(MILKWAY_VERSION_MICRO) AC_SUBST(LT_VERSION_INFO) # Check for dependencies #PKG_CHECK_MODULES(DEP, x11) changequote(,)dnl if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-Wall[\ \ ]*) ;; *) CFLAGS="$CFLAGS -Wall" ;; esac fi changequote([,])dnl dnl AC_PATH_PROG(PERL, perl, no) dnl if test "x$PERL" = xno; then dnl AC_MSG_ERROR([Perl is required to build milkway.]) dnl fi dnl AC_SUBST(PERL) dnl ========================================================================= dnl -fvisibility stuff have_gcc4=no AC_MSG_CHECKING(for -fvisibility) AC_COMPILE_IFELSE([ #if defined(__GNUC__) && (__GNUC__ >= 4) #else error Need GCC 4.0 for visibility #endif int main () { return 0; } ], have_gcc4=yes) if test "x$have_gcc4" = "xyes"; then CFLAGS="$CFLAGS -fvisibility=hidden" fi AC_MSG_RESULT($have_gcc4) have_sunstudio8=no AC_MSG_CHECKING([for -xldscope (Sun compilers)]) AC_COMPILE_IFELSE([ #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) #else error Need Sun Studio 8 for visibility #endif int main () { return 0; } ], have_sunstudio8=yes) if test "x$have_sunstudio8" = "xyes"; then CFLAGS="$CFLAGS -xldscope=hidden" fi AC_MSG_RESULT($have_sunstudio8) dnl =========================================================================== PKG_PROG_PKG_CONFIG() if test "x$PKG_CONFIG" = x; then AC_MSG_ERROR([pkg-config >= $PKGCONFIG_REQUIRED required but not found (http://pkgconfig.freedesktop.org/)]) fi dnl Check for recent pkg-config which supports Requires.private case `$PKG_CONFIG --version` in [0.?|0.?.?|0.1[0-7]|0.1[0-7].?]) PKGCONFIG_REQUIRES="Requires"; ;; *) PKGCONFIG_REQUIRES="Requires.private"; ;; esac AC_SUBST(PKGCONFIG_REQUIRES) AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = "xyes") MILKWAY_BIGENDIAN AC_ARG_ENABLE(atomic, [AS_HELP_STRING([--disable-atomic], [disable use of native atomic operations])], [use_atomic=$enableval], [use_atomic=yes]) AS_IF([test "x$use_atomic" = "xyes"], [ MILKWAY_CHECK_NATIVE_ATOMIC_PRIMITIVES MILKWAY_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER ]) AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(size_t) AC_MSG_CHECKING([for native Win32]) case "$host" in *-*-mingw*) milkway_os_win32=yes ;; *) milkway_os_win32=no ;; esac AC_MSG_RESULT([$milkway_os_win32]) AM_CONDITIONAL(OS_WIN32, test "$milkway_os_win32" = "yes") AC_MSG_CHECKING([for Sun Solaris (non-POSIX ctime_r)]) case "$host" in *-*-solaris*) CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" solaris_posix_pthread=yes ;; *) solaris_posix_pthread=no ;; esac AC_MSG_RESULT([$solaris_posix_pthread]) dnl ==================================================================== dnl Library checks dnl ==================================================================== AC_CHECK_LIBM LIBS="$LIBS $LIBM" AC_CHECK_LIB(rt, sched_yield, [RT_LIBS=-lrt], [RT_LIBS=]) MILKWAY_LIBS="$MILKWAY_LIBS $RT_LIBS" has_shm_open= AC_CHECK_LIB(rt, shm_open, [ SHM_LIBS=-lrt has_shm_open=yes ], [SHM_LIBS=]) AM_CONDITIONAL(HAVE_SHM, test "x$has_shm_open" = "xyes") AC_SUBST(SHM_LIBS) AC_CHECK_LIB(socket, connect, [SOCKET_LIBS=-lsocket], [SOCKET_LIBS=]) MILKWAYBOILERPLATE_LIBS=$SOCKET_LIBS AC_SUBST(MILKWAYBOILERPLATE_LIBS) dnl ==================================================================== dnl Header/function checks dnl ==================================================================== dnl Checks for precise integer types AC_CHECK_HEADERS([stdint.h inttypes.h sys/int_types.h]) AC_CHECK_TYPES([uint64_t]) dnl Check for socket support AC_CHECK_HEADERS([fcntl.h unistd.h signal.h sys/stat.h sys/socket.h sys/poll.h sys/un.h strings.h]) dnl Check for infinite loops AC_CHECK_FUNCS([alarm]) dnl check for CPU affinity support AC_CHECK_HEADERS([sched.h], [AC_CHECK_FUNCS([sched_getaffinity])]) dnl check for mmap support AC_CHECK_HEADERS([sys/mman.h], [AC_CHECK_FUNCS([mmap])]) dnl check for clock_gettime() support save_LIBS="$LIBS" LIBS="$LIBS $RT_LIBS" AC_CHECK_HEADERS([time.h], [AC_CHECK_FUNCS([clock_gettime])]) LIBS="$save_LIBS" dnl check for GNU-extensions to fenv AC_CHECK_HEADER(fenv.h, [AC_CHECK_FUNCS(feenableexcept fedisableexcept feclearexcept)]) dnl check for misc headers and functions AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h fenv.h]) AC_CHECK_FUNCS([vasnprintf link ctime_r drand48 flockfile ffs]) AC_CHECK_HEADERS([sys/poll.h sys/select.h]) AC_CHECK_FUNCS([poll select]) AC_CHECK_HEADERS([stdarg.h]) AC_CHECK_FUNCS([strcmp strcasecmp stricmp memcpy memmove]) dnl check for win32 headers (this detects mingw as well) AC_CHECK_HEADERS([windows.h], have_windows=yes, have_windows=no) dnl Possible headers for mkdir AC_CHECK_HEADERS([sys/stat.h io.h]) AC_CHECK_FUNC(mkdir, [AC_MSG_CHECKING([mkdir variant]) mkdir_variant="unknown" save_CFLAGS="$CFLAGS" CFLAGS=$WARN_CFLAGS AC_TRY_COMPILE([ #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_IO_H #include #endif ], [mkdir ("hello.world", 0777)], mkdir_variant="mkdir(path, mode)", [AC_TRY_COMPILE([ #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_IO_H #include #endif ], [mkdir ("hello.world")], mkdir_variant="mkdir(path)")]) AC_MSG_RESULT([$mkdir_variant]) CFLAGS="$save_CFLAGS" if test "x$mkdir_variant" = "xmkdir(path, mode)"; then AC_DEFINE(HAVE_MKDIR, 2, [Define to non-zero if your system has mkdir, and to 2 if your version of mkdir requires a mode parameter]) else AC_DEFINE(HAVE_MKDIR, 1, [Define to non-zero if your system has mkdir, and to 2 if your version of mkdir requires a mode parameter]) fi]) # Checks for library functions. AC_CHECK_FUNCS([gettimeofday memmove memset select]) dnl Use lots of warning flags with with gcc and compatible compilers dnl Note: if you change the following variable, the cache is automatically dnl skipped and all flags rechecked. So there's no need to do anything dnl else. If for any reason you need to force a recheck, just change dnl MAYBE_WARN in an ignorable way (like adding whitespace) # -Wcast-align generates lots of false positive reports we need to # cast image data from uint8_t to uin32_t. MAYBE_WARN="-Wall -Wextra \ -Wold-style-definition \ -Wmissing-declarations -Werror-implicit-function-declaration \ -Wnested-externs -Wpointer-arith -Wwrite-strings \ -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes \ -Wpacked -Wswitch-enum -Wmissing-format-attribute \ -Wbad-function-cast -Wvolatile-register-var \ -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \ -Wno-missing-field-initializers -Wno-unused-parameter \ -Wno-attributes -Wno-long-long -Winline" dnl Sun Studio 12 likes to rag at us for abusing enums like dnl having milkway_status_t variables hold milkway_int_status_t dnl values. It's bad, we know. Now please be quiet. MAYBE_WARN="$MAYBE_WARN -erroff=E_ENUM_TYPE_MISMATCH_ARG \ -erroff=E_ENUM_TYPE_MISMATCH_OP" dnl We also abuse the warning-flag facility to enable other compiler dnl options. Namely, the following: MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common" dnl Also to turn various gcc/glibc-specific preprocessor checks MAYBE_WARN="$MAYBE_WARN -Wp,-D_FORTIFY_SOURCE=2" # invalidate cached value if MAYBE_WARN has changed if test "x$milkway_cv_warn_maybe" != "x$MAYBE_WARN"; then unset milkway_cv_warn_cflags fi AC_CACHE_CHECK([for supported warning flags], milkway_cv_warn_cflags, [ echo WARN_CFLAGS="" # Some warning options are not supported by all versions of # gcc, so test all desired options against the current # compiler. # # Note that there are some order dependencies # here. Specifically, an option that disables a warning will # have no net effect if a later option then enables that # warnings, (perhaps implicitly). So we put some grouped # options (-Wall and -Wextra) up front and the -Wno options # last. for W in $MAYBE_WARN; do MILKWAY_CC_TRY_FLAG([$W],, [WARN_CFLAGS="$WARN_CFLAGS $W"]) done milkway_cv_warn_cflags=$WARN_CFLAGS milkway_cv_warn_maybe=$MAYBE_WARN AC_MSG_CHECKING([which warning flags were supported]) ]) WARN_CFLAGS="$milkway_cv_warn_cflags" MILKWAY_CFLAGS="$MILKWAY_CFLAGS $WARN_CFLAGS" AC_SUBST(WARN_CFLAGS) AC_SUBST(MILKWAY_CFLAGS) AC_SUBST(MILKWAY_LIBS) # We only wish to enable attribute(warn_unused_result) if we can prevent # gcc from generating thousands of warnings about the misapplication of the # attribute to void functions and variables. AC_CACHE_CHECK([how to enable unused result warnings], milkway_cv_warn_unused_result, [ milkway_cv_warn_unused_result="" if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then MILKWAY_CC_TRY_FLAG_SILENT( [-Wno-attributes], [__attribute__((__warn_unused_result__)) void f (void) {} __attribute__((__warn_unused_result__)) int g;], [milkway_cv_warn_unused_result="__attribute__((__warn_unused_result__))"]) fi ]) AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$milkway_cv_warn_unused_result], [Define to the value your compiler uses to support the warn-unused-result attribute]) AC_CHECK_HEADERS(dlfcn.h, [have_dlsym=yes], [have_dlsym=no]) AM_CONDITIONAL(MILKWAY_HAS_DL, test "x$have_dl" = "xyes") ACX_PTHREAD MILKWAY_LIBS="$MILKWAY_LIBS $PTHREAD_LIBS" MILKWAY_CFLAGS="$MILKWAY_CFLAGS $PTHREAD_CFLAGS" AC_ARG_ENABLE(gtk, [AC_HELP_STRING([--enable-gtk], [enable tests using GTK+ [default=auto]])], [enable_gtk=$enableval], [enable_gtk=auto]) PKG_PROG_PKG_CONFIG if test $enable_gtk = auto ; then PKG_CHECK_EXISTS([gtk+-2.0], [enable_gtk=yes], [enable_gtk=no]) fi if test $enable_gtk = yes ; then PKG_CHECK_MODULES(GTK, [gtk+-2.0]) fi AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) AC_SUBST(DEP_CFLAGS) AC_SUBST(DEP_LIBS) AC_OUTPUT([Makefile server/Makefile client/Makefile milkway/Makefile milkway/test/Makefile])