Commit 61323405 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

Merge branch 'autotools-update' into 'master'

Autotools update

Rationalise the use of optimization macros and a lot of other related tidyups.
Add options to not optimize and add debugging flags. Start a description of
how to build SWIFT.

See merge request !4


Former-commit-id: 0056b73c37f873181468e9d7cb6cfaffb431371d
parents 9801b0af 0dec585e
Building SWIFT
==============
SWIFT is built from a clean source repository using the commands:
./autogen
./configure
make
and from a distribution tarball using:
./configure
make
The compiler choice is GCC by default, but that can be changed using the "CC"
environment variable. This can be just set, or passed on the ./configure
command line, i.e.:
bash:
export CC=icc
./configure
[t]csh:
setenv CC=icc
./configure
or:
./configure CC=icc
to use an Intel compiler. The main "programs" can be found in the "examples/"
directory.
By default an attempt to choose suitable set of optimizing compiler flags
will be made, targetted for the host machine of the build. If this doesn't
work or the binaries will for another architecture then you can stop the
selection of flags using:
./configure --disable-optimization
and then supply your own flags using the "CFLAGS" environment variable, as for
CC.
Note that any CFLAGS that you supply will be added to those determined by
configure in all circumstances. To build SWIFT with debugging support you
can use:
./configure --enable-debug --disable-optimization
You could also add some additional flags:
./configure --enable-debug --disable-optimization CFLAGS="-O2"
for instance. GCC address sanitizer flags can be included using the
./configure --enable-sanitizer
option. Note this requires a GCC compiler version of at least 4.8.
Dependencies: needs to be filled in...
......@@ -16,8 +16,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Automake stuff
AUTOMAKE_OPTIONS = gnu
ACLOCAL_AMFLAGS = -I m4
# Show the way...
SUBDIRS = src examples doc
# Non-standard files that should be part of the distribution.
EXTRA_DIST = INSTALL.swift
# This file is part of SWIFT.
# Coypright (c) 2012 pedro.gonnet@durham.ac.uk.
#
# Copyright (C) 2012 pedro.gonnet@durham.ac.uk.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program 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 General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# init the project
# Init the project.
AC_INIT([SWIFT],[0.1.0])
AC_CONFIG_SRCDIR([src/space.c])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE
AC_GNU_SOURCE
AC_PROG_LIBTOOL
# my own macro collection
# Add local macro collection.
AC_CONFIG_MACRO_DIR([m4])
# generate header file
AM_CONFIG_HEADER(config.h)
# Stop default CFLAGS from anyone except the environment.
: ${CFLAGS=""}
# compiler settings
#CFLAGS="-Wall $(CFLAGS)"
# Generate header file.
AM_CONFIG_HEADER(config.h)
# find and test the compiler
# Find and test the compiler.
AX_CHECK_ENABLE_DEBUG
AC_PROG_CC
AM_PROG_CC_C_O
# Enable POSIX and platform extension preprocessor macros.
AC_USE_SYSTEM_EXTENSIONS
# Add libtool support.
LT_INIT
# Check for compiler version and vendor.
AX_COMPILER_VENDOR
AX_COMPILER_VERSION
# Check for MPI. Need to do this before characterising the compiler (C99 mode),
# as this changes the compiler.
# We should consider using AX_PROG_CC_MPI to replace AC_PROG_CC when compiling
# whole applications. There are issues with mixing compilers when using this
# macro. See
# http://lists.gnu.org/archive/html/autoconf-archive-maintainers/2011-05/msg00004.html.
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--enable-mpi],
[Compile with functionality for distributed-memory parallelim using MPI @<:@default=yes@:>@]
)],
[enable_mpi="$enableval"],
[enable_mpi="yes"]
)
if test "$enable_mpi" = "yes"; then
AX_MPI([CC="$MPICC" AC_DEFINE(HAVE_MPI, 1, [Define if you have the MPI library.]) ])
fi
AM_CONDITIONAL([HAVEMPI],[test -n "$MPICC"])
# Need C99 and inline support.
AC_PROG_CC_C99
AC_LANG_C
# AX_CC_MAXOPT
AC_C_INLINE
# Define HAVE_POSIX_MEMALIGN if it works.
AX_FUNC_POSIX_MEMALIGN
AX_GCC_ARCHFLAG([no])
AX_EXT
# autoconf stuff
# Only optimize if allowed, otherwise assume user will set CFLAGS as
# appropriate.
AC_ARG_ENABLE([optimization],
[AS_HELP_STRING([--enable-optimization],
[Enable compile time optimization flags for host @<:@default=yes@:>@]
)],
[enable_opt="$enableval"],
[enable_opt="yes"]
)
if test "$enable_opt" = "yes" ; then
# Add code optimisation flags and tuning to host. This is a funny macro
# that does not like CFLAGS being already set. Work around that as we have
# at least set it to "", so it is set.
ac_test_CFLAGS="no"
old_CFLAGS="$CFLAGS"
AX_CC_MAXOPT
ac_test_CFLAGS="yes"
CFLAGS="$old_CFLAGS $CFLAGS"
# Check SSE & AVX support (some overlap with AX_CC_MAXOPT).
AX_EXT
if test "$SIMD_FLAGS" != ""; then
CFLAGS="$CFLAGS $SIMD_FLAGS"
fi
fi
# Add address sanitizer options to flags, if requested. Only useful for GCC
# version 4.8 and later.
AC_ARG_ENABLE([sanitizer],
[AS_HELP_STRING([--enable-sanitizer],
[Enable memory error detection using address sanitizer @<:@default=no@:>@]
)],
[enable_san="$enableval"],
[enable_san="no"]
)
if test "$enable_san" = "yes" -a "$GCC" = yes; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [4.8.0],
[enable_san="yes"], [enable_san="no"] )
if test "$enable_san" = "yes"; then
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
fi
fi
# Autoconf stuff.
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_HEADER_STDC
# check for the libraries we will need
# Check for the libraries we will need.
AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR(something is wrong with the math library!))
# Check for pthreads
ACX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for pthreads.
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC" LDFLAGS="$PTHREAD_LIBS $LIBS"],
AC_MSG_ERROR([Could not find a working version of
the pthread library. Make sure you have the library and header files installed
or use CPPFLAGS and LDFLAGS if the library is installed in a
non-standard location.]))
# Check for MPI
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--enable-mpi],[compile with functionality for distributed-memory parallelim using MPI @<:@default=yes@:>@])],
[if test "x$enable_mpi" != "xno"
then
ACX_MPI([ CC="$MPICC" AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.]) ])
fi],
[ACX_MPI([ CC="$MPICC" AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.]) ])])
AM_CONDITIONAL([HAVEMPI],[test -n "$MPICC"])
# Check for metis
# Check for OpenMP.
AC_OPENMP
AC_SUBST(OPENMP_CFLAGS)
enable_openmp="no"
if test -z "$OPENMP_CFLAGS"; then
echo $OPENMP_CFLAGS
AC_MSG_ERROR(Compiler does not support OpenMP, 1)
else
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
enable_openmp="yes"
fi
# Check for metis. Note AX_LIB_METIS exists, but cannot be configured
# to be default off (i.e. given no option it tries to locate METIS), so we
# don't use that.
AC_ARG_WITH([metis],
[AS_HELP_STRING([--with-metis=PATH],[prefix where the metis library is installed @<:@default=yes@:>@])],
[if test "x$with_metis" != "xno"
then
if test "x$with_metis" != "xyes" -a "x$with_metis" != "x"
then
METIS_LDFLAGS="-L$with_metis -lmetis"
else
METIS_LDFLAGS="-lmetis"
fi
AC_CHECK_LIB([metis],[METIS_PartGraphKway],,AC_MSG_ERROR(something is wrong with the metis library!),$METIS_LDFLAGS)
AC_DEFINE([HAVE_METIS],[true],[The metis library appears to be present.])
AC_DEFINE(WITH_METIS, 1, [METIS library installed])
fi])
AC_SUBST(METIS_LDFLAGS)
[AS_HELP_STRING([--with-metis=PATH],
[prefix where the metis library is installed @<:@default=yes@:>@]
)],
[],
[with_metis="no"]
)
if test "x$with_metis" != "xno"; then
if test "x$with_metis" != "xyes" -a "x$with_metis" != "x"; then
METIS_LDFLAGS="-L$with_metis -lmetis"
else
METIS_LDFLAGS="-lmetis"
fi
AC_CHECK_LIB([metis],[METIS_PartGraphKway],
AC_DEFINE([HAVE_METIS],1,[The metis library appears to be present.]),
AC_MSG_ERROR(something is wrong with the metis library!),$METIS_LDFLAGS)
fi
AC_SUBST([METIS_LDFLAGS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LDFLAGS"])
# check for zlib
AC_CHECK_LIB(z,gzopen,[
# Check for zlib.
AC_CHECK_LIB([z],[gzopen],[
AC_DEFINE([HAVE_LIBZ],[1],[Set to 1 if zlib is installed.])
LDFLAGS="$LDFLAGS -lz"
],[])
# check for memalign
AX_FUNC_POSIX_MEMALIGN
# Check for OpenMP
AX_OPENMP
AC_SUBST(OPENMP_CFLAGS)
if test -z "${OPENMP_CFLAGS}"; then
echo $OPENMP_CFLAGS
AC_MSG_ERROR(Compiler does not support OpenMP, 1)
fi
# Check for HDF5.
AX_LIB_HDF5
# Check for HDF5
AX_LIB_HDF5()
# check for setaffinity
AC_USE_SYSTEM_EXTENSIONS
# Check for setaffinity.
AC_CHECK_FUNC( pthread_setaffinity_np , AC_DEFINE([HAVE_SETAFFINITY],[true],
[Defined if pthread_setaffinity_np exists.]) )
# Check for timing functions needed by cycle.h
AC_C_INLINE
# Check for timing functions needed by cycle.h.
AC_HEADER_TIME
AC_CHECK_HEADERS([sys/time.h c_asm.h intrinsics.h mach/mach_time.h])
AC_CHECK_TYPE([hrtime_t],[AC_DEFINE(HAVE_HRTIME_T, 1, [Define to 1 if hrtime_t is defined in <sys/time.h>])],,[#if HAVE_SYS_TIME_H
AC_CHECK_TYPE([hrtime_t],[AC_DEFINE(HAVE_HRTIME_T, 1, [Define to 1 if hrtime_t
is defined in <sys/time.h>])],,
[#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif])
AC_CHECK_FUNCS([gethrtime read_real_time time_base_to_time clock_gettime mach_absolute_time])
AC_MSG_CHECKING([for _rtc intrinsic])
rtc_ok=yes
AC_TRY_LINK([#ifdef HAVE_INTRINSICS_H
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#ifdef HAVE_INTRINSICS_H
#include <intrinsics.h>
#endif], [_rtc()], [AC_DEFINE(HAVE__RTC,1,[Define if you have the UNICOS _rtc() intrinsic.])], [rtc_ok=no])
#endif]],
[[_rtc()]])],
[AC_DEFINE(HAVE__RTC,1,[Define if you have the UNICOS _rtc() intrinsic.])],[rtc_ok=no])
AC_MSG_RESULT($rtc_ok)
# make the documentation
# Make the documentation.
DX_INIT_DOXYGEN(libswift,doc/Doxyfile,doc/)
# .in files.
# Handle .in files.
AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile doc/Makefile doc/Doxyfile])
# generate output.
# Report general configuration.
AC_MSG_RESULT([
Compiler: $CC
vendor: $ax_cv_c_compiler_vendor
version: $ax_cv_c_compiler_version
flags: $CFLAGS
MPI enabled: $enable_mpi
HDF5 enabled: $with_hdf5
OpenMP enabled: $enable_openmp
])
# Generate output.
AC_OUTPUT
......@@ -16,16 +16,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Automake stuff
AUTOMAKE_OPTIONS=gnu
# Common flags
MYFLAGS = -DTIMER
# Add the source directory and debug to CFLAGS
AM_CFLAGS = -g -std=gnu99 -Wall -Werror -I../src $(OPENMP_CFLAGS) -DCPU_TPS=2.67e9
AM_LDFLAGS =
AM_LDFLAGS = @METIS_LDFLAGS@
# Set-up the library
bin_PROGRAMS = test test_fixdt test_mindt test_single
......@@ -38,35 +35,35 @@ endif
# Sources for test
test_SOURCES = test.c
test_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep | engine_policy_setaffinity"
test_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS)
test_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_fixdt
test_fixdt_SOURCES = test.c
test_fixdt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep | engine_policy_setaffinity"
test_fixdt_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS)
test_fixdt_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_mindt
test_mindt_SOURCES = test.c
test_mindt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_keep | engine_policy_setaffinity"
test_mindt_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS)
test_mindt_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_mpi
test_mpi_SOURCES = test.c
test_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep"
test_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS)
test_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_fixdt_mpi
test_fixdt_mpi_SOURCES = test.c
test_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep"
test_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS)
test_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_mindt_mpi
test_mindt_mpi_SOURCES = test.c
test_mindt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_keep"
test_mindt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS)
test_mindt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_single
test_single_SOURCES = test_single.c
test_single_CFLAGS = $(MYFLAGS) $(AM_CFLAGS)
test_single_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS)
test_single_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# ===========================================================================
# http://autoconf-archive.cryp.to/ax_cc_maxopt.html
# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html
# ===========================================================================
#
# SYNOPSIS
......@@ -21,7 +21,7 @@
# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point
# computations can be re-ordered as needed.
#
# Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR,
# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID.
#
# LICENSE
......@@ -55,14 +55,16 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 16
AC_DEFUN([AX_CC_MAXOPT],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
acx_maxopt_portable=$withval, acx_maxopt_portable=no)
AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
acx_maxopt_portable=$enableval, acx_maxopt_portable=no)
# Try to determine "good" native compiler flags if none specified via CFLAGS
if test "$ac_test_CFLAGS" != "set"; then
......@@ -88,8 +90,8 @@ if test "$ac_test_CFLAGS" != "set"; then
else
xlc_opt="-qtune=auto"
fi
AX_CHECK_COMPILER_FLAGS($xlc_opt,
CFLAGS="-O3 -qansialias -w $xlc_opt",
AX_CHECK_COMPILE_FLAG($xlc_opt,
CFLAGS="-O3 -qansialias -w $xlc_opt",
[CFLAGS="-O3 -qansialias -w"
echo "******************************************************"
echo "* You seem to have the IBM C compiler. It is *"
......@@ -113,17 +115,25 @@ if test "$ac_test_CFLAGS" != "set"; then
AX_GCC_X86_CPUID(0)
AX_GCC_X86_CPUID(1)
case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
*:756e6547:*:*) # Intel
*:756e6547:6c65746e:49656e69) # Intel
case $ax_cv_gcc_x86_cpuid_1 in
*6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
*f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
*f??:*:*:*) icc_flags="-xN -xW -xK";;
*0?6[[78ab]]?:*:*:*|?6[[78ab]]?:*:*:*|6[[78ab]]?:*:*:*) icc_flags="-xK" ;;
*0?6[[9d]]?:*:*:*|?6[[9d]]?:*:*:*|6[[9d]]?:*:*:*|*1?65?:*:*:*) icc_flags="-xSSE2 -xB -xK" ;;
*0?6e?:*:*:*|?6e?:*:*:*|6e?:*:*:*) icc_flags="-xSSE3 -xP -xO -xB -xK" ;;
*0?6f?:*:*:*|?6f?:*:*:*|6f?:*:*:*|*1?66?:*:*:*) icc_flags="-xSSSE3 -xT -xB -xK" ;;
*1?6[[7d]]?:*:*:*) icc_flags="-xSSE4.1 -xS -xT -xB -xK" ;;
*1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) icc_flags="-xSSE4.2 -xS -xT -xB -xK" ;;
*2?6[[ad]]?:*:*:*) icc_flags="-xAVX -SSE4.2 -xS -xT -xB -xK" ;;
*3?6[[ae]]?:*:*:*) icc_flags="-xCORE-AVX-I -xAVX -SSE4.2 -xS -xT -xB -xK" ;;
*3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) icc_flags="-xCORE-AVX2 -xCORE-AVX-I -xAVX -SSE4.2 -xS -xT -xB -xK" ;;
*000?f[[346]]?:*:*:*|?f[[346]]?:*:*:*|f[[346]]?:*:*:*) icc_flags="-xSSE3 -xP -xO -xN -xW -xK" ;;
*00??f??:*:*:*|??f??:*:*:*|?f??:*:*:*|f??:*:*:*) icc_flags="-xSSE2 -xN -xW -xK" ;;
esac ;;
esac ;;
esac
if test "x$icc_flags" != x; then
for flag in $icc_flags; do
AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break])
AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break])
done
fi
AC_MSG_CHECKING([for icc architecture flag])
......@@ -139,17 +149,22 @@ if test "$ac_test_CFLAGS" != "set"; then
CFLAGS="-O3 -fomit-frame-pointer"
# -malign-double for x86 systems
AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double")
# -fstrict-aliasing for gcc-2.95+
AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
AX_CHECK_COMPILE_FLAG(-fstrict-aliasing,
CFLAGS="$CFLAGS -fstrict-aliasing")
# note that we enable "unsafe" fp optimization with other compilers, too
AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
AX_GCC_ARCHFLAG($acx_maxopt_portable)
;;
microsoft)
# default optimization flags for MSVC opt builds
CFLAGS="-O2"
;;
esac
if test -z "$CFLAGS"; then
......@@ -163,7 +178,7 @@ if test "$ac_test_CFLAGS" != "set"; then
CFLAGS="-O3"
fi
AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
AX_CHECK_COMPILE_FLAG($CFLAGS, [], [
echo ""
echo "********************************************************"
echo "* WARNING: The guessed CFLAGS don't seem to work with *"
......
......@@ -4,7 +4,7 @@
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
......@@ -19,6 +19,8 @@
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
......@@ -53,19 +55,19 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
[AC_PREREQ(2.63)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
......
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
#
# DESCRIPTION
#
# Check for the presence of an --enable-debug option to configure, with
# the specified default value used when the option is not present. Return
# the value in the variable $ax_enable_debug.
#
# Specifying 'yes' adds '-g -O0' to the compilation flags for all
# languages. Specifying 'info' adds '-g' to the compilation flags.
# Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
# the linking flags. Otherwise, nothing is added.
#
# Define the variables listed in the second argument if debug is enabled,
# defaulting to no variables. Defines the variables listed in the third
# argument if debug is disabled, defaulting to NDEBUG. All lists of
# variables should be space-separated.
#
# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
# Should be invoked prior to any AC_PROG_* compiler checks.
#
# IS-RELEASE can be used to change the default to 'no' when making a
# release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
# uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
# macro, there is no need to pass this parameter.
#
# AX_IS_RELEASE([git-directory])
# AX_CHECK_ENABLE_DEBUG()
#
# LICENSE
#
# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
#serial 5
AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
AC_BEFORE([$0],[AC_PROG_CC])dnl
AC_BEFORE([$0],[AC_PROG_CXX])dnl
AC_BEFORE([$0],[AC_PROG_F77])dnl
AC_BEFORE([$0],[AC_PROG_FC])dnl
AC_MSG_CHECKING(whether to enable debugging)
ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
[$ax_is_release],
[$4])))
# If this is a release, override the default.
AS_IF([test "$ax_enable_debug_is_release" = "yes"],
[ax_enable_debug_default="no"])