1# 2# TODO For BitArrayBase: Default is not set, code will select a default. 3# --enable-bit-arrays=byte 4# --enable-bit-arrays=word 5# Define BIT_ARRAYS_BY_BYTE or BIT_ARRAYS_BY_WORD 6# 7# TODO: cleanup tests for linpack library and add it to the link line 8# when building tests 9# 10# TODO: We probably don't want to error-out on the absence of 11# all these headers. We can work around not having strings.h, etc. 12# Let's wait till we fail on a platform to decide what we want 13# to work around. 14# 15# These were recommended by autoscan. TODO: Define replacement 16# functions for these three if autoconf test decides they 17# are faulty, and include AC_LIBOBJ commands to replace them. 18# 19#AC_FUNC_ERROR_AT_LINE 20#AC_FUNC_MALLOC 21#AC_FUNC_STRTOD 22# 23 24 25############################################################### 26# boilerplate 27 28AC_PREREQ(2.59) 29AC_INIT([utilib], [VOTD], [acro-help@software.sandia.gov]) 30 31 32############################################################### 33# A file or directory that should be found here, so we know 34# we are in the right place. 35 36AC_CONFIG_SRCDIR([src/libs/cholesky.cpp]) 37 38 39############################################################### 40# Location of our m4 macros. These test for the features 41# we are interested. This doesn't actually work. Documentation 42# says it will in the future. We need to define 43# ACLOCAL_AMFLAGS in Makefile.am instead. autoconf looks there 44# for some reason. 45 46AC_CONFIG_MACRO_DIR([config]) 47AC_CONFIG_AUX_DIR([config]) 48 49############################################################### 50# Create this header file which will help configure our Makefiles 51# and source files at build time. 52 53AC_CONFIG_HEADERS([src/config.h]) 54AX_PREFIX_CONFIG_H([src/utilib_config.h]) 55AH_TOP([ 56/* _________________________________________________________________________ 57 * 58 * UTILIB: A utility library for developing portable C++ codes. 59 * Copyright (c) 2008 Sandia Corporation. 60 * This software is distributed under the BSD License. 61 * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 62 * the U.S. Government retains certain rights in this software. 63 * For more information, see the README file in the top UTILIB directory. 64 * _________________________________________________________________________ 65 */ 66 67/** 68 * \file utilib_config.h 69 * 70 * A header file for UTILIB configuration options that is generated by 71 * autoconf. 72 */ 73]) 74AH_BOTTOM( 75#ifndef UTILIB_HAVE_EXPLICIT 76#ifndef explicit 77#define explicit 78#endif 79#endif 80) 81 82############################################################### 83# Are we using a cache file, and if so does the cache file already 84# exist, or is it empty and we are initializing it? 85 86use_ac_cv_env=no 87ac_cv_env_empty=yes 88 89if test "$cache_file" != "/dev/null" ; then 90 use_ac_cv_env=yes 91 if test X$ac_cv_env_CCASFLAGS_set = Xset ; then 92 ac_cv_env_empty=no 93 fi 94fi 95 96if test "$ac_cv_env_empty" = "no" ; then 97 # 98 # Respect cache file settings for CC, CXX, CCFLAGS, etc. 99 # We are building as a subpackage of a package which has 100 # given us a cache file, or the Acro builder is using a 101 # cache file created on a previous run. 102 # 103 AC_MSG_NOTICE([=====================================================================]) 104 AC_MSG_NOTICE([Compile environment obtained from cache file.]) 105 AC_MSG_NOTICE([UTILIB's special options for compile environment]) 106 AC_MSG_NOTICE([(for example "--with-debugging") will be ignored.]) 107 AC_MSG_NOTICE([=====================================================================]) 108fi 109 110############################################################### 111# Setup platform information and initialize automake 112 113AC_CANONICAL_BUILD 114AC_CANONICAL_HOST 115AC_CANONICAL_TARGET 116AM_INIT_AUTOMAKE([-Wall -Werror foreign]) 117 118AC_CACHE_SAVE 119 120############################################################### 121# Platform ID 122 123ACRO_PLATFORM 124 125############################################################### 126# Is utilib being built as part of acro? If so we will 127# copy our library to acro/lib when done. If not, we'll 128# copy it to top_builddir/lib. 129 130if test -d ../../packages ; then 131 AM_CONDITIONAL(I_AM_SUBPACKAGE, true) 132 ac_cv_subpackage=subpackage 133else 134 AM_CONDITIONAL(I_AM_SUBPACKAGE, false) 135 ac_cv_subpackage=no 136fi 137 138############################################################### 139# Configure command line options 140 141using_acro_special=no 142 143############################################################### 144# Request executables that are linked only with static libraries, 145# default is to use shared system libraries when available 146 147ACRO_STATIC_EXECUTABLES 148 149 150 151# --with-compiler=mingw 152ACRO_COMPILER_OPTION 153 154if test $ac_cv_env_empty = yes ; then 155 # Various special options to override compiler flags, sets 156 # using_acro_special to yes 157 ACRO_COMPILER_OPTIONS 158fi 159 160# Control whether UTILIB CommonIO mapping is used 161ACRO_COMMONIO_OPTION 162# Control whether UTILIB DEBUGPR output is used 163ACRO_DEBUGPR_OPTION 164# Control whether UTILIB memory debugging utilities are used 165ACRO_MEMDEBUG_OPTION 166# Control whether UTILIB checksum is used 167ACRO_CHECKSUM_OPTION 168# Control whether executables are built 169ACRO_EXECUTABLES_OPTION 170# Control wether test codes are built 171ACRO_TEST_OPTION 172# Control wether code validation is used 173ACRO_VALIDATING_OPTION 174 175# Various options to setup the use of MPI, sets using_acro_special to yes 176 177AC_ARG_ENABLE(mpi, 178AS_HELP_STRING([--enable-mpi],[Enable MPI support]), 179[ENABLE_MPI=$enableval], 180[ENABLE_MPI=no] 181) 182 183if test $ac_cv_env_empty = yes ; then 184 ACRO_MPI_OPTIONS 185fi 186 187# 188# Will application using utilib link in linpack? Default is NO. 189# 190AC_ARG_WITH(linpack, 191[AC_HELP_STRING([--with-linpack],[Allow utilib to call linpack functions])], 192[WITH_LINPACK=$withval], 193[WITH_LINPACK=no] 194) 195 196if test X${WITH_LINPACK} = Xyes; then 197 AC_DEFINE(YES_LINPACK,,[define whether linpack will be included]) 198fi 199 200AC_CACHE_SAVE 201 202############################################################### 203# Checks for programs 204 205#c_compilers="" 206#cpp_compilers="" 207 208if test $ac_cv_env_empty = yes ; then 209 temp_cflags=${CFLAGS} 210 temp_cxxflags=${CXXFLAGS} 211 212 if test "X${MPI_CC}" = "Xnone" ; then 213 if test X${USERDEF_CC} = Xnotset ; then 214# if test X$with_vendor_compilers = Xyes ; then 215# c_compilers="icc pgcc xlc cc gcc" 216# else 217# c_compilers="cc gcc" 218# fi 219 c_compilers="" 220 else 221 CC="${USERDEF_CC}" 222 fi 223 else 224 CC="${MPI_CC}" 225 fi 226 227 if test "X${MPI_CXX}" = "Xnone" ; then 228 if test X${USERDEF_CXX} = Xnotset ; then 229 if test X${build_os} = Xcygwin ; then 230 cpp_compilers="g++" 231 else 232# if test X$with_vendor_compilers = Xyes ; then 233# cpp_compilers="icpc pgCC xlC CC c++ g++" 234# else 235# cpp_compilers="c++ g++" 236# fi 237 cpp_compilers="" 238 fi 239 else 240 CXX="${USERDEF_CXX}" 241 fi 242 else 243 CXX="${MPI_CXX}" 244 fi 245fi 246 247AC_PROG_CC 248AC_PROG_CXX 249 250if test $ac_cv_env_empty = yes ; then 251 # AC_PROG_CC and AC_PROG_CXX overwrote our flag values 252 CFLAGS=${temp_cflags} 253 CXXFLAGS=${temp_cxxflags} 254fi 255 256AC_PROG_CXXCPP 257AC_PROG_LN_S 258AM_PROG_AS 259m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 260 261AC_CACHE_SAVE 262 263############################################################### 264# Platform-specific compiler options 265 266# Setup CXX flags 267AC_CXX_COMPILER_VENDOR([CXX_VENDOR]) 268 269if test $ac_cv_env_empty = yes ; then 270 AC_CXX_CPPFLAGS_STD_LANG([CXXFLAGS]) 271 ACRO_PLATFORM_COMPILER_FLAGS 272fi 273 274AM_CONDITIONAL(HAVE_GNU_COMPILER,false) 275AM_CONDITIONAL(HAVE_PGI_COMPILER,false) 276 277if test X$ac_cv_cxx_compiler_vendor = Xpgi ; then 278 AM_CONDITIONAL(HAVE_PGI_COMPILER,true) 279else 280 if test X$ac_cv_cxx_compiler_vendor = Xgnu ; then 281 AM_CONDITIONAL(HAVE_GNU_COMPILER,true) 282 fi 283fi 284 285############################################################### 286# Platform specific flags for some Acro source files. 287 288ACRO_PLATFORM_CODE_FLAGS 289 290############################################################### 291# Setup compiler flags 292 293if test $ac_cv_env_empty = yes ; then 294 ACRO_COMPILER_FLAGS 295fi 296 297AC_CACHE_SAVE 298############################################################### 299# Validate MPI builds 300 301AM_CONDITIONAL(BUILD_MPI, false) 302 303if test $ac_cv_env_empty = yes ; then 304# 305# Try compiling with MPI, and set BUILD_MPI to true on success. 306# 307 ACRO_MPI_TESTS 308elif test "X$acro_cv_with_mpi_set" = "Xyes" ; then 309# 310# We're here if we are configuring from cache variables, and 311# "--with-mpi*=" options were specified previously. The MPI 312# tests were run previously and succeeded. 313# 314 AM_CONDITIONAL(BUILD_MPI, true) 315 AC_DEFINE(HAVE_MPI,,[define that mpi is being used]) 316fi 317 318############################################################### 319# Checks for libraries 320 321# Configure with boost 322AX_BOOST_BASE([1.37],[available]) 323# Configure with tinyxml 324ACX_TINYXML 325# Configure with cxxtest 326ACX_CXXTEST 327 328############################################################### 329# Checks for headers 330# 331 332# Define STDC_HEADERS if system has ANSI C header files. Right 333# now we wouldn't be able to compile if this fails. We can 334# fix this if we find platforms without standard C headers. 335AC_HEADER_STDC 336 337# Define TIME_WITH_SYS_TIME if system is one where both 338# time.h and sys/time.h should be included 339AC_HEADER_TIME 340 341# libexpat related options, including 342# makefile condititional USE_EXPAT_LIBRARY if including libexpat 343# makefile variables EXPAT_LIBS, EXPAT_INCDIR, EXPAT_LIBDIR 344# config file macro UTILIB_HAVE_EXPAT_H 345# option --without-expat turns off use of expat even if you have it 346 347ACRO_EXPAT_OPTIONS 348 349# Define HAVE_SYS_TIME_H if this header file exists 350AC_CHECK_HEADERS([sys/time.h]) 351 352# Define HAVE_TIMEB_H if sys/timeb.h exists. This is obsolete 353# and we'll only use it if we don't find better time functions 354AC_CHECK_HEADERS([sys/timeb.h]) 355 356AC_CHECK_HEADERS([sys/resource.h]) 357 358# Notes on defined max/min constants: 359# We need float.h (which defines FLT_MAX) and limits.h 360# (which defines INT_MAX). If they don't exist, we will 361# take values.h (which defines MAXINT), which is obsolete. 362# If none of these exist, we fail. To be more careful we 363# could also check here if the values we need are defined. 364AC_CHECK_HEADERS([float.h limits.h],,[AC_CHECK_HEADERS([values.h],,[AC_MSG_ERROR(missing headers)])]) 365 366AC_CHECK_HEADERS([memory.h stddef.h stdlib.h string.h strings.h unistd.h], , [AC_MSG_ERROR(missing headers)]) 367 368AC_CHECK_HEADERS([cxxabi.h]) 369 370AC_CHECK_HEADERS([windows.h]) 371 372AC_CHECK_HEADERS([err.h]) 373 374AC_CHECK_HEADERS([dbghelp.h]) 375 376AC_CHECK_HEADERS([execinfo.h], [HAVE_EXECINFO=yes], [HAVE_EXECINFO=no]) 377 378# 379# If the C compiler is gcc, then AC_PROG_CC set GCC=yes 380# 381if test $HAVE_EXECINFO = yes && test "X$GCC" = "Xyes" && "$host_os" != "Darwin" ; then 382 ACRO_ADD(CFLAGS, -rdynamic) 383 ACRO_ADD(CXXFLAGS, -rdynamic) 384fi 385 386AC_MSG_NOTICE([Warnings about rejection of header files by preprocessor may be IGNORED]) 387 388AC_CACHE_SAVE 389############################################################### 390# Checks for typedefs, structures and compiler behavior 391 392# Defines HAVE_STDBOOL_H. If not defined we need to include bool 393# information in every source that uses type bool. 394AC_HEADER_STDBOOL 395 396# Define "const" to be empty if compiler doesn't support const 397AC_C_CONST 398 399# Redefine "inline" if necessary 400AC_C_INLINE 401 402# For now, it's an error if size_t is not defined. 403AC_CHECK_TYPES([size_t],,[AC_MSG_ERROR(missing size_t)]) 404 405# 406# TODO - replace ptrdiff_t if it's not defined 407# 408AC_CHECK_TYPES([ptrdiff_t]) 409 410# defines HAVE_LONG_DOUBLE if the long double type exists and 411# has more precision than double 412# OLD: 413# AC_C_LONG_DOUBLE 414# NEW: 415# AC_TYPE_LONG_DOUBLE 416# AC_TYPE_LONG_DOUBLE_WIDER 417 418AC_CACHE_SAVE 419 420############################################################### 421# Checks for compiler behavior 422# 423# AC_CXX_* are checks for C++ behavior 424 425# Defines HAVE_NAMESPACES if we can use them 426# TODO - find out if the means std namespace only, or any namespace 427# is it possible we can declare namespaces, but there's no std? 428# Modifying sources to use HAVE_NAMESPACES is not complete 429AC_CXX_NAMESPACES 430 431# WEH - turned off because these are not portable 432# Defines HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS if we can pass a template 433# argument in for a template parameter 434# AC_CXX_TEMPLATES_AS_TEMPLATE_ARGUMENTS 435 436# Defines HAVE_EXCEPTIONS if we can use throw/catch 437AC_CXX_EXCEPTIONS 438 439# Defines HAVE_STD if was can include ISO C++ headers 440# (iostream, map, iomanip and cmath) 441AC_CXX_HAVE_STD 442 443# Define HAVE_SSTREAM if we have stringstreams 444AC_CXX_HAVE_SSTREAM 445 446# Define HAVE_EXPLICIT if we can use the explicit keyword 447AC_CXX_EXPLICIT 448 449# Define HAVE_MEMBER_TEMPLATES if class member functions can be templated 450AC_CXX_MEMBER_TEMPLATES 451 452AC_CACHE_SAVE 453 454############################################################### 455# Platform-specific C++ compiler settings 456 457case "$ac_cv_cxx_compiler_vendor" in 458 gnu) 459 AX_CXXFLAGS_GCC_OPTION([-fpermissive]) 460 ;; 461 compaq) 462 AX_CXXFLAGS_OSF_OPTION([-tlocal]) 463 ;; 464 sgi) 465 AX_CXXFLAGS_IRIX_OPTION([-ptused]) 466 ;; 467 *) 468 ;; 469esac 470 471 472############################################################### 473# Checks for functions 474 475# 476# It is an error if neither stricmp or strcasecmp are defined. 477# 478AC_CHECK_FUNCS([stricmp],,[AC_CHECK_FUNCS([strcasecmp],,AC_MSG_ERROR([missing functions]))]) 479 480# 481# It's an error if these are not defined. 482# 483AC_CHECK_FUNCS([atexit strchr],,[AC_MSG_ERROR([missing functions])]) 484 485# 486# It's NOT an error if these are not defined. 487# 488AC_CHECK_FUNCS([nrand48]) 489 490# 491# There was some code in utilib that uses _getcwd() from direct.h 492# on Windows machines if getcwd() from unistd.h is not available. 493# For now we will consider it an error if getcwd() does not exist. 494# If this fails on a platform, we will add code to look for _getcwd() 495# and use it in the code. (Modern cygwin and mingw systems seem to 496# have getcwd().) 497# 498AC_CHECK_FUNCS([getcwd],,[AC_MSG_ERROR([missing headers])]) 499 500# Notes on time functions: 501# We want getrusage() (sys/resource.h) 502# next choice would be times() 503# (sys/times.h and requires sysconf(_SC_CLOCK_TICK)) 504# last choice would be clock() (time.h) 505# 506# We want gettimeofday() (sys/time.h) 507# next choice would be localtime() (time.h) 508# last choice would be ftime (sys/timeb.h) 509# 510# TODO: the default names are confusing: HAVE_GETRUSAGE, HAVE_TIMES, etc. 511# we really mean USE_GETRUSAGE, USE_TIMES, etc. We may have them but 512# not define them because we don't want to use them. 513# 514# TODO: We could replace a missing "floor()" fuction. 515 516AC_CHECK_FUNCS([sysconf]) 517 518AC_CHECK_FUNCS([getrusage],,[AC_CHECK_FUNCS([times sysconf],,[AC_CHECK_FUNCS([clock],,[AC_MSG_ERROR([no process time usage functions])])])]) 519AC_CHECK_FUNCS([gettimeofday],,[AC_CHECK_FUNCS([localtime],,[AC_CHECK_FUNCS([ftime],,[AC_MSG_ERROR([no time functions])])])]) 520 521AC_CHECK_LIB([m], [sqrt],,[AC_MSG_ERROR([cannot find sqrt in math library])]) 522AC_CHECK_LIB([m], [floor],,[AC_MSG_ERROR([cannot find floor in math library])]) 523AC_CHECK_LIB([m], [pow],,[AC_MSG_ERROR([cannot find pow in math library])]) 524AC_CHECK_LIB([m], [lround], [AC_DEFINE([HAVE_LROUND],,[define whether libm contains lround()])]) 525 526AC_LIBTOOL_WIN32_DLL 527AC_DISABLE_SHARED 528AC_PROG_LIBTOOL 529 530if test "X$enable_shared" = "Xyes"; then 531 AM_CONDITIONAL(BUILD_SHARED, true) 532else 533 AM_CONDITIONAL(BUILD_SHARED, false) 534fi 535 536if test "X$enable_static" = "Xyes"; then 537 AM_CONDITIONAL(BUILD_STATIC, true) 538else 539 AM_CONDITIONAL(BUILD_STATIC, false) 540fi 541AC_CACHE_SAVE 542 543############################################################### 544# output 545 546AC_CONFIG_FILES([ 547Makefile 548doc/Makefile 549src/Makefile 550examples/Makefile 551test/Makefile 552test/studies/Makefile 553test/unit/Makefile 554]) 555 556############################################################### 557# We are all done with actions which modify the compilers 558# and build flags. The following definitions are required 559# in case the -C or --cache-file= options were given, and 560# there was no existing cache file, so we created the 561# compile environment variables from our command line options 562# and defaults. 563# 564# These definitions will be written to the new cache file. 565 566if test $use_ac_cv_env = yes && test $ac_cv_env_empty = yes ; then 567 ac_cv_env_CCASFLAGS_value=$CCASFLAGS 568 ac_cv_env_CCASFLAGS_set=set 569 ac_cv_env_CCAS_value=$CCAS 570 ac_cv_env_CCAS_set=set 571 ac_cv_env_CC_value=$CC 572 ac_cv_env_CC_set=set 573 ac_cv_env_CFLAGS_value=$CFLAGS 574 ac_cv_env_CFLAGS_set=set 575 ac_cv_env_CPPFLAGS_value=$CPPFLAGS 576 ac_cv_env_CPPFLAGS_set=set 577 ac_cv_env_CPP_value=$CPP 578 ac_cv_env_CPP_set=set 579 ac_cv_env_CXXCPP_value=$CXXCPP 580 ac_cv_env_CXXCPP_set=set 581 ac_cv_env_CXXFLAGS_value=$CXXFLAGS 582 ac_cv_env_CXXFLAGS_set=set 583 ac_cv_env_CXX_value=$CXX 584 ac_cv_env_CXX_set=set 585 ac_cv_env_LDFLAGS_value=$LDFLAGS 586 ac_cv_env_LDFLAGS_set=set 587 ac_cv_env_LIBS_value=$LIBS 588 ac_cv_env_LIBS_set=set 589fi 590############################################################### 591 592AC_OUTPUT 593 594if test $use_ac_cv_env = yes && test $ac_cv_env_empty = yes ; then 595 AC_MSG_WARN([ ============== COMPILE ENVIRONMENT ============== ]) 596fi 597 598AC_MSG_NOTICE(CCAS=\"$CCAS\" CCASFLAGS=\"$CCASFLAGS\") 599AC_MSG_NOTICE(CXXCPP=\"$CXXCPP\" CC=\"$CC\" CFLAGS=\"$CFLAGS\") 600AC_MSG_NOTICE(CPP=\"$CPP\" CPPFLAGS=\"$CPPFLAGS\") 601AC_MSG_NOTICE(CXX=\"$CXX\" CXXFLAGS=\"$CXXFLAGS\") 602AC_MSG_NOTICE(LDFLAGS=\"$LDFLAGS\" LIBS=\"$LIBS\") 603 604if test $use_ac_cv_env = yes && test $ac_cv_env_empty = yes ; then 605 AC_MSG_WARN([ ================================================= ]) 606 AC_MSG_WARN([ In subsequent configure runs that use the "-C" or ]) 607 AC_MSG_WARN([ "--cache-file=" options, you must provide the ]) 608 AC_MSG_WARN([ compile environment on the configure command line ]) 609 AC_MSG_WARN([ using the above flags. ]) 610if test $using_acro_special = yes ; then 611 AC_MSG_WARN([ The special UTILIB options (like "--with-debugging" ]) 612 AC_MSG_WARN([ or "--with-cc=") are not compatible with ]) 613 AC_MSG_WARN([ GNU autoconf's cache variable feature.]) 614fi 615 AC_MSG_WARN([ ================================================= ]) 616fi 617 618echo 619echo "---" 620echo "--- Thank you for downloading UTILIB. For more information" 621echo "--- visit: http://software.sandia.gov/utilib/" 622echo "---" 623echo 624 625