Skip to content
Snippets Groups Projects
Commit 109787d8 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Update autotools support

removes compiler hard coding, adds configure option for controlling optimisation, debugging and sanitizer
parent bbf10846
No related branches found
No related tags found
1 merge request!4Autotools update
...@@ -17,6 +17,8 @@ doc/latex/ ...@@ -17,6 +17,8 @@ doc/latex/
doc/man/ doc/man/
doc/Doxyfile doc/Doxyfile
src/version.h
examples/test examples/test
examples/test_bh examples/test_bh
examples/test_bh_sorted examples/test_bh_sorted
......
...@@ -18,49 +18,111 @@ ...@@ -18,49 +18,111 @@
# init the project # init the project
AC_INIT([QUICKSCHED],[0.1.0]) AC_INIT([QUICKSCHED],[0.1.0])
AC_CONFIG_SRCDIR([src/qsched.c]) AC_CONFIG_SRCDIR([src/qsched.c])
AM_INIT_AUTOMAKE([gnu]) AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE
AC_GNU_SOURCE # Add local macro collection
AC_PROG_LIBTOOL
# my own macro collection
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# Stop default CFLAGS from anyone except the environment.
: ${CFLAGS=""}
# generate header file # generate header file
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
# compiler settings # Find and test the compiler.
#CFLAGS="-Wall $(CFLAGS)" AX_CHECK_ENABLE_DEBUG
AC_PROG_CC
# find and test the compiler
AM_PROG_CC_C_O 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
# Need C99 and inline support.
AC_PROG_CC_C99 AC_PROG_CC_C99
AC_LANG_C AC_C_INLINE
# AX_CC_MAXOPT
AX_FUNC_POSIX_MEMALIGN # Only optimize if allowed, otherwise assume user will set CFLAGS as
AX_GCC_ARCHFLAG([no]) # appropriate.
AX_EXT 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
# autoconf stuff # 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"; then
if test "$ax_cv_c_compiler_vendor" = "gnu"; 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
else
AC_MSG_WARN([Compiler does not support address sanitizer option])
fi
fi
# Autoconf stuff
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_HEADER_STDC AC_HEADER_STDC
# Check for pthreads # Check for pthreads.
ACX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC" LDFLAGS="$PTHREAD_LIBS $LIBS" CC="$PTHREAD_CC" LDFLAGS="$LDFLAGS $PTHREAD_LIBS $LIBS"]
AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])], AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),
AC_MSG_ERROR([Could not find a working version of AC_MSG_ERROR([Could not find a working version of
the pthread library. Make sure you have the library and header files installed 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 or use CPPFLAGS and LDFLAGS if the library is installed in a
non-standard location.])) non-standard location.]))
# Check for OpenMP # Check for OpenMP, is required.
AX_OPENMP AC_OPENMP
AC_SUBST(OPENMP_CFLAGS) AC_SUBST(OPENMP_CFLAGS)
if test -z "${OPENMP_CFLAGS}"; then enable_openmp="no"
echo $OPENMP_CFLAGS if test -z "$OPENMP_CFLAGS"; then
AC_MSG_ERROR(Compiler does not support OpenMP, 1) AC_MSG_ERROR(Compiler does not support OpenMP, 1)
else
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
enable_openmp="yes"
AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])
fi fi
# Check for timing functions needed by cycle.h # Check for timing functions needed by cycle.h
...@@ -78,11 +140,27 @@ AC_TRY_LINK([#ifdef HAVE_INTRINSICS_H ...@@ -78,11 +140,27 @@ AC_TRY_LINK([#ifdef HAVE_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) AC_MSG_RESULT($rtc_ok)
# Check for feenableexcept, should be present in C99, also checks for -lm.
AC_CHECK_LIB([m],[feenableexcept])
# Check for git, needed for revision stamps.
AC_PATH_PROG([GIT_CMD], [git])
AC_SUBST([GIT_CMD])
# make the documentation # make the documentation
DX_INIT_DOXYGEN(libquicksched,doc/Doxyfile,doc/) DX_INIT_DOXYGEN(libquicksched,doc/Doxyfile,doc/)
# .in files. # .in files.
AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile doc/Makefile doc/Doxyfile]) AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile doc/Makefile doc/Doxyfile])
# Report general configuration.
AC_MSG_RESULT([
Compiler: $CC
vendor: $ax_cv_c_compiler_vendor
version: $ax_cv_c_compiler_version
flags: $CFLAGS
OpenMP enabled: $enable_openmp
])
# generate output. # generate output.
AC_OUTPUT AC_OUTPUT
...@@ -17,15 +17,9 @@ ...@@ -17,15 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Add the source directory and debug to CFLAGS # Add the source directory and debug to CFLAGS
AM_CFLAGS = -g -O3 -Wall -Werror -I../src -ffast-math -fstrict-aliasing \ AM_CFLAGS = -I../src -DCPU_TPS=2.67e9 -DTIMERS
-ftree-vectorize -funroll-loops $(SIMD_FLAGS) $(OPENMP_CFLAGS) \
-DCPU_TPS=2.67e9 -DTIMERS \ AM_LDFLAGS =
# -fsanitize=address -fno-omit-frame-pointer
# AM_CFLAGS = -g -O0 -Wall -Werror -I../src \
# -DCPU_TPS=2.67e9 -DTIMERS $(OPENMP_CFLAGS) \
# -fsanitize=address -fno-omit-frame-pointer
AM_LDFLAGS = -lm # -fsanitize=address
# Set-up the library # Set-up the library
bin_PROGRAMS = test test_qr test_bh test_bh_sorted test_fmm_sorted bin_PROGRAMS = test test_qr test_bh test_bh_sorted test_fmm_sorted
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Add the debug flag to the whole thing # Add the debug flag to the whole thing
AM_CFLAGS = -g -O3 -Wall -Werror -ffast-math -fstrict-aliasing -ftree-vectorize \ AM_CFLAGS = -DTIMERS
-funroll-loops $(SIMD_FLAGS) $(OPENMP_CFLAGS) -DTIMERS \
# -fsanitize=address -fno-omit-frame-pointer
# Assign a "safe" version number # Assign a "safe" version number
AM_LDFLAGS = -version-info 0:0:0 AM_LDFLAGS = -version-info 0:0:0
# The git command, if available.
GIT_CMD = @GIT_CMD@
# Build the libquicksched library # Build the libquicksched library
lib_LTLIBRARIES = libquicksched.la lib_LTLIBRARIES = libquicksched.la
libquicksched_la_SOURCES = qsched.c queue.c libquicksched_la_SOURCES = qsched.c queue.c
...@@ -32,3 +33,19 @@ include_HEADERS = atomic.h lock.h queue.h qsched.h task.h res.h error.h ...@@ -32,3 +33,19 @@ include_HEADERS = atomic.h lock.h queue.h qsched.h task.h res.h error.h
# Private headers. # Private headers.
noinst_HEADERS = cycle.h quicksched.h noinst_HEADERS = cycle.h quicksched.h
# Versioning. If any sources change then update the version.h file with
# the current git revision and package version.
version.h: version.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
if test "X$(GIT_CMD)" != "X"; then \
GIT_REVISION=`git describe --abbrev=8 --always --tags --dirty`; \
sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
-e "s,@GIT_REVISION\@,$${GIT_REVISION}," version.h.in > version.h; \
fi
# Make sure version.h is built first.
BUILT_SOURCES = version.h
# And distribute the built files.
EXTRA_DIST = version.h version.h.in
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
* Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk).
*
* This program 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 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 Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_VERSION_H
#define SWIFT_VERSION_H
/**
* @file version.h
* @brief Package version and git revision sha.
*/
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
#define GIT_REVISION "@GIT_REVISION@"
const char* package_description( void );
const char* package_version(void);
const char* git_revision(void);
#endif /* SWIFT_VERSION_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment