# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(lamarc, 2.1.10, lamarc@u.washington.edu, lamarc)
AM_MAINTAINER_MODE
AC_CONFIG_AUX_DIR([config])
AC_DEFINE(RELEASE_DATE, ["14 Nov 2013"], [The release date of the program])
wxRequiredMajorVersion=2
wxRequiredMinorVersion=8
wxRequiredPatchVersion=3
wxVersionRequired=${wxRequiredMajorVersion}.${wxRequiredMinorVersion}.${wxRequiredPatchVersion}
wxProvidedMajorVersion=2
wxProvidedMinorVersion=8
wxProvidedPatchVersion=12
wxVersionProvided=${wxProvidedMajorVersion}.${wxProvidedMinorVersion}.${wxProvidedPatchVersion}
# setting up OS and CPU variables
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([src/control/lamarc.cpp])
AC_CONFIG_HEADER([config/conf.h])
# define conditionals/arguments ***************************
# use --disable-data for generating stationaries
AC_ARG_ENABLE(arrcheck, [ --enable-arrcheck LAMARC: produce output to check arrangers],[lamARRCHECK=$enableval],[lamARRCHECK=no])
AC_ARG_ENABLE(buildwx, [ --enable-buildwx LAMARC: do a local build the wxWidgets library],[lamBUILDWX=$enableval],[lamBUILDWX=no])
AC_ARG_ENABLE(converter, [ --disable-converter LAMARC: don't build data conversion program(s)],[lamCONV=$enableval],[lamCONV=yes])
AC_ARG_ENABLE(data, [ --disable-data LAMARC: ignore data file],[lamDATA_READ=$enableval],[lamDATA_READ=yes])
AC_ARG_ENABLE(denovo, [ --enable-denovo LAMARC: all trees generated de-novo],[lamDENOVO=$enableval],[lamDENOVO=no])
AC_ARG_ENABLE(debug, [ --enable-debug Compile with debug flags],[lamDEBUG=$enableval],[lamDEBUG=no])
AC_ARG_ENABLE(dmalloc, [ --enable-dmalloc LAMARC: Link with dmalloc library],[lamDMALLOC=$enableval],[lamDMALLOC=no])
AC_ARG_ENABLE(efence, [ --enable-efence LAMARC: Link with electric fence],[lamEFENCE=$enableval],[lamEFENCE=no])
AC_ARG_ENABLE(gcov, [ --enable-gcov LAMARC: Compile with gcov flags],[lamGCOV=$enableval],[lamGCOV=no])
AC_ARG_ENABLE(gui, [ --disable-gui LAMARC: don't create lam_conv with graphic UI capability],[lamGUI=$enableval],[lamGUI=yes])
AC_ARG_ENABLE(jsim, [ --enable-jsim LAMARC: Compile with Jon's simulation flags],[lamJSIM=$enableval],[lamJSIM=no])
AC_ARG_ENABLE(profile, [ --enable-profile LAMARC: compile with profiling flags],[lamPROFILE=$enableval],[lamPROFILE=no])
AC_ARG_ENABLE(progress, [ --disable-progress LAMARC: turn off progress bar],[lamPROGRESS=$enableval],[lamPROGRESS=yes])
AC_ARG_ENABLE(shared, [ --disable-shared LAMARC: don't use shared libs],[lamSHARED=$enableval],[lamSHARED=no])
AC_ARG_ENABLE(treetrack, [ --enable-treetrack LAMARC: track datalikelihoods of sampled trees],[lamTREETRACK=$enableval],[lamTREETRACK=no])
AC_ARG_ENABLE(universal_binary, [ --enable-universal_binary LAMARC: build universal binary],[lamUNIVB=$enableval],[lamUNIVB=no])
AC_ARG_WITH(wx-config, [ --with-wx-config=FILE LAMARC: use existing wxWindows installation],[lamWX_CONFIG=$withval])
# check that we either have info on GUI toolkit and OS, or get it and complain
AC_SUBST(LAMARC_CODE_OSTYPE)
case "$target_os" in
darwin*)
if test "X${lamCONV}" = "Xyes" ; then
if test "X${lamGUI}" = "Xyes" ; then
if test "X${GUI_TOOLKIT}" = "X" ; then
GUI_TOOLKIT=osx_cocoa
fi
fi
fi
if test "X${LAMARC_CODE_OSTYPE}" = "X" ; then
LAMARC_CODE_OSTYPE=LAMARC_COMPILE_MACOSX
fi
;;
freebsd*|linux*)
if test "X${lamCONV}" = "Xyes" ; then
if test "X${lamGUI}" = "Xyes" ; then
if test "X${GUI_TOOLKIT}" = "X" ; then
GUI_TOOLKIT=gtk2
fi
fi
fi
if test "X${LAMARC_CODE_OSTYPE}" = "X" ; then
LAMARC_CODE_OSTYPE=LAMARC_COMPILE_LINUX
fi
;;
*mingw32*)
if test "X${lamCONV}" = "Xyes" ; then
if test "X${lamGUI}" = "Xyes" ; then
if test "X${GUI_TOOLKIT}" = "X" ; then
GUI_TOOLKIT=msw
fi
fi
fi
if test "X${LAMARC_CODE_OSTYPE}" = "X" ; then
LAMARC_CODE_OSTYPE=LAMARC_COMPILE_MSWINDOWS
fi
;;
*)
if test "X${LAMARC_CODE_OSTYPE}" = "X" ; then
GUI_TOOLKIT=osx_cocoa
LAMARC_CODE_OSTYPE=LAMARC_COMPILE_MACOSX
echo "*************************************************************"
echo "DO NOT CHECK THIS config.ac in, it has GUI_TOOLKIT and"
echo "LAMARC_CODE_OSTYPE hardwired for 10.7 mac"
echo "*************************************************************"
fi
;;
esac
if test "X${LAMARC_CODE_OSTYPE}" = "X" ; then
echo "An internal error occured. We thought it was impossible not"
echo "to have LAMARC_CODE_OSTYPE set. Please notify the lamarc"
echo "team at lamarc@u.washington.edu and try setting the environment"
echo "variable LAMARC_CODE_OSTYPE as described in the \"Compiling"
echo "Lamarc\" portion of the documentation."
AC_MSG_ERROR([cannot proceed without LAMARC_CODE_OSTYPE])
fi
if test "X${lamCONV}" = "Xyes" ; then
if test "X${lamGUI}" = "Xyes" ; then
if test "X${GUI_TOOLKIT}" = "X" ; then
echo "*************************************************************"
echo "You have enabled compilation of the converter GUI but the"
echo "configure script was not able to guess the correct GUI"
echo "toolkit to use. See the section entitled Compiling"
echo "Lamarc in the Lamarc documentation for more information."
echo "*************************************************************"
AC_MSG_ERROR([cannot proceed without GUI_TOOLKIT])
fi
else
if test "X${GUI_TOOLKIT}" != "X" ; then
if test "X${GUI_TOOLKIT}" != "Xbase" ; then
AC_MSG_WARN([changing GUI_TOOLKIT ${GUI_TOOLKIT} to base because GUI is disabled])
fi
fi
GUI_TOOLKIT=base
fi
fi
AC_SUBST(LAMARC_HOST_PREFIX)
if test "X${host_alias}" = "X" ; then
LAMARC_HOST_PREFIX=""
else
LAMARC_HOST_PREFIX="${host_alias}-"
fi
# conditionals used in Makefile.am to specify different
# resources and/or compilation products for different
# platforms
AM_CONDITIONAL(LAMARC_APP_OSX, test $LAMARC_CODE_OSTYPE = LAMARC_COMPILE_MACOSX)
AM_CONDITIONAL(LAMARC_APP_MSW, test $LAMARC_CODE_OSTYPE = LAMARC_COMPILE_MSWINDOWS)
# now a few functions for checking the wxWidgets stuff
build_wx()
{
echo "*******************************************"
echo "* starting wxWidgets build *"
echo "*******************************************"
# build wx options
if test "X${lamGUI}" = "Xyes" ; then
guiOption="--with-${GUI_TOOLKIT}"
else
guiOption="--disable-gui"
fi
sharedOption="--disable-shared"
debugOption="--disable-debug"
if test "X${lamDEBUG}" = "Xyes" ; then
debugOption="--enable-debug"
fi
crossOptions=
if test "$host_os" != "$build_os" ; then
crossOptions="--disable-threads --host=${host_alias}"
fi
# this is not optimal -- but it is the easiest way to solve
# the problem that builtin tiff is needed for debian, yet
# we compile releases on red hat
tiffOptions=
if test "$LAMARC_CODE_OSTYPE" = "LAMARC_COMPILE_LINUX" ; then
tiffOptions="--with-libtiff=builtin"
fi
universalBinaryOptions=
if test "X${lamUNIVB}" = "Xyes" ; then
universalBinaryOptions="--enable-universal_binary --disable-dependency-tracking"
fi
wxConfigOptions="${guiOption} ${sharedOption} ${debugOption} ${crossOptions} ${tiffOptions} ${universalBinaryOptions}"
thisDir=`pwd`;
configScriptDir=`dirname $0`
topOfPackage=`(cd $configScriptDir 2> /dev/null && pwd ;)`
wxTarFile=${topOfPackage}/wxWidgets/wxWidgets-${wxVersionProvided}.tar.gz
wxUnpackedDir=wxWidgets-${wxVersionProvided}
# unpack tar file
if test ! -d ${wxUnpackedDir} ; then
echo "untar-ing wxWidgets distribution ${wxTarFile}"
tar xfvz ${wxTarFile}
else
echo "${wxUnpackedDir} already exists. Skipping main un-tar step"
fi
if test ! -d ${wxUnpackedDir} ; then
AC_MSG_ERROR([Unsuccessful trying to un-tar ${wxTarFile}])
else
cd ${wxUnpackedDir}
fi
# untar patches over tar file
for file in ${topOfPackage}/wxWidgets/wxWidgets-${wxVersionProvided}-Patch*.tar.gz
do
tar xfvz ${file}
done
# build wxWidgets
./configure ${wxConfigOptions}
make
cd ${thisDir}
RETURN_STRING=${thisDir}/${wxUnpackedDir}/wx-config
}
get_wx_config_script()
{
if test "X${lamWX_CONFIG}" = "Xyes" ; then
# whoops, user used --with-wx-config without an argument
# let's assume it is going to be on their path
AC_MSG_WARN([no argument given to --with-wx-config])
AC_MSG_WARN([Assuming "wx-config" is on your \$PATH])
WXCONFIG="wx-config"
else
if test "X${lamWX_CONFIG}" = "X" ; then
# whoops, user didn't give --with-wx-config
# let's assume wx-config is going to be on their path
AC_MSG_WARN([No option --with-wx-config given])
AC_MSG_WARN([Assuming "wx-config" is on your \$PATH])
WXCONFIG="wx-config"
else
# take the value of wx-config script the user gave us
WXCONFIG=$lamWX_CONFIG
fi
fi
AC_PATH_PROG(WXCONFIG2, $WXCONFIG, "")
if test "X${WXCONFIG2}" = "X" ; then
AC_MSG_WARN([Failure of above check for $WXCONFIG might have been a bug])
AC_MSG_WARN([Searching for it using AC CHECK FILE macro])
AC_CHECK_FILE($WXCONFIG, WXCONFIG2=$WXCONFIG, WXCONFIG2="")
fi
AC_MSG_CHECKING([wxWidgets version])
if test "X${WXCONFIG2}" = "X" ; then
AC_MSG_RESULT([not found])
wxVersion=""
else
if wxVersion=`$WXCONFIG2 --version`; then
AC_MSG_RESULT([$wxVersion])
else
AC_MSG_RESULT([not found])
fi
fi
whatIsWxProb=""
isVersionBad=""
if test "X${wxVersion}" = "X" ; then
whatIsWxProb="Could not find wxWidgets config script"
isVersionBad="yes"
else
whatIsWxProb="Your wxWidgets version is ${wxVersion}"
wxVersionMajor=`echo ${wxVersion} | awk -F. '{ print $1 }' - `
wxVersionMinor=`echo ${wxVersion} | awk -F. '{ print $2 }' - `
wxVersionPatch=`echo ${wxVersion} | awk -F. '{ print $3 }' - `
if test "$wxVersionMajor" -lt "$wxRequiredMajorVersion" ; then
isVersionBad="yes"
else
if test "$wxVersionMajor" -eq "$wxRequiredMajorVersion" ; then
if test "$wxVersionMinor" -lt "$wxRequiredMinorVersion" ; then
isVersionBad="yes"
else
if test "$wxVersionMinor" -eq "$wxRequiredMinorVersion" ; then
if test "$wxVersionPatch" -lt "$wxRequiredPatchVersion" ; then
isVersionBad="yes"
fi
fi
fi
fi
fi
fi
if test "${isVersionBad}" ; then
echo "*******************************************"
echo "wxWidgets version ${wxVersionRequired} or greater is required"
echo "to build lamarc data converters, but the configure script"
echo "found version ${wxVersion}."
echo ""
echo "If you don't want to install your own version of wxWidgets,"
echo "you can try using the configure switch --enable-buildwx"
echo ""
echo "See the section entitled Compiling Lamarc in the"
echo "Lamarc documentation for more information."
echo "*******************************************"
AC_MSG_ERROR([needed wxWidgets version ${wxVersionRequired} or greater])
fi
RETURN_STRING=${WXCONFIG2}
}
if test "X${lamBUILDWX}" = "Xyes" ; then
if test "X${lamWX_CONFIG}" != "X" ; then
AC_MSG_ERROR([configure switches --with-wx-config and --enable-buildwx mutually exclusive])
fi
build_wx
lamWX_CONFIG=${RETURN_STRING}
fi
WXCONFIG3=""
if test "X${lamCONV}" = "Xyes" ; then
get_wx_config_script
WXCONFIG3=${RETURN_STRING}
if test "$host_os" != "$build_os" ; then
WXCONFIG3="${WXCONFIG3} --host=${host_alias}"
fi
if test "X${lamDEBUG}" = "Xyes" ; then
WXCONFIG3="${WXCONFIG3} --debug=yes"
else
WXCONFIG3="${WXCONFIG3} --debug=no"
fi
# we may have many toolkits installed so specify
# if we are GUI-less GUI_TOOLKIT should already have
# been set to "base"
WXCONFIG3="${WXCONFIG3} --toolkit=${GUI_TOOLKIT}"
# check that the wx-config we found will provide us anything
wxListResult=`${WXCONFIG3} --list`
wxOK=`echo ${wxListResult} | awk '{ if (/will be used/) {print 1} ; if (/Specification best match/) {print 1} }' - `
if test "X${wxOK}" != "X1" ; then
echo "*************************************************************"
echo " Lamarc configure script failed because it could not find the "
echo " correct wxWidgets library. You might check your path, the "
echo " value of variable GUI_TOOLKIT, or try adding the configure"
echo " option --enable-build_wx . For more details see the section"
echo " entitled \"Compiling Lamarc\" in the lamarc documentation."
echo ""
echo " Here is error message from wx-config, in case that helps:"
echo ""
echo " " ${wxListResult}
echo ""
echo "*************************************************************"
AC_MSG_ERROR([cannot proceed without suitable wxWidgets library])
fi
AC_SUBST(WX_CXXFLAGS, [`$WXCONFIG3 --cxxflags`])
AC_SUBST(WX_LIBS, [`$WXCONFIG3 --libs`])
fi
# Checks for programs. -- tests and setting of cxxflags are to
# keep AC_PROG_CXX from setting unfortunate default values
if test -n "${CXXFLAGS}"; then
user_set_cxxflags=yes
fi
AC_PROG_CXX
if test X$user_set_cxxflags != Xyes; then
CXXFLAGS=" "
fi
# so we can build tinyxml as a library
AC_PROG_RANLIB
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([float.h limits.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MEMCMP
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([getcwd pow sqrt strchr strpbrk])
AM_CONDITIONAL(ARRCHECK, test x$lamARRCHECK = xyes)
AM_CONDITIONAL(CONVERTER, test x$lamCONV = xyes)
AM_CONDITIONAL(DEBUG, test x$lamDEBUG = xyes)
AM_CONDITIONAL(DENOVO, test x$lamDENOVO = xyes)
AM_CONDITIONAL(DMALLOC, test x$lamDMALLOC = xyes)
AM_CONDITIONAL(EFENCE, test x$lamEFENCE = xyes)
AM_CONDITIONAL(GCOV, test x$lamGCOV = xyes)
AM_CONDITIONAL(GUI, test x$lamGUI = xyes)
AM_CONDITIONAL(JSIM, test x$lamJSIM = xyes)
AM_CONDITIONAL(NODATA, test x$lamDATA_READ != xyes)
AM_CONDITIONAL(NOPROGRESS, test x$lamPROGRESS != xyes)
AM_CONDITIONAL(PROFILE, test x$lamPROFILE = xyes)
AM_CONDITIONAL(TREETRACK, test x$lamTREETRACK = xyes)
AM_CONDITIONAL(UNIVB, test x$lamUNIVB = xyes)
AM_CONDITIONAL(USERCXXFLAGS, test x$user_set_cxxflags = xyes)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
echo "*************************************************************"
echo " Settings for lamarc build. For information on how to change"
echo " try executing \"configure --help\" and reading the lamarc"
echo " documentation section entitled \"Compiling Lamarc\"."
echo "*************************************************************"
echo ""
echo "Options that are almost always on:"
echo " Compile lam_conv, the lamarc data converter? ${lamCONV}"
if test "X${lamCONV}" = "Xyes" ; then
echo " Compile lam_conv as a GUI? ${lamGUI}"
else
echo " Compile lam_conv as a GUI? --"
fi
echo " Compile LAMARC to read data? ${lamDATA_READ}"
echo " Compile LAMARC to display progress bar? ${lamPROGRESS}"
echo "Options that are almost always off:"
echo " Compile LAMARC to check arrangers? ${lamARRCHECK}"
echo " Compile LAMARC to generate all trees denovo? ${lamDENOVO}"
echo " Compile LAMARC to use dmalloc? ${lamDMALLOC}"
echo " Compile LAMARC to use electric fence? ${lamEFENCE}"
echo " Compile LAMARC to use gcov? ${lamGCOV}"
echo " Compile LAMARC to use Jon's simulation code? ${lamJSIM}"
echo " Compile LAMARC to generate profile data? ${lamPROFILE}"
echo " Track data likelihoods of sampled trees? ${lamTREETRACK}"
echo " Attempt to compile universal binary (MAC)? ${lamUNIVB}"
echo ""
echo "Commonly toggled configure options:"
echo " Compile LAMARC in debug mode? ${lamDEBUG}"
echo ""
if test "X${lamCONV}" = "Xyes" ; then
echo "wxWidgets version ${wxVersion}"
else
echo "wxWidgets version --"
fi
if test "X${lamCONV}" = "Xyes" ; then
echo "gui toolkit ${GUI_TOOLKIT}"
else
echo "gui toolkit --"
fi
echo "LAMARC_CODE_OSTYPE ${LAMARC_CODE_OSTYPE}"
echo "*************************************************************"
case "${LAMARC_CODE_OSTYPE}" in
LAMARC_COMPILE_MACOSX)
;;
LAMARC_COMPILE_LINUX)
;;
LAMARC_COMPILE_MSWINDOWS)
;;
*)
echo "The lamarc compile script either failed to recognize"
echo "${LAMARC_CODE_OSTYPE} as a legal value for "
echo "LAMARC_CODE_OSTYPE. It is likely that you will have"
echo "trouble compiling lamarc."
echo ""
echo "We recommend that you see the section entitled \"Compiling"
echo "Lamarc\" in the lamarc documentation for alternative solutions."
echo "*************************************************************"
;;
esac
if test "X${lamCONV}" = "Xyes" ; then
case "${GUI_TOOLKIT}" in
gtk2)
;;
mac)
;;
msw)
;;
base)
;;
*)
echo "The lamarc compile script did not recognize your GUI toolkit,"
echo "\"$GUI_TOOLKIT\", as one we have tested. It is very likely"
echo "that the lamarc file converter, lam_conv, will not work."
echo ""
echo "We recommend that you see the section entitled \"Compiling"
echo "Lamarc\" in the lamarc documentation for alternative solutions."
echo "*************************************************************"
;;
esac
fi
if test "X$user_set_cxxflags" = "Xyes"; then
echo "************************************************************* "
echo "You have set your own value of CXXFLAGS. Did you remember to"
echo "use a matching argument of --enable-debug or --disable-debug?"
echo "If not, you may have trouble running the programs. "
echo "************************************************************* "
fi
echo "Configure script finished successfully."