1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ([2.69]) 5AC_INIT([MrBayes],[3.2.7]) 6 7AC_CONFIG_AUX_DIR([am-aux]) 8AC_CONFIG_MACRO_DIRS([am-macros]) 9 10AM_INIT_AUTOMAKE([foreign]) 11AM_MAINTAINER_MODE 12 13AC_CONFIG_SRCDIR([src/bayes.c]) 14AC_CONFIG_HEADERS([src/config.h]) 15 16AC_CANONICAL_HOST 17AC_DEFINE_UNQUOTED([HOST_TYPE], ["$host"], [Host triplet]) 18AC_DEFINE_UNQUOTED([HOST_CPU], ["$host_cpu"], [Host CPU type]) 19 20# NB: DEFAULT CFLAGS: 21# Using --enable-debug sets CFLAGS to "-g" ($debug_cflags) 22# Not using --enable-debug sets CFLAGS to "-O3 -DNDEBUG" ($release_cflags) 23# "-std=c99 -pedantic" will always be added ($default_cflags) 24# 25# (warning flags are added by the AX_CFLAGS_WARN_ALL macro further down) 26 27debug_cflags="-g" 28release_cflags="-O3 -DNDEBUG" 29default_cflags="-std=c99 -pedantic" 30 31# Optional feature: debug 32 33AC_ARG_ENABLE([debug], 34 [AS_HELP_STRING([--enable-debug], 35 [Enable debugging @<:@default=no@:>@])], 36 [enable_debug=$enableval], 37 [enable_debug=no]) 38 39# Handle CFLAGS at once, before AX_PROG_CC_MPI further down. 40 41AS_IF([test "x$enable_debug" = "xyes"], 42 [our_cflags="$debug_cflags"], 43 [our_cflags="$release_cflags"]) 44 45# Use our_cflags, the default_cflags, 46# plus any CFLAGS given to us by the user. 47CFLAGS="$our_cflags $default_cflags $CFLAGS" 48 49# Optional features: SSE, AVX, FMA 50 51AC_ARG_ENABLE([sse], 52 [AS_HELP_STRING([--enable-sse], 53 [Enable use of code written using SSE (Streaming SIMD Extensions) 54 @<:@default=yes@:>@ (if supported)])], 55 [enable_sse=$enableval], 56 [enable_sse=yes]) 57 58AC_ARG_ENABLE([avx], 59 [AS_HELP_STRING([--enable-avx], 60 [Enable use of code written using AVX (Advanced Vector Extensions) 61 @<:@default=yes@:>@ (if supported)])], 62 [enable_avx=$enableval], 63 [enable_avx=yes]) 64 65AC_ARG_ENABLE([fma], 66 [AS_HELP_STRING([--enable-fma], 67 [Enable use of code written using FMA (Fused multiply-add SIMD Extensions) 68 @<:@default=yes@:>@ (if supported)])], 69 [enable_fma=$enableval], 70 [enable_fma=yes]) 71 72# Optional external libraries: MPI, Readline, Beagle 73 74AC_ARG_WITH([mpi], 75 [AS_HELP_STRING([--with-mpi], 76 [Build with MPI parallelization support @<:@default=check@:>@])], 77 [], 78 [with_mpi=no]) 79 80AC_ARG_WITH([readline], 81 [AS_HELP_STRING([--with-readline], 82 [Build with the Readline library @<:@default=check@:>@])], 83 [], 84 [with_readline=check]) 85 86AC_ARG_WITH([beagle], 87 [AS_HELP_STRING([--with-beagle[[=PATH]]], 88 [Build with the Beagle library @<:@default=check@:>@. 89 The PATH argument should be the prefix path where Beagle 90 was installed, e.g. @S|@HOME/local, /opt/local etc. 91 The paths /usr/local and /usr are checked if no path is specified.])], 92 [], 93 [with_beagle=check]) 94 95# Checks for programs. 96 97AC_PROG_INSTALL 98PKG_PROG_PKG_CONFIG 99 100# Test whether we can rebuild the documentation. 101# This does not affect the pre-built PDF documents unless these are deleted. 102AC_PATH_PROG(PDFLATEX, [pdflatex]) 103AC_PATH_PROG(BIBTEX, [bibtex]) 104 105AM_CONDITIONAL([BUILD_DOC], [test -n "$PDFLATEX" && test -n "$BIBTEX"]) 106AM_COND_IF([BUILD_DOC], [], 107 [AC_MSG_WARN([pdflatex or bibtex is missing, documentation will not be rebuilt])]) 108 109# Determine if we can (and want) to use an MPI C compiler. 110AX_PROG_CC_MPI([test "x$with_mpi" != "xno"], 111 [use_mpi=yes 112 AC_DEFINE([MPI_ENABLED], [1], [Define if you want to enable MPI])], 113 [use_mpi=no 114 AS_IF([test "x$with_mpi" = "xyes"], 115 [AC_MSG_ERROR([--with-mpi was given, but test for MPI failed]) 116 ]) dnl AS_IF 117]) dnl AX_PROG_CC_MPI 118 119# Checks for libraries. 120AC_CHECK_LIB([m], [sqrt]) 121 122# Check for the Beagle library. 123 124# Strategy: Use AC_CHECK_LIB + AC_CHECK_HEADER to look for the library 125# and headers with the given prefix, or in /usr/local followed by /usr 126# if no prefix path was given, and if that fails use PKG_CHECK_MODULES 127# (and trust its result). 128 129# Note: We assume that Beagle's top-level include directory is located under 130# include/libhmsbeagle-1 and nowhere else. 131 132AS_IF([test "x$with_beagle" != "xno"], [ 133 old_cppflags="$CPPFLAGS" 134 old_ldflags="$LDFLAGS" 135 old_ldlibs="$LDLIBS" 136 137 beagle_pkg_name="hmsbeagle-1" 138 beagle_subinc="include/lib$beagle_pkg_name" 139 beagle_sublib="lib" 140 141 AS_IF([test -n "$BEAGLE_CFLAGS" || test -n "$BEAGLE_LIBS"], 142 [AC_MSG_NOTICE([Using the supplied values of BEAGLE_CFLAGS and BEAGLE_LIBS]) 143 beagle_found="yes"], 144 [AS_IF([test -d "$with_beagle"], 145 [beagle_prefix_list="$with_beagle"], 146 [beagle_prefix_list="/usr/local /usr"])]) 147 148 for beagle_prefix in $beagle_prefix_list; do 149 150 AC_MSG_NOTICE([Trying to locate Beagle ($beagle_pkg_name) in '$beagle_prefix']) 151 152 CPPFLAGS="-I$beagle_prefix/$beagle_subinc" 153 LDFLAGS="-L$beagle_prefix/$beagle_sublib -Wl,-rpath,$beagle_prefix/$beagle_sublib" 154 LDLIBS="-lhmsbeagle" 155 156 AC_CHECK_HEADER([libhmsbeagle/beagle.h], 157 [AC_SUBST([BEAGLE_CFLAGS], [$CPPFLAGS])], []) 158 AC_CHECK_LIB(hmsbeagle, beagleCreateInstance, 159 [AC_SUBST([BEAGLE_LIBS], ["$LDFLAGS $LDLIBS"])], []) 160 161 CPPFLAGS="$old_cppflags" 162 LDFLAGS="$old_ldflags" 163 LDLIBS="$old_ldlibs" 164 165 AS_IF([test -n "$BEAGLE_CFLAGS" && test -n "$BEAGLE_LIBS"], 166 [AC_MSG_NOTICE([Found Beagle in '$beagle_prefix']) 167 beagle_found="yes"]) 168 169 AS_IF([test "x$beagle_found" = "xyes"], [break], 170 [AS_UNSET(BEAGLE_LIBS) 171 AS_UNSET(BEAGLE_CFLAGS) 172 AX_RESET_HEADERS_CACHE([libhmsbeagle_beagle_h])]) 173 done 174 175 AS_IF([test "x$beagle_found" != "xyes"], [ 176 AC_MSG_WARN([Failed to locate Beagle, falling back on pkg-config]) 177 178 PKG_CHECK_MODULES([BEAGLE], [$beagle_pkg_name], 179 [AC_MSG_NOTICE([Found Beagle with pkg-config]) 180 beagle_found="yes" 181 # Augument the BEAGLE_LIBS value with -Wl,-rpath,... 182 BEAGLE_LIBS="$BEAGLE_LIBS -Wl,-rpath,$(pkg-config --libs-only-L $beagle_pkg_name | sed 's/-L//')"], 183 [beagle_found="no"]) 184 ]) dnl AS_IF 185 186 AS_IF([test "x$beagle_found" != "xyes"], 187 [AS_IF([test "x$with_beagle" != "xcheck"], 188 [AC_MSG_ERROR( 189 [--with-beagle was given, but test for Beagle failed])] 190 )], dnl AS_IF - ELSE 191 [ 192 AC_DEFINE([BEAGLE_ENABLED], [1], 193 [Define if you want to enable Beagle]) 194 # Test whether we should enable Beagle3 support. 195 old_ldflags=$LDFLAGS 196 LDFLAGS="$BEAGLE_LIBS" 197 AC_CHECK_LIB(hmsbeagle, beagleSetCPUThreadCount, 198 [AC_DEFINE([BEAGLE_V3_ENABLED], [1], 199 [Define to enable Beagle v3.1 extensions]) 200 BEAGLE_CFLAGS="$BEAGLE_CFLAGS -pthread"]) 201 LDFLAGS=$old_ldflags 202 AS_UNSET(old_ldflags) 203 AC_MSG_NOTICE([Using BEAGLE_CFLAGS="$BEAGLE_CFLAGS"]) 204 AC_MSG_NOTICE([Using BEAGLE_LIBS="$BEAGLE_LIBS"]) 205 ]) 206]) dnl AS_IF 207 208# Check for readline, but only if we don't have MPI, because apparently 209# it won't work. 210 211AS_IF([test "x$use_mpi" = "xno"], 212 [AS_IF([test "x$with_readline" != "xno"], [AX_LIB_READLINE])], 213 [AS_IF([test "x$with_readline" = "xyes"], 214 [AC_MSG_WARN( 215 [--with-readline was given, but MPI support requires 216 readline to be disabled. Retry with --without-mpi if you 217 *really* need readline support]) 218 ]) dnl AS_IF 219]) dnl AS_IF 220 221# Checks for header files. 222AC_CHECK_HEADERS([float.h limits.h memory.h stdlib.h string.h]) 223 224# Checks for typedefs, structures, and compiler characteristics. 225AC_TYPE_SIZE_T 226AC_CHECK_HEADER_STDBOOL 227 228# Get compiler's vendor and version 229AX_COMPILER_VENDOR 230AX_COMPILER_VERSION 231 232AC_DEFINE_UNQUOTED([COMPILER_VENDOR], 233 ["$ax_cv_c_compiler_vendor"], [Compiler vendor]) 234AC_DEFINE_UNQUOTED([COMPILER_VERSION], 235 ["$ax_cv_c_compiler_version"], [Compiler version]) 236 237# Add warning flags to compile command line. 238AX_CFLAGS_WARN_ALL 239 240# Check for SIMD (etc.) extensions supported by hardware and compiler 241# (-msse2 etc.) 242AX_EXT 243 244AS_IF([test "x$enable_sse" = "xno"], 245 [AC_DEFINE([DISABLE_SSE], [1], 246 [SSE code path should not be compiled.])]) 247AS_IF([test "x$enable_avx" = "xno"], 248 [AC_DEFINE([DISABLE_AVX], [1], 249 [AVX code path should not be compiled.])]) 250AS_IF([test "x$enable_fma" = "xno"], 251 [AC_DEFINE([DISABLE_FMA], [1], 252 [FMA code path should not be compiled.])]) 253 254# Checks for library functions. 255AC_CHECK_FUNCS([floor memset pow sqrt strchr]) 256 257AC_CONFIG_FILES([Makefile 258 doc/Makefile 259 doc/manual/Makefile 260 doc/tutorial/Makefile 261 examples/Makefile 262 src/Makefile 263]) 264AC_OUTPUT 265