# Process this file with autoconf to produce a configure script. #------------------------------------------------------------------------------ # This file is part of the "Base Functions and Types" library, intended to # simplify and enhance portability, memory and I/O use for scientific codes. # # Copyright (C) 2004-2006 EDF # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Initialization #------------------------------------------------------------------------------ m4_define([bft_licence_c_comment], [/* This file is part of the "Base Functions and Types" library, intended to simplify and enhance portability, memory and I/O use for scientific codes. Copyright (C) 2004-2006 EDF This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */]) m4_define([bft_major_version], [1]) m4_define([bft_minor_version], [0]) m4_define([bft_release_version], [3]) m4_define([bft_version_string], [bft_major_version.bft_minor_version.bft_release_version]) AC_INIT([bft],[bft_version_string],[yvan.fournier@edf.fr]) AC_CONFIG_SRCDIR([src/bft_config_defs.h]) # Use the config directory for libtool stuff ... AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(config) AC_SUBST(ac_aux_dir) AC_CANONICAL_TARGET AC_CONFIG_HEADERS([bft_config_priv.h:bft_config_priv.h.in]) AM_INIT_AUTOMAKE AH_TOP([#ifndef __BFT_CONFIG_PRIV_H__ #define __BFT_CONFIG_PRIV_H__ /* This file is part of the "Base Functions and Types" library, intended to simplify and enhance portability, memory and I/O use for scientific codes. */]) AH_BOTTOM([#endif /* __BFT_CONFIG_PRIV_H__ */]) #Define public configuration file BFT_AC_CONFIG_PUBL_INIT([bft_config.h]) BFT_AC_CONFIG_PUBL_VERBATIM([bft_licence_c_comment]) # Get the ac_aux_dir macro defined in top level Makefile.am AC_SUBST(ac_aux_dir) AM_MAINTAINER_MODE # Version information BFT_AC_CONFIG_PUBL_DEFINE_STRING(BFT_VERSION, bft_version_string, [Complete version number]) BFT_AC_CONFIG_PUBL_DEFINE(BFT_MAJOR_VERSION, bft_major_version, [Major version number]) BFT_AC_CONFIG_PUBL_DEFINE(BFT_MINOR_VERSION, bft_minor_version, [Minor version number]) BFT_AC_CONFIG_PUBL_DEFINE(BFT_RELEASE_VERSION, bft_release_version, [Release version number]) #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Checks for programs. #------------------------------------------------------------------------------ # Check for C compiler #--------------------- user_CPPFLAGS=$CPPFLAGS user_CFLAGS=$CFLAGS user_LDFLAGS=$LDFLAGS AC_PROG_CC(cc gcc) AC_PROG_INSTALL AC_PROG_LN_S # Debug or production compilation mode (debug by default) ? AC_ARG_ENABLE(debug, [ --enable-debug enable debugging (reduces optimization)], [ case "${enableval}" in yes) debug=true ;; no) debug=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; esac ], [ debug=false ] ) AM_CONDITIONAL(DEBUG, test x$debug = xtrue) # Optionally deactivate automatic determination of flags on known systems AC_ARG_ENABLE(auto-flags, [ --disable-auto-flags Do not define *FLAGS on known systems], [ case "${enableval}" in yes) auto_flags=true ;; no) auto_flags=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-auto-flags]) ;; esac ], [ auto_flags=true ] ) # Default compiler debug options (may be modified # by defining G_CFLAGS in the environment) #------------------------------------------------ if test "x$auto_flags" = "xtrue" ; then # Source associated recommended compiler options if test -f "$srcdir/config/bft_auto_flags.sh" ; then AC_MSG_NOTICE([sourcing config/bft_auto_flags.sh (test for known compilers)]) . "$srcdir/config/bft_auto_flags.sh" else AC_MSG_WARN([config/bft_auto_flags.sh default configuration file not found]) fi if test "x$user_CPPFLAGS" = "x"; then CPPFLAGS="$cppflags_default" else AC_MSG_NOTICE([default CPPFLAGS overridden by user definition]) fi if test "x$user_CFLAGS" = "x"; then CFLAGS="$cflags_default" if test "x$debug" = xtrue; then CFLAGS="${CFLAGS} $cflags_default_dbg" else CFLAGS="${CFLAGS} $cflags_default_opt" fi else AC_MSG_NOTICE([default CFLAGS overridden by user definition]) fi if test "x$user_LDFLAGS" = "x"; then LDFLAGS="$ldflags_default" if test "x$debug" = xtrue; then LDFLAGS="${LDFLAGS} $ldflags_default_dbg" else LDFLAGS="${LDFLAGS} $ldflags_default_opt" fi else AC_MSG_NOTICE([default LDFLAGS overridden by user definition]) fi fi # Optional additional user flags #------------------------------- if test "x$CPP_ADD" != x ; then CPPFLAGS="${CPPFLAGS} $CPP_ADD" fi if test "x$CC_ADD" != x ; then CFLAGS="${CFLAGS} $CC_ADD" fi if test "x$LD_ADD" != x ; then LDFLAGS="${LDFLAGS} $LD_ADD" fi if test "x$LIBS_ADD" != x ; then LIBS="${LIBS} $LIBS_ADD" fi # Add some preprocessor flags to include additional system features #------------------------------------------------------------------ case "$host_os" in linux*) CPPFLAGS="${CPPFLAGS} -D_POSIX_C_SOURCE=200112L" ;; osf*) CPPFLAGS="${CPPFLAGS} -D_OSF_SOURCE" ;; hpux*) CPPFLAGS="${CPPFLAGS} -D_HPUX_SOURCE" ;; esac # We may only turn on processing for libtool now that the basic compiler # and linker flags are set (to avoid issues with linkers with different # modes such as 32 and 64 bit which may be modified by compiler or # linker flags). # AC_DISABLE_SHARED may not be used inside a test, as it seems to # take effect whether the result is true or not (maybe due to a bug), # so we directly use autoconf's enable_shared variable. if test "x$bft_disable_shared" = "xyes" ; then enable_shared=no fi AC_PROG_LIBTOOL # Libtool configuration bug workaround (problem encountered by bft on Linux # with pgcc 3.3.1, which does not recognize "-soname", so that "-Wl,-soname" # is needed to pass flags to the linker; Manually setting $wl to "-Wl" in # libtool corrects the problem, and so does this workaround borrowed from # the HDF5 configure.in, which does it automatically. case $host_os in linux*) if test "x$GCC" != "xyes"; then echo 'fixing $wl in' $ofile ed - $ofile < /dev/null /^wl=""/s//wl="-Wl,"/ w q EOF fi ;; esac #-------------------------------------------------------------------------- # If the system is of a known type, declare it in the configuration header. #-------------------------------------------------------------------------- case "$host_os" in linux*) AC_DEFINE(bft_OS_Linux, 1, bft_OS_Linux) ;; osf*) AC_DEFINE(bft_OS_OSF1, 1, bft_OS_OSF1) ;; irix5.*|irix6.*) AC_DEFINE(bft_OS_IRIX64, 1, bft_OS_IRIX64) ;; hpux*) AC_DEFINE(bft_OS_HP_UX, 1, bft_OS_HP_UX) ;; solaris2.*) AC_DEFINE(bft_OS_Solaris, 1, bft_OS_SunOS) ;; uxpv*) AC_DEFINE(bft_OS_UXPV, 1, bft_OS_UNIX_System_V) ;; esac #------------------------------------------------------------------------------ # Checks for libraries. #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Checks for header files. #------------------------------------------------------------------------------ AC_HEADER_STDC AC_CHECK_HEADERS([malloc.h unistd.h fcntl.h sys/types.h sys/signal.h]) AC_CHECK_HEADERS([sys/stat.h sys/procfs.h sys/sysinfo.h sys/utsname.h]) AC_CHECK_HEADERS([stddef.h]) #------------------------------------------------------------------------------ # Checks for typedefs, structures, and compiler characteristics. #------------------------------------------------------------------------------ AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_TYPE_PID_T AC_HEADER_TIME AC_HEADER_STDBOOL AC_CHECK_TYPES([long long, unsigned long long]) AC_CHECK_TYPES([int32_t]) AC_CHECK_TYPES([ptrdiff_t]) BFT_AC_CHECK_SIZEOF([void *], [bft]) BFT_AC_CHECK_SIZEOF([short], [bft]) BFT_AC_CHECK_SIZEOF([int], [bft]) BFT_AC_CHECK_SIZEOF([long], [bft]) BFT_AC_CHECK_SIZEOF([long long], [bft]) BFT_AC_CHECK_SIZEOF([float], [bft]) BFT_AC_CHECK_SIZEOF([double], [bft]) #------------------------------------------------------------------------------ # Checks for library functions. #------------------------------------------------------------------------------ # AC_FUNC_MALLOC AC_CHECK_FUNCS([getrusage gettimeofday sbrk sysinfo]) AC_CHECK_FUNCS([mkdir]) AC_CHECK_FUNCS([posix_memalign]) AC_FUNC_FSEEKO #------------------------------------------------------------------------------ # Checks for system services. #------------------------------------------------------------------------------ # Largefile support (may be disabled in case of conflicts) AC_SYS_LARGEFILE # Test for size of off_t once largefile support is activated BFT_AC_CHECK_SIZEOF([off_t], [bft]) #---------------------- # Optional Zlib Support #---------------------- BFT_AC_ZLIB #---------------------------- # optional mallinfo() support #---------------------------- have_mallinfo=no AC_ARG_ENABLE(mallinfo, [ --disable-mallinfo Do not use mallinfo() when available], [ case "${enableval}" in yes) mallinfo=true ;; no) mallinfo=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-mallinfo]) ;; esac ], [ mallinfo=true ] ) saved_LIBS="$LIBS" # If we use mallinfo(), we may need to add a -lmalloc link flag. if test "x$mallinfo" = "xtrue" ; then # Basic test AC_MSG_CHECKING([for mallinfo (basic test)]) LIBS="$saved_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int mallinfo(); mallinfo(); ]])], [have_mallinfo=yes], [have_mallinfo=no]) AC_MSG_RESULT($have_mallinfo) # If failed, test with -lmalloc if test "x$have_mallinfo" = "xno"; then AC_MSG_CHECKING([for mallinfo (with -lmalloc)]) MALLINFO_LIBS="-lmalloc" LIBS="$saved_LIBS $MALLINFO_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int mallinfo(); mallinfo(); ]])], [have_mallinfo=yes], [have_mallinfo=no]) AC_MSG_RESULT($have_mallinfo) if test "x$have_mallinfo" = "xno"; then LIBS="$saved_LIBS" fi fi fi if test "x$have_mallinfo" = "xyes"; then AC_DEFINE(HAVE_MALLINFO, 1, HAVE_MALLINFO) case "$host_os" in osf*) AC_MSG_WARN([mallinfo present only for compatibility reasons and not recommended on some versions of OSF1/Tru64 Unix; please check malloc.h, and eventually use --disable-mallinfo]) ;; esac fi #------------------------------ # optional malloc hooks support (for glibc) #------------------------------ have_malloc_hooks=no AC_ARG_ENABLE(malloc_hooks, [ --disable-malloc-hooks Do not use malloc hooks when available], [ case "${enableval}" in yes) malloc_hooks=true ;; no) malloc_hooks=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-malloc-hooks]) ;; esac ], [ malloc_hooks=true ] ) saved_LIBS="$LIBS" # If we use malloc hooks, we may need to add a -lmalloc link flag. if test "x$mallinfo" = "xtrue" ; then # Basic test AC_MSG_CHECKING([for malloc hooks]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int __malloc_hook(); __malloc_hook(); ]])], [have_malloc_hooks=yes], [have_malloc_hooks=no]) AC_MSG_RESULT($have_malloc_hooks) fi if test "x$have_malloc_hooks" = "xyes"; then AC_DEFINE(HAVE_MALLOC_HOOKS, 1, HAVE_MALLOC_HOOKS) fi #------------------------------ # backtrace support (for glibc) #------------------------------ # Basic backtrace functionnality have_glibc_backtrace=no AC_MSG_CHECKING([for glibc backtrace]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if defined(__GNUC__) #define _GNU_SOURCE #include #include #endif]], [[ void *tr_array[10]; backtrace(tr_array, 10); ]])], [have_glibc_backtrace=yes], [have_glibc_backtrace=no]) AC_MSG_RESULT($have_glibc_backtrace) if test "x$have_glibc_backtrace" = "xyes"; then AC_DEFINE(HAVE_GLIBC_BACKTRACE, 1, HAVE_GLIBC_BACKTRACE) fi # C++ demangling have_cplus_demangle=no AC_MSG_CHECKING([for glibc cplus_demangle]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ const char *s; cplus_demangle(s, auto_demangling); ]])], [have_cplus_demangle=yes], [have_cplus_demangle=no]) AC_MSG_RESULT($have_cplus_demangle) if test "x$have_cplus_demangle" = "xyes"; then AC_DEFINE(HAVE_CPLUS_DEMANGLE, 1, HAVE_CPLUS_DEMANGLE) fi #------------------------------------------------------------------------------ # Internationalization #------------------------------------------------------------------------------ if test "${prefix}" = "NONE"; then localedir="/usr/local/share/locale" else localedir="${prefix}/share/locale" fi AC_DEFINE_UNQUOTED(LOCALEDIR, "${localedir}", LOCALEDIR) # Set of available languages now in po/LINGUAS. # AM_GNU_GETTEXT #----------------------------------------------------------------------------- # Compiler options and system characteristics #----------------------------------------------------------------------------- AC_ARG_VAR(CPP_ADD, [Additional user C compiler flags]) AC_ARG_VAR(CC_ADD, [Additional user C compiler flags]) AC_ARG_VAR(LD_ADD, [Additional user linker flags, e.g. -L]) AC_ARG_VAR(LIBS_ADD, [Additional user librairies, e.g. -l]) AC_SUBST(CPPFLAGS) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(LIBS) #----------------------------------------------------------------------------- # Configuration info output #----------------------------------------------------------------------------- # Determine CPPFLAGS, and LDFLAGS required for external code using the BFT #------------------------------------------------------------------------- for flag in [$CPPFLAGS] ; do case [$flag] in -I* | -isystem*) user_cppflags="${user_cppflags} $flag" ;; esac done for flag in [$LDFLAGS] ; do case [$flag] in -L* | -Wl,-L*) user_ldflags="${user_ldflags} $flag" ;; esac done # Output configuration info script #--------------------------------- BFT_AC_CONFIG_INFO_INIT([bft-config]) BFT_AC_CONFIG_INFO_EXTRA([ # use debugging code: "$debug" # Zlib (gzipped file) support: "$have_Zlib" # use mallinfo(): "$have_mallinfo" # use malloc hooks: "$have_malloc_hooks" ]) BFT_AC_CONFIG_INFO_CC([${CC}], [${bft_ac_cc_version}], [${bft_ac_cc_version_full}]) BFT_AC_CONFIG_INFO_VERSION([bft_version_string]) BFT_AC_CONFIG_INFO_DIRS([$prefix], [$exec_prefix], [$includedir], [$libdir]) BFT_AC_CONFIG_INFO_FLAGS([$user_cppflags], [], [$user_ldflags], [$LIBS]) BFT_AC_CONFIG_INFO_FLAGS([$CPPFLAGS], [$CFLAGS], [$LDFLAGS], [$LIBS], [build]) BFT_AC_CONFIG_INFO_FLAGS([$MPI_CPPFLAGS], [], [$MPI_LDFLAGS], [$MPI_LIBS], [mpi]) BFT_AC_CONFIG_INFO_FINALIZE #------------------------------------------------------------------------------ # If we use GNU gettext, we need intl/Makefile, po/Makefile, and m4/Makefile. # AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile # intl/Makefile po/Makefile.in m4/Makefile]) AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile]) #------------------------------------------------------------------------------ BFT_AC_CONFIG_PUBL_FINALIZE AC_OUTPUT echo echo "Configuration options:" echo " use debugging code: "$debug"" echo " Zlib (gzipped file) support: "$have_Zlib"" echo " use mallinfo(): "$have_mallinfo"" echo " use malloc hooks: "$have_malloc_hooks"" echo echo "The package has been configured. Type:" echo " make" echo " make install" echo echo "To generate and install the BFT package" echo