Files
opm-core/configure
T

357 lines
11 KiB
Bash
Raw Normal View History

2012-12-07 09:45:12 +01:00
#!/bin/bash
2013-02-22 13:36:09 +01:00
# where is the source tree located
srcdir=$(dirname "$0")
2012-12-07 09:45:12 +01:00
# display help text
usage () {
cat <<EOF
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]. Note: set DESTDIR=PATH when doing
\`make install' to install to a different sysroot.
Optional Features:
--disable-FEATURE do not include FEATURE
--disable-gxx11check do not try flag -std=c++11 to enable C++11 features
--enable-shared build a shared library [default=yes]
--enable-static build a static library [default=no]. Note: only one
of the options shared and static may be built.
2013-04-05 00:47:54 +02:00
--enable-debug build a non-optimized version of the library
[default=no]
--enable-lto use whole program optimization [default=no]
2013-01-24 20:45:39 +01:00
--disable-pch do not use precompiled headers (if buggy compiler)
2013-01-24 23:52:51 +01:00
--disable-silent-rules print every compilation statement as executed
--enable-system-debug put .debug files in global GDB debug dir
[default=yes if prefix=/usr, no otherwise]
--enable-parallel process in parallel using MPI [default=no]
2013-03-06 23:55:40 +01:00
--enable-openmp activate experimental support for OpenMP
--disable-option-checking ignore unrecognized --enable/--with options
Optional Packages:
2013-02-22 10:24:58 +01:00
--with-boost=PATH use Boost library from a specified location
--with-dune=PATH specify parent of all DUNE modules not specified
--with-dune-MODULE=PATH use given DUNE module from a specified location
--with-opm=PATH specify parent of all OPM modules not specified
--with-opm-MODULE=PATH use given OPM module from a specified location
--with-superlu=PATH user defined path to SuperLU library
--with-agmg=PATH Include DOUBLE PRECISION version Notay's of AGMG
Algebraic Multigrid solver from specified source
location. Note: this option requires a complete,
working Fortran 90 environment.
--with-umfpack=PATH use UMFPACK/SuiteSparse from a specified location
--with-ert=PATH Use ERT libraries
2013-01-23 01:03:23 +01:00
--with-tinyxml=PATH use TinyXML library from a specified location
(Note: if not found, then a bundled library will
be used)
--with-cmake=PROGRAM use this program instead of \`cmake' to configure
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
FC Fortran compiler command
FCFLAGS Fortran compiler flags
CMAKE_COMMAND Executable used to run cmake scripts
Use these variables to override the choices made by \`configure' or to help
it to find libraries and programs with nonstandard names/locations.
2012-12-07 09:45:12 +01:00
EOF
}
# report an error regarding the arguments
invalid_arg () {
cat <<EOF
configure: error: unrecognized option: \`$1'
Try \`$0 --help' for more information
EOF
}
# notify the user that this argument is not known
unknown_arg () {
cat <<EOF
configure: warning: unrecognized option: \`$1'
EOF
}
# warn only if option checking is enabled
invalid_opt () {
if [ "${option_check}" = "yes" ]; then
unknown_arg $@
fi
}
2012-12-07 09:45:12 +01:00
# default values
prefix=/usr/local
2013-04-05 00:47:54 +02:00
#buildtype=" -DCMAKE_BUILD_TYPE=Debug"
buildtype=
2013-01-24 20:45:39 +01:00
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
pch_use=
2013-03-06 23:55:40 +01:00
#use_openmp=" -DUSE_OPENMP=OFF"
use_openmp=
use_mpi=
2013-01-24 23:52:51 +01:00
#silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF"
silent_rules=
#debug_loc=" -DSYSTEM_DEBUG=OFF"
debug_loc=
#use_lto=" -DWHOLE_PROG_OPTIM=OFF"
use_lto=
# default is to warn for unknown options, but this can be disabled
option_check=yes
2012-12-07 09:45:12 +01:00
# this variable will get feature options
FEATURES=
2013-03-06 19:08:09 +01:00
# this array will get all variable assignments from command-line
VARS=()
2013-02-14 22:44:22 +01:00
# command that launches cmake; look for 2.8 if available
if [ "${CMAKE_COMMAND}" = "" ]; then
if which cmake28 >/dev/null 2>&1; then
CMAKE_COMMAND=cmake28
else
CMAKE_COMMAND=cmake
fi
2013-02-14 22:44:22 +01:00
fi
2013-03-06 19:08:09 +01:00
for OPT in "$@"; do
case "$OPT" in
--*)
OPTARG=${OPT#--}
2012-12-07 09:45:12 +01:00
# OPTARG now contains everything after double dashes
case "${OPTARG}" in
prefix=*)
# remove prefix consisting of everything up to equal sign
prefix=${OPTARG#*=}
;;
help)
2013-01-08 10:57:40 +01:00
usage
exit 0
;;
with-*)
# get the name of the package; everything before equal sign
pkgname=${OPTARG%=*}
pkgname=${pkgname#with-}
# get the location of the package; everyhing after equal sign
pkgloc=${OPTARG#*=}
# the parameter to this option is an executable program, so
# skip the directory test in that case
if [ "${pkgname}" = "cmake" ]; then
CMAKE_COMMAND="${pkgloc}"
break
fi
2013-03-05 22:12:11 +01:00
# tilde expansion; quote safely before running eval on it
eval pkgloc=$(printf "%q" "${pkgloc}")
2012-12-19 11:35:21 +01:00
# expand to full path since CMake changes to source directory (!)
# this also normalize the path name wrt. not having a trailing slash
2013-03-06 19:13:28 +01:00
test -d "${pkgloc}" && pkgloc=$(sh -c "cd \"${pkgloc}\"; pwd")
# special aliases
case "${pkgname}" in
umfpack)
pkgname="SuiteSparse"
;;
2013-01-23 01:03:23 +01:00
tinyxml)
pkgname="TinyXML"
;;
esac
# packages need different suffix for their root (sic)
case "${pkgname}" in
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
rootvar=""
;;
2013-04-03 10:52:57 +02:00
mpi |\
mpi-prefix)
rootvar="_MPI_PREFIX_PATH"
;;
2013-03-04 21:51:59 +01:00
agmg |\
ert |\
boost |\
superlu |\
2013-02-22 10:24:58 +01:00
SuiteSparse |\
TinyXML |\
opm |\
opm-* |\
dune |\
2013-03-04 21:51:59 +01:00
dune-* |\
zlib)
rootvar="${pkgname^^}_ROOT"
rootvar="${rootvar/-/_}"
2013-02-22 10:24:58 +01:00
;;
*)
invalid_opt --with-${pkgname}
rootvar=""
;;
esac
# add this to the list of existing features
test -n "${rootvar}" && \
2013-01-09 10:39:24 +01:00
FEATURES="${FEATURES} \"-D${rootvar}=${pkgloc}\""
;;
2013-02-22 10:21:18 +01:00
without-* | \
disable-*)
# get the name of the package
2013-02-22 10:21:18 +01:00
pkgname=$OPTARG
pkgname=${pkgname#disable-}
pkgname=${pkgname#without-}
# special aliases
case "${pkgname}" in
umfpack)
pkgname="SuiteSparse"
;;
2013-02-22 10:21:18 +01:00
tinyxml)
pkgname="TinyXML"
;;
esac
# casing is of course different
case "${pkgname}" in
option-checking)
option_check=no
# special flag: don't disable any particular package
pkgname=""
;;
2013-01-09 11:26:57 +01:00
debug)
2013-04-05 00:47:54 +02:00
buildtype=" -DCMAKE_BUILD_TYPE=Release"
2013-01-09 11:26:57 +01:00
# special flag: don't disable any particular package
pkgname=""
;;
2013-01-24 20:45:39 +01:00
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
pkgname=""
;;
2013-01-24 23:52:51 +01:00
silent-rules)
silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON"
pkgname=""
;;
system-debug)
2013-03-07 00:15:41 +01:00
debug_loc=" -DSYSTEM_DEBUG=OFF"
pkgname=""
;;
wpo |\
lto )
use_lto=" -DWHOLE_PROG_OPTIM=OFF"
pkgname=""
;;
2013-03-06 23:55:40 +01:00
openmp)
use_openmp=" -DUSE_OPENMP=OFF"
pkgname=""
;;
2013-04-03 10:52:57 +02:00
mpi | \
parallel)
use_mpi=" -DUSE_MPI=OFF"
pkgname=""
;;
agmg |\
ert |\
superlu)
pkgname="${pkgname^^}"
;;
openmp)
pkgname="OpenMP"
;;
gxx11check)
pkgname="CXX11Features"
;;
*)
invalid_opt --disable-${pkgname}
pkgname=""
;;
esac
2013-01-09 11:26:57 +01:00
# only disable packages if the flag refers to a proper one
test -n "${pkgname}" && \
FEATURES="${FEATURES} -DCMAKE_DISABLE_FIND_PACKAGE_${pkgname}=TRUE"
;;
enable-*)
# what kind of library are we building; shared or static?
kind=${OPTARG#enable-}
case "${kind}" in
system-debug)
debug_loc=" -DSYSTEM_DEBUG=ON"
# special flag; don't set shared/static
shared=""
;;
2013-03-06 23:55:40 +01:00
openmp)
use_openmp=" -DUSE_OPENMP=ON"
# special flag; don't set shared/static
shared=""
;;
2013-04-03 10:52:57 +02:00
mpi | \
parallel)
use_openmp=" -DUSE_MPI=ON"
# special flag; don't set shared/static
shared=""
;;
2013-04-05 00:47:54 +02:00
debug)
buildtype=" -DCMAKE_BUILD_TYPE=Debug"
shared=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
shared=""
;;
lto)
use_lto=" -DWHOLE_PROG_OPTIM=ON"
shared=""
;;
# this flag is just for compatibility with the deprecation
# flag in DUNE, so we can build without warnings
fieldvector-size-is-method)
shared=""
;;
shared)
shared="ON"
;;
static)
shared="OFF"
;;
*)
invalid_opt --enable-${kind}
shared=""
;;
esac
test -n "${shared}" && \
FEATURES="${FEATURES} -DBUILD_SHARED_LIBS:BOOL=${shared}"
;;
2012-12-07 09:45:12 +01:00
*)
# remove everything *after* the equal sign
2013-01-08 10:57:40 +01:00
arg=${OPTARG%=*}
2012-12-07 09:45:12 +01:00
invalid_arg --$arg
2013-01-08 10:57:40 +01:00
exit 1
;;
2012-12-07 09:45:12 +01:00
esac
2013-01-08 10:57:40 +01:00
;;
2013-03-06 19:08:09 +01:00
[A-Za-z0-9_]*=*)
# collect for further processing later
VARS+=("$OPT")
;;
2012-12-07 09:45:12 +01:00
*)
2013-03-06 19:08:09 +01:00
invalid_arg $OPT
2013-01-08 10:57:40 +01:00
exit 1
2012-12-07 09:45:12 +01:00
;;
esac
done
# remove all arguments processed by getopts
shift $((OPTIND-1))
2013-03-06 19:08:09 +01:00
# remove Autotools-specific variables. notice the usage of a quoted
# array: each element will be returned even with spaces.
for a in "${VARS[@]}"; do
a="${a/ACLOCAL_*=*/}"
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
done
2012-12-07 09:45:12 +01:00
# pass everything on to CMake
2013-04-05 00:47:54 +02:00
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto} ${FEATURES}"
echo --- calling CMake ---
echo ${CMDLINE}
eval exec ${CMDLINE}