diff --git a/bin/duneproject b/bin/duneproject index d6377690f96418d5fc4e73e6bef4bb1a93e8d4f1..a31a76a14ef2ab16bdafb9336b7b7b4df4726321 100755 --- a/bin/duneproject +++ b/bin/duneproject @@ -339,6 +339,8 @@ LIBS="\$DUNE_LIBS" AC_CONFIG_FILES([ Makefile src/Makefile + cmake/Makefile + cmake/pkg/Makefile doc/Makefile doc/doxygen/Makefile doc/doxygen/Doxyfile @@ -441,9 +443,13 @@ cat> "$PROJECT/Makefile.am" << M_DELIM # \$Id$ # we need the module file to be able to build via dunecontrol -EXTRA_DIST=dune.module +EXTRA_DIST = dune.module \\ + CMakeLists.txt \\ + config.h.cmake \\ + $PROJECT-config.cmake.in \\ + $PROJECT-version.cmake.in -SUBDIRS = src m4 dune doc +SUBDIRS = src m4 dune doc cmake if BUILD_DOCS # TODO: set up documentation tree automatically @@ -520,6 +526,80 @@ CC_DELIM echo " Please remember to update your $PROJECT/$MODULE.pc.in," echo " Description and URL are missing right now." +################# config.h.cmake ##################### + +echo "- $PROJECT/config.h.cmake" +cat> "$PROJECT/config.h.cmake" <<EOF +/* begin $NAME + put the definitions for config.h specific to + your project here. Everything above will be + overwritten +*/ + +/* begin private */ +/* Name of package */ +#define PACKAGE "@DUNE_MOD_NAME" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@DUNE_MOD_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@DUNE_MOD_NAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "@DUNE_MOD_URL@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@DUNE_MOD_VERSION@" + +/* end private */ + +/* Define to the version of $PROJECT */ +#define ${UNAME}_VERSION "@${UNAME}_VERSION@" + +/* Define to the major version of $PROJECT */ +#define ${UNAME}_VERSION_MAJOR @${UNAME}_VERSION_MAJOR@ + +/* Define to the minor version of $PROJECT */ +#define ${UNAME}_VERSION_MINOR @${UNAME}_VERSION_MINOR@ + +/* Define to the revision of $PROJECT */ +#define ${UNAME}_VERSION_REVISION @${UNAME}_VERSION_REVISION@ + +/* end $NAME + Everything below here will be overwritten +*/ +EOF +## done + +################# $PROJECT-config.cmake.in ##################### + +echo "- $PROJECT/$PROJECT""-config.cmake.in" +cat> "$PROJECT/$PROJECT""-config.cmake.in" <<EOF +if(NOT @DUNE_MOD_NAME@_FOUND) +#import the target +#include("@CMAKE_BINARY_DIR@/@DUNE_MOD_NAME@-targets.cmake") + +#report other information +set(@DUNE_MOD_NAME@_PREFIX "@CMAKE_SOURCE_DIR@") +set(@DUNE_MOD_NAME@_INCLUDE_DIRS "@CMAKE_SOURCE_DIR@") +set(@DUNE_MOD_NAME@_CXX_FLAGS "@CMAKE_CXX_FLAGS@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@") +set(@DUNE_MOD_NAME@_LIBRARIES "") # list exported libraries here +set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@") +set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@") +endif(NOT @DUNE_MOD_NAME@_FOUND) +EOF + ############################################################### ################## The source subdirectory #################### ############################################################### @@ -580,6 +660,8 @@ AUTOMAKE_OPTIONS = foreign 1.5 # pass most important options when "make distcheck" is used DISTCHECK_CONFIGURE_FLAGS = $DISTCHECK_CONFIGURE_FLAGS CXX="\$(CXX)" CC="\$(CC)" +EXTRA_DIST = CMakeLists.txt + include \$(top_srcdir)/am/global-rules M_DELIM @@ -625,7 +707,7 @@ M4FILES = $MODULE.m4 aclocaldir = \$(datadir)/aclocal aclocal_DATA = \$(M4FILES) -EXTRA_DIST = \$(M4FILES) +EXTRA_DIST = \$(M4FILES) CMakeLists.txt include \$(top_srcdir)/am/global-rules CC_DELIM @@ -675,6 +757,8 @@ echo "- $PROJECT/dune/Makefile.am" cat> $PROJECT/dune/Makefile.am <<EOF SUBDIRS = $NAME +EXTRA_DIST = CMakeLists.txt + include \$(top_srcdir)/am/global-rules EOF @@ -690,6 +774,8 @@ cat> $PROJECT/dune/$NAME/Makefile.am <<EOF ${NAME}includedir = \$(includedir)/dune/${NAME} ${NAME}include_HEADERS = ${NAME}.hh +EXTRA_DIST = CMakeLists.txt + include \$(top_srcdir)/am/global-rules EOF @@ -731,6 +817,8 @@ PAGES= docdir=\$(datadir)/doc/${PROJECT} +EXTRA_DIST = CMakeLists.txt + include \$(top_srcdir)/am/webstuff include \$(top_srcdir)/am/global-rules CC_DELIM @@ -797,11 +885,14 @@ cat> "$PROJECT/doc/doxygen/Makefile.am" << CC_DELIM BASEDIR=../.. CURDIR=doc/doxygen +EXTRA_DIST = CMakeLists.txt + include \$(top_srcdir)/am/doxygen include \$(top_srcdir)/am/global-rules CC_DELIM +################# doc/doxygen/CMakeLists.txt ##################### echo "- $PROJECT/doc/doxygen/CMakeLists.txt" cat> "$PROJECT/doc/doxygen/CMakeLists.txt" << CC_DELIM @@ -809,80 +900,32 @@ cat> "$PROJECT/doc/doxygen/CMakeLists.txt" << CC_DELIM add_doxygen_target() CC_DELIM -echo "- $PROJECT/config.h.cmake" -cat> "$PROJECT/config.h.cmake" <<EOF -/* begin $NAME - put the definitions for config.h specific to - your project here. Everything above will be - overwritten -*/ +######################################################### +############### The cmake subdirectory ################## +######################################################### -/* begin private */ -/* Name of package */ -#define PACKAGE "@DUNE_MOD_NAME" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "@DUNE_MOD_NAME@" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@DUNE_MOD_NAME@" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "@DUNE_MOD_URL@" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@DUNE_MOD_VERSION@" - -/* end private */ - -/* Define to the version of $PROJECT */ -#define ${UNAME}_VERSION "@${UNAME}_VERSION@" - -/* Define to the major version of $PROJECT */ -#define ${UNAME}_VERSION_MAJOR @${UNAME}_VERSION_MAJOR@ +mkdir "$PROJECT/cmake" +mkdir "$PROJECT/cmake/pkg" -/* Define to the minor version of $PROJECT */ -#define ${UNAME}_VERSION_MINOR @${UNAME}_VERSION_MINOR@ +################# cmake/Makefile.am ##################### -/* Define to the revision of $PROJECT */ -#define ${UNAME}_VERSION_REVISION @${UNAME}_VERSION_REVISION@ +echo "- $PROJECT/cmake/Makefile.am" +cat> "$PROJECT/cmake/Makefile.am" <<EOF +SUBDIRS = pkg -/* end $NAME - Everything below here will be overwritten -*/ +include \$(top_srcdir)/am/global-rules EOF -## done -echo "- $PROJECT/$PROJECT""-config.cmake.in" -cat> "$PROJECT/$PROJECT""-config.cmake.in" <<EOF -if(NOT @DUNE_MOD_NAME@_FOUND) -#import the target -#include("@CMAKE_BINARY_DIR@/@DUNE_MOD_NAME@-targets.cmake") +################# cmake/pkg/Makefile.am ##################### -#report other information -set(@DUNE_MOD_NAME@_PREFIX "@CMAKE_SOURCE_DIR@") -set(@DUNE_MOD_NAME@_INCLUDE_DIRS "@CMAKE_SOURCE_DIR@") -set(@DUNE_MOD_NAME@_CXX_FLAGS "@CMAKE_CXX_FLAGS@") -set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@") -set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@") -set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@") -set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@") -set(@DUNE_MOD_NAME@_LIBRARIES "") # list exported libraries here -set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@") -set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@") -endif(NOT @DUNE_MOD_NAME@_FOUND) -endif(NOT @DUNE_MOD_NAME@_FOUND) +echo "- $PROJECT/cmake/pkg/Makefile.am" +cat> "$PROJECT/cmake/pkg/Makefile.am" <<EOF +EXTRA_DIST = $PROJECT-config.cmake.in + +include \$(top_srcdir)/am/global-rules EOF -mkdir "$PROJECT/cmake" -mkdir "$PROJECT/cmake/modules" -mkdir "$PROJECT/cmake/pkg" +################# cmake/pkg/$PROJECT-config.cmake.in ##################### echo "- $PROJECT/cmake/pkg/$PROJECT""-config.cmake.in" cat> "$PROJECT/cmake/pkg/$PROJECT""-config.cmake.in" <<EOF @@ -908,6 +951,8 @@ set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@") endif(NOT @DUNE_MOD_NAME@_FOUND) EOF +################# $PROJECT-version.cmake.in ##################### + echo "- $PROJECT/$PROJECT""-version.cmake.in" cat> "$PROJECT/$PROJECT""-version.cmake.in" <<EOF set(PACKAGE_VERSION "@DUNE_MOD_VERSION@") @@ -919,6 +964,9 @@ if(NOT "\${PACKAGE_FIND_VERSION}" VERSION_GREATER "@DUNE_MOD_VERSION@") endif() endif() EOF + +################# stamp-regenerate-config-h ##################### + echo "- $PROJECT/stamp-regenerate-config-h" touch $PROJECT/stamp-regenerate-config-h echo diff --git a/cmake/modules/AddMETISFlags.cmake b/cmake/modules/AddMETISFlags.cmake index 7a5792874265fdd2712b8c0a06e200c0cd8b1bad..b0f4bde3cf10ff3b8d9327da00c9e31b2ca04ed0 100644 --- a/cmake/modules/AddMETISFlags.cmake +++ b/cmake/modules/AddMETISFlags.cmake @@ -11,7 +11,7 @@ function(add_dune_metis_flags _targets) foreach(_target ${_targets}) target_link_libraries(${_target} ${METIS_LIBRARY}) endforeach(_target ${_targets}) - set_property(TARGET ${_targets} APPEND PROPERTIES + set_property(TARGET ${_targets} APPEND PROPERTY COMPILE_DIRECTORIES ${METIS_INCLUDE_DIR}) endif(METIS_FOUND) endfunction(add_dune_metis_flags _targets) diff --git a/cmake/modules/AddUMFPackFlags.cmake b/cmake/modules/AddUMFPackFlags.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5ed6cdc2b45dcb5b8c18004db04d65c677f0cadb --- /dev/null +++ b/cmake/modules/AddUMFPackFlags.cmake @@ -0,0 +1,18 @@ +# module providing convenience mehtods for compiling bianries with UMFPack support +# +# Provides the following functions: +# +# add_dune_umfpack_flags(target1 target2...) +# +# adds UMFPack flags to the targets for compilation and linking +function(add_dune_umfpack_flags _targets) + if(UMFPACK_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${UMFPACK_DUNE_LIBRARIES}) + get_target_property(_props ${_target} COMPILE_FLAGS) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS + "${_props} ${UMFPACK_DUNE_COMPILE_FLAGS} -DENABLE_UMFPACK") + endforeach(_target ${_targets}) + endif(UMFPACK_FOUND) +endfunction(add_dune_umfpack_flags) \ No newline at end of file diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 77cbc9168bc0444eb23e60c23a91247f5c8b673f..3dcce83eb9adf3819be100c5c04822f8ac9aa7e8 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -2,6 +2,9 @@ set(modules AddGMPFlags.cmake AddMETISFlags.cmake AddParMETISFlags.cmake + AddUMFPackFlags.cmake + CheckCXX11Features.cmake + CheckSharedPtr.cmake DuneBoost.cmake DuneCommonMacros.cmake DuneCxaDemangle.cmake @@ -14,14 +17,12 @@ set(modules DuneTestMacros.cmake DuneTests.cmake FindBoostFusion.cmake - FindCXX11Conditional.cmake - FindCXX11Features.cmake FindGMP.cmake FindInkscape.cmake FindMETIS.cmake FindMProtect.cmake FindParMETIS.cmake - FindSharedPtr.cmake + FindUMFPack.cmake Headercheck.cmake LanguageSupport.cmake UseInkscape.cmake diff --git a/cmake/modules/FindCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake similarity index 84% rename from cmake/modules/FindCXX11Features.cmake rename to cmake/modules/CheckCXX11Features.cmake index fbb96ce4e53162fb37ee12ebcfc5fb24493d43ec..7aa05e646630739d1f0bfd8647b6bebf6fa6a7fe 100644 --- a/cmake/modules/FindCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -14,6 +14,8 @@ # HAVE_VARIADIC_TEMPLATES True if variadic templates are supprt # HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported # HAVE_RVALUE_REFERENCES True if rvalue references are supported +# HAVE_STD_CONDITIONAL True if std::conditional is supported +# HAVE_INITIALIZER_LIST True if initializer list is supported include(CMakePushCheckState) cmake_push_check_state() @@ -23,7 +25,7 @@ include(TestCXXAcceptsFlag) if(NOT DISABLE_GXX0XCHECK) # try to use compiler flag -std=c++11 - CHECK_CXX_ACCEPTS_FLAG("-std=c++11" CXX_FLAG_CXX11) + check_cxx_accepts_flag("-std=c++11" CXX_FLAG_CXX11) endif(NOT DISABLE_GXX0XCHECK) if(CXX_FLAG_CXX11) @@ -37,7 +39,7 @@ if(CXX_FLAG_CXX11) else() if(NOT DISABLE_GXX0XCHECK) # try to use compiler flag -std=c++0x for older compilers - CHECK_CXX_ACCEPTS_FLAG("-std=c++0x" CXX_FLAG_CXX0X) + check_cxx_accepts_flag("-std=c++0x" CXX_FLAG_CXX0X) endif(NOT DISABLE_GXX0XCHECK) if(CXX_FLAG_CXX0X) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x" ) @@ -53,7 +55,7 @@ endif(CXX_FLAG_CXX11) include(CheckCXXSourceCompiles) # nullptr -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" int main(void) { char* ch = nullptr; @@ -66,7 +68,7 @@ include(CheckIncludeFileCXX) if(NOT DISABLE_TR1_HEADERS) # array and fill -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #include <array> int main(void) @@ -102,14 +104,15 @@ endif(NOT HAVE_FUNCTIONAL) if(_functional_header) check_cxx_source_compiles(" -#include <${_functional_header}> -int main(void){ - ${_hash_type}<int> hasher; hasher(42); -}" ${_hash_variable}) + #include <${_functional_header}> + int main(void){ + ${_hash_type}<int> hasher; hasher(42); + } +" ${_hash_variable}) endif(_functional_header) # Check whether if std::integral_constant< T, v > is supported and casts into T -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #include <type_traits> void f( int ){} @@ -122,7 +125,7 @@ CHECK_CXX_SOURCE_COMPILES(" endif(NOT DISABLE_TR1_HEADERS) # __attribute__((unused)) -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" int main(void) { int __attribute__((unused)) foo; @@ -132,7 +135,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # __attribute__((deprecated)) -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #define DEP __attribute__((deprecated)) class bar { @@ -164,7 +167,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # __attribute__((deprecated("msg"))) -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #define DEP __attribute__((deprecated(\"message\"))) class bar { bar() DEP; @@ -196,7 +199,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # static assert -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" int main(void) { static_assert(true,\"MSG\"); @@ -206,7 +209,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # variadic template support -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #include <cassert> template<typename... T> @@ -232,7 +235,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # SFINAE on variadic template constructors within template classes -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #include <functional> template<typename... U> @@ -268,7 +271,7 @@ CHECK_CXX_SOURCE_COMPILES(" ) # rvalue references -CHECK_CXX_SOURCE_COMPILES(" +check_cxx_source_compiles(" #include <cassert> #include <utility> int foo(int&& x) { return 1; } @@ -288,4 +291,37 @@ CHECK_CXX_SOURCE_COMPILES(" } " HAVE_RVALUE_REFERENCES ) + +# std::conditional +check_cxx_source_compiles(" + #include <type_traits> + + int main(void){ + return std::conditional<true,std::integral_constant<int,0>,void>::type::value; + } +" HAVE_STD_CONDITIONAL +) + +# initializer list +check_cxx_source_compiles(" + #include <initializer_list> + #include <vector> + + struct A + { + A(std::initializer_list<int> il) + : vec(il) + {} + + std::vector<int> vec; + }; + + int main(void) + { + A a{1,3,4,5}; + return 0; + } +" HAVE_INITIALIZER_LIST +) + cmake_pop_check_state() diff --git a/cmake/modules/FindSharedPtr.cmake b/cmake/modules/CheckSharedPtr.cmake similarity index 87% rename from cmake/modules/FindSharedPtr.cmake rename to cmake/modules/CheckSharedPtr.cmake index 38288481e4cefa62796cab5c6580f5a01112b0ed..1a962c2f6869f3eb4969c49e61209edba0258048 100644 --- a/cmake/modules/FindSharedPtr.cmake +++ b/cmake/modules/CheckSharedPtr.cmake @@ -7,16 +7,16 @@ # SHARED_PTR_HEADER: The name of header file supplying shared_ptr # # check if make_shared works -macro(CHECK_MAKE_SHARED) +macro(check_make_shared) include(CheckIncludeFileCXX) if(SHARED_PTR_NAMESPACE EQUAL "boost") - CHECK_INCLUDE_FILE_CXX("boost/make_shared.hpp" HAVE_BOOST_MAKE_SHARED_HPP) + check_include_file_cxx("boost/make_shared.hpp" HAVE_BOOST_MAKE_SHARED_HPP) endif(SHARED_PTR_NAMESPACE EQUAL "boost") - CHECK_INCLUDE_FILE_CXX("boost/shared_ptr.hpp" HAVE_BOOST_SHARED_PTR_HPP) + check_include_file_cxx("boost/shared_ptr.hpp" HAVE_BOOST_SHARED_PTR_HPP) - CHECK_CXX_SOURCE_COMPILES(" + check_cxx_source_compiles(" #if defined(HAVE_MEMORY) # include <memory> #endif @@ -34,14 +34,14 @@ macro(CHECK_MAKE_SHARED) return 0; } " HAVE_MAKE_SHARED) -endmacro(CHECK_MAKE_SHARED) +endmacro(check_make_shared) # check location of shared_ptr header file and the necessary namespace include(CheckCXXSourceCompiles) # search namespace foreach(SHARED_PTR_NAMESPACE_ "std" "tr1" "std::tr1" "boost") - CHECK_CXX_SOURCE_COMPILES(" + check_cxx_source_compiles(" #include <memory> #include <string> @@ -58,7 +58,7 @@ foreach(SHARED_PTR_NAMESPACE_ "std" "tr1" "std::tr1" "boost") if(SHARED_PTR_NAMESPACE_FOUND) #search header name foreach(SHARED_PTR_HEADER_ "<memory>" "<tr1/memory>" "<boost/shared_ptr.hpp>") - CHECK_CXX_SOURCE_COMPILES(" + check_cxx_source_compiles(" # include ${SHARED_PTR_HEADER_} #include <string> @@ -76,7 +76,7 @@ foreach(SHARED_PTR_NAMESPACE_ "std" "tr1" "std::tr1" "boost") # save result set(SHARED_PTR_NAMESPACE ${SHARED_PTR_NAMESPACE_}) set(SHARED_PTR_HEADER ${SHARED_PTR_HEADER_}) - CHECK_MAKE_SHARED() + check_make_shared() return() endif(SHARED_PTR_HEADER_FOUND) endforeach(SHARED_PTR_HEADER_) diff --git a/cmake/modules/DuneCommonMacros.cmake b/cmake/modules/DuneCommonMacros.cmake index 8f89d8771542368df38eead1fc577dbf1add2f18..49dbb13127cee4c98dbfaa21311377f9a8dca070 100644 --- a/cmake/modules/DuneCommonMacros.cmake +++ b/cmake/modules/DuneCommonMacros.cmake @@ -8,7 +8,7 @@ include(DuneStreams) dune_set_minimal_debug_level() -find_package(SharedPtr) +include(CheckSharedPtr) if(Fortran_Works) # search for lapack find_package(LAPACK) diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index 1ae2f456fb33e291600403cf68f70a7871b6b021..7cb1c937573312daea6cf9c09f7214add8ae360e 100644 --- a/cmake/modules/DuneMacros.cmake +++ b/cmake/modules/DuneMacros.cmake @@ -423,8 +423,7 @@ macro(dune_project) endif(DUNE_USE_ONLY_STATIC_LIBS) # set required compiler flags for C++11 (former C++0x) - find_package(CXX11Features) - find_package(CXX11Conditional) + include(CheckCXX11Features) include(DuneCxaDemangle) diff --git a/cmake/modules/FindCXX11Conditional.cmake b/cmake/modules/FindCXX11Conditional.cmake deleted file mode 100644 index 6c85ca65ed3d01b1b6f558dcd4e077a57f3a9239..0000000000000000000000000000000000000000 --- a/cmake/modules/FindCXX11Conditional.cmake +++ /dev/null @@ -1,17 +0,0 @@ -# Module that checks whether the compiler supports -# C++11 std::conditional. -# -# Sets the following variable: -# HAVE_STD_CONDITIONAL -# -# perform tests -include(CheckCXXSourceCompiles) - -check_cxx_source_compiles(" - - #include <type_traits> - - int main(void){ - return std::conditional<true,std::integral_constant<int,0>,void>::type::value; - }" - HAVE_STD_CONDITIONAL) diff --git a/cmake/modules/FindMETIS.cmake b/cmake/modules/FindMETIS.cmake index cda8da0b8dd8fd07020aca268b81cf0245674959..8aa3efdc3f71b0c34afe0ff008ff50b2e6ae9d8a 100644 --- a/cmake/modules/FindMETIS.cmake +++ b/cmake/modules/FindMETIS.cmake @@ -52,7 +52,7 @@ if(METIS_LIBRARY) list(APPEND CMAKE_REQUIRED_LIBRARIES ${METIS_LIBRARIY}) set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${METIS_LIBRARY}) include(CheckSymbolExists) - check_function_exists(METIS_PartMeshDual HAVE_METIS_PARTMESH_DUAL) + check_function_exists(METIS_PartGraphKway HAVE_METIS_PARTGRAPHKWAY) endif(METIS_LIBRARY) # behave like a CMake module is supposed to behave @@ -62,7 +62,7 @@ find_package_handle_standard_args( DEFAULT_MSG METIS_INCLUDE_DIR METIS_LIBRARY - HAVE_METIS_PARTMESH_DUAL + HAVE_METIS_PARTGRAPHKWAY ) cmake_pop_check_state() @@ -91,4 +91,4 @@ if(METIS_FOUND) foreach(dir ${METIS_INCLUDE_DIRS}) set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}") endforeach() -endif() \ No newline at end of file +endif() diff --git a/cmake/modules/FindUMFPack.cmake b/cmake/modules/FindUMFPack.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8e60b4350c412e62d9d560b11275070a29cc04c0 --- /dev/null +++ b/cmake/modules/FindUMFPack.cmake @@ -0,0 +1,112 @@ +# Module that checks whether UMFPack is available. +# +# Variables used by this module which you may want to set: +# UMFPACK_ROOT Path list to search for UMFPack +# +# Sets the following variables +# +# UMFPACK_FOUND True if UMFPack was found and usable +# UMFPACK_INCLUDE_DIRS Path to the UMFPack include dirs +# UMFPACK_LIBRARIES Name of the UMFPack libraries +# + +find_package(BLAS QUIET REQUIRED) +if(NOT BLAS_FOUND) + message(WARNING "UMFPack requires BLAS which was not found, skipping the test.") + return() +endif() + +find_library(AMD_LIBRARY + NAMES "amd" + PATHS ${UMFPACK_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "AMD" "AMD/Lib" + NO_DEFAULT_PATH +) + +find_library(AMD_LIBRARY + NAMES "amd" + PATH_SUFFIXES "lib" "lib32" "lib64" "AMD" "AMD/Lib" +) + +if(NOT AMD_LIBRARY) + message(WARNING "UMFPack requires AMD which was not found, skipping the test.") + return() +endif() + +#look for header files at positions given by the user +find_path(UMFPACK_INCLUDE_DIR + NAMES "umfpack.h" + PATHS ${UMFPACK_ROOT} + PATH_SUFFIXES "umfpack" "include/umfpack" "suitesparse" "include" "src" "UMFPACK" "UMFPACK/Include" + NO_DEFAULT_PATH +) +#now also look for default paths +find_path(UMFPACK_INCLUDE_DIR + NAMES "umfpack.h" + PATH_SUFFIXES "umfpack" "include/umfpack" "suitesparse" "include" "UMFPACK" "UMFPACK/Include" +) + +#look for library at positions given by the user +find_library(UMFPACK_LIBRARY + NAMES "umfpack" + PATHS ${UMFPACK_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "UMFPACK" "UMFPACK/Lib" + NO_DEFAULT_PATH +) +#now also include the deafult paths +find_library(UMFPACK_LIBRARY + NAMES "umfpack" + PATH_SUFFIXES "lib" "lib32" "lib64" "UMFPACK" "UMFPACK/Lib" +) + +if(UMFPACK_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${UMFPACK_INCLUDE_DIR} ${AMD_INCLUDE_DIR}) +endif() +if(UMFPACK_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${UMFPACK_LIBRARY}) +endif() +if(BLAS_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES}) +endif() +if(AMD_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${AMD_LIBRARY}) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "UMFPack" + DEFAULT_MSG + UMFPACK_INCLUDE_DIR + UMFPACK_LIBRARY +) + +mark_as_advanced(UMFPACK_INCLUDE_DIR UMFPACK_LIBRARY) + +if(UMFPACK_FOUND) + set(UMFPACK_INCLUDE_DIRS ${UMFPACK_INCLUDE_DIR}) + set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARY}) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of UMFPack succeded:\n" + "Include directory: ${UMFPACK_INCLUDE_DIRS}\n" + "Library directory: ${UMFPACK_LIBRARIES}\n\n") + set(UMFPACK_DUNE_COMPILE_FLAGS "-I${UMFPACK_INCLUDE_DIRS}" + CACHE STRING "Compile Flags used by DUNE when compiling with UMFPack programs") + set(UMFPACK_DUNE_LIBRARIES ${UMFPACK_LIBRARIES} ${BLAS_LIBRARIES} ${AMD_LIBRARY} + CACHE STRING "LIbraries used by DUNE when linking UMFPack programs") +else(UMFPACK_FOUND) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log + "Determing location of UMFPack failed:\n" + "Include directory: ${UMFPACK_INCLUDE_DIRS}\n" + "Library directory: ${UMFPACK_LIBRARIES}\n\n") +endif(UMFPACK_FOUND) + +#set HAVE_UMFPACK for config.h +set(HAVE_UMFPACK UMFPACK_FOUND) + +#add all umfpack related flags to ALL_PKG_FLAGS, this must happen regardless of a target using add_dune_umfpack_flags +if(UMFPACK_FOUND) + set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "${UMFPACK_DUNE_COMPILE_FLAGS}") + foreach(dir "${UMFPACK_INCLUDE_DIRS}") + set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}") + endforeach() +endif() \ No newline at end of file diff --git a/cmake/modules/Headercheck.cmake b/cmake/modules/Headercheck.cmake index 148187555142d792a62828c88b5eaecd31b08ac3..b12af40717925976637b6f9129ec709aef98e2ad 100644 --- a/cmake/modules/Headercheck.cmake +++ b/cmake/modules/Headercheck.cmake @@ -4,7 +4,9 @@ macro(setup_headercheck) #glob for headers file(GLOB_RECURSE src_headers "src/*.hh") file(GLOB_RECURSE dune_headers "dune/*.hh") - set_property(GLOBAL PROPERTY headercheck_list ${src_headers} ${dune_headers}) + # strip hidden files + string(REGEX REPLACE "[^;]*/\\.[^;]*\\.hh;?" "" headers "${dune_headers};${src_headers}") + set_property(GLOBAL PROPERTY headercheck_list ${headers}) #define headercheck target dune_common_script_dir(SCRIPT_DIR) @@ -66,4 +68,4 @@ macro(finalize_headercheck) set_property(TARGET headercheck_${targname} PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/headercheck/${relpath}") add_dune_all_flags(headercheck_${targname}) endforeach(header ${headerlist}) -endmacro(finalize_headercheck) \ No newline at end of file +endmacro(finalize_headercheck) diff --git a/cmake/modules/Makefile.am b/cmake/modules/Makefile.am index cd86b02066a4f37b7114be7db24ed98b4281321b..4676f1ea43e6da471f6263bef414c5608c6cd260 100644 --- a/cmake/modules/Makefile.am +++ b/cmake/modules/Makefile.am @@ -1,4 +1,8 @@ -MODULES = DuneBoost.cmake \ +MODULES = \ + CheckCXX11Features.cmake \ + CheckSharedPtr.cmake \ + AddUMFPackFlags.cmake \ + DuneBoost.cmake \ DuneCommonMacros.cmake \ DuneCxaDemangle.cmake \ DuneDoc.cmake \ @@ -10,14 +14,12 @@ MODULES = DuneBoost.cmake \ DuneTestMacros.cmake \ DuneTests.cmake \ FindBoostFusion.cmake \ - FindCXX11Conditional.cmake \ - FindCXX11Features.cmake \ FindGMP.cmake \ FindInkscape.cmake \ FindMETIS.cmake \ FindMProtect.cmake \ FindParMETIS.cmake \ - FindSharedPtr.cmake \ + FindUMFPack.cmake \ Headercheck.cmake \ LanguageSupport.cmake \ UseLATEX.cmake diff --git a/cmake/scripts/FindFiles.cmake b/cmake/scripts/FindFiles.cmake index e4832811d0274e54065b4aaf53ad177437d9594e..fa012d8c5ac0730ac80301c3a3a9cf9d6f753824 100644 --- a/cmake/scripts/FindFiles.cmake +++ b/cmake/scripts/FindFiles.cmake @@ -2,10 +2,13 @@ cmake_policy(SET CMP0009 NEW) file(GLOB_RECURSE makefiles RELATIVE ${RELPATH} "CMakeLists.txt") foreach(_file ${makefiles}) - string(REGEX MATCH ".*/test$" _testdir ${_file}) - if(_testdir) + # path contains "/test" + string(REGEX MATCH ".*/test" _testdir ${_file}) + # path end with "/test" and not "/testFoo" or "/test/foo" + string(REGEX MATCH ".*/test/CMakeLists.txt$" _testdirensured ${_file}) + if(_testdir AND _testdirensured) list(APPEND _makefiles ${_testdir}) - endif(_testdir) + endif(_testdir AND _testdirensured) endforeach(_file ${makefiles}) if(_makefiles) message("${_makefiles}") diff --git a/config.h.cmake b/config.h.cmake index af32e048e87c7fa5f694b68ff0808a918bf0103e..dde41d58022b09cc842ff6d71aa1854a71fb20e1 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -157,6 +157,9 @@ /* Define to 1 if rvalue references are supported */ #cmakedefine HAVE_RVALUE_REFERENCES 1 +/* Define to 1 if initializer list is supported */ +#cmakedefine HAVE_INITIALIZER_LIST 1 + /* Include always useful headers */ #include <dune/common/deprecated.hh> #include <dune/common/unused.hh> diff --git a/configure.ac b/configure.ac index 36700e251b3db72a8781fdffae47f79105faefe5..b836e3033bfaf6ac25ea392f4fb62b985a32cdc6 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_CONFIG_FILES([Makefile dune/common/test/Makefile dune/common/parallel/Makefile dune/common/parallel/test/Makefile + dune/common/std/Makefile doc/Makefile doc/comm/Makefile doc/comm/figures/Makefile diff --git a/dune/common/CMakeLists.txt b/dune/common/CMakeLists.txt index 43fe8fc7bb947de70988c3dd100ca531283619c3..0075584a18fcac0a6ad17fc627bd7032bf1e0f56 100644 --- a/dune/common/CMakeLists.txt +++ b/dune/common/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory("parallel") +add_subdirectory("std") add_subdirectory("test" EXCLUDE_FROM_ALL) #build the library dunecommon @@ -86,12 +87,14 @@ install(FILES sllist.hh static_assert.hh stdstreams.hh + stringutility.hh timer.hh tuples.hh tupleutility.hh typetraits.hh unused.hh version.hh + visibility.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common) # Install some test headers, because they get used by tests in other modules diff --git a/dune/common/Makefile.am b/dune/common/Makefile.am index 75e9d54e8fbe891a8e2b2ddf7ffb21b792039598..189757a8299c6a372acaae52444c8ff95a815ea7 100644 --- a/dune/common/Makefile.am +++ b/dune/common/Makefile.am @@ -1,6 +1,6 @@ # $Id$ -SUBDIRS = . test parallel +SUBDIRS = . test parallel std # the standard debug streams are put into the libdune noinst_LTLIBRARIES = libcommon.la @@ -89,7 +89,8 @@ commoninclude_HEADERS = \ tupleutility.hh \ typetraits.hh \ unused.hh \ - version.hh + version.hh \ + visibility.hh include $(top_srcdir)/am/global-rules diff --git a/dune/common/array.hh b/dune/common/array.hh index eeca2dbb702c3b946b451a6236bf6317a992765a..cf2cf3ae0aec507eb138fe9c904e80ee9b3d81c8 100644 --- a/dune/common/array.hh +++ b/dune/common/array.hh @@ -173,25 +173,25 @@ namespace Dune #ifndef DOXYGEN template<class T> array<T, 1> make_array(const T &t0) { - array<T, 1> result = { t0 }; + array<T, 1> result = { {t0} }; return result; } template<class T> array<T, 2> make_array(const T &t0, const T &t1) { - array<T, 2> result = { t0, t1 }; + array<T, 2> result = { {t0, t1} }; return result; } template<class T> array<T, 3> make_array(const T &t0, const T &t1, const T &t2) { - array<T, 3> result = { t0, t1, t2 }; + array<T, 3> result = { {t0, t1, t2} }; return result; } template<class T> array<T, 4> make_array(const T &t0, const T &t1, const T &t2, const T &t3) { - array<T, 4> result = { t0, t1, t2, t3 }; + array<T, 4> result = { {t0, t1, t2, t3} }; return result; } @@ -199,7 +199,7 @@ namespace Dune array<T, 5> make_array(const T &t0, const T &t1, const T &t2, const T &t3, const T &t4) { - array<T, 5> result = { t0, t1, t2, t3, t4 }; + array<T, 5> result = { {t0, t1, t2, t3, t4} }; return result; } @@ -207,7 +207,7 @@ namespace Dune array<T, 6> make_array(const T &t0, const T &t1, const T &t2, const T &t3, const T &t4, const T &t5) { - array<T, 6> result = { t0, t1, t2, t3, t4, t5 }; + array<T, 6> result = { {t0, t1, t2, t3, t4, t5} }; return result; } @@ -215,7 +215,7 @@ namespace Dune array<T, 7> make_array(const T &t0, const T &t1, const T &t2, const T &t3, const T &t4, const T &t5, const T &t6) { - array<T, 7> result = { t0, t1, t2, t3, t4, t5, t6 }; + array<T, 7> result = { {t0, t1, t2, t3, t4, t5, t6} }; return result; } @@ -223,7 +223,7 @@ namespace Dune array<T, 8> make_array(const T &t0, const T &t1, const T &t2, const T &t3, const T &t4, const T &t5, const T &t6, const T &t7) { - array<T, 8> result = { t0, t1, t2, t3, t4, t5, t6, t7 }; + array<T, 8> result = { {t0, t1, t2, t3, t4, t5, t6, t7} }; return result; } @@ -232,7 +232,7 @@ namespace Dune const T &t4, const T &t5, const T &t6, const T &t7, const T &t8) { - array<T, 9> result = { t0, t1, t2, t3, t4, t5, t6, t7, t8 }; + array<T, 9> result = { {t0, t1, t2, t3, t4, t5, t6, t7, t8} }; return result; } #endif // !DOXYGEN diff --git a/dune/common/fmatrix.hh b/dune/common/fmatrix.hh index 826399ebb0e33c26874654c78259bd331cc9afaa..0c6a5ad4179d883e4e542fcb1e1c92b3db281913 100644 --- a/dune/common/fmatrix.hh +++ b/dune/common/fmatrix.hh @@ -13,6 +13,7 @@ #include <dune/common/densematrix.hh> #include <dune/common/precision.hh> #include <dune/common/static_assert.hh> +#include <dune/common/std/constexpr.hh> namespace Dune { @@ -168,8 +169,8 @@ namespace Dune } // make this thing a matrix - size_type mat_rows() const { return ROWS; } - size_type mat_cols() const { return COLS; } + DUNE_CONSTEXPR size_type mat_rows() const { return ROWS; } + DUNE_CONSTEXPR size_type mat_cols() const { return COLS; } row_reference mat_access ( size_type i ) { @@ -270,8 +271,8 @@ namespace Dune } // make this thing a matrix - size_type mat_rows() const { return 1; } - size_type mat_cols() const { return 1; } + DUNE_CONSTEXPR size_type mat_rows() const { return 1; } + DUNE_CONSTEXPR size_type mat_cols() const { return 1; } row_reference mat_access ( size_type i ) { diff --git a/dune/common/fvector.hh b/dune/common/fvector.hh index 8fd550e69780aad247ac40bebde1c942a7569fd5..d9b3860add3f134ed67b850e7670f1c400518087 100644 --- a/dune/common/fvector.hh +++ b/dune/common/fvector.hh @@ -9,6 +9,9 @@ #include <cstdlib> #include <complex> #include <cstring> +#include <utility> + +#include <dune/common/std/constexpr.hh> #include "typetraits.hh" #include "exceptions.hh" @@ -98,8 +101,22 @@ namespace Dune { typedef typename Base::size_type size_type; typedef typename Base::value_type value_type; - //! Constructor making uninitialized vector - FieldVector() {} + //! Constructor making default-initialized vector + FieldVector() + // Use C++11 unified initialization if available - tends to generate + // fastest code +#if HAVE_INITIALIZER_LIST + : _data{} + {} +#else + { + // fall back to library approach - this gives faster code than array placement + // new. Apart from that, placement new may create problems if K is a complex + // type. In that case, the default constructor of the _data elements has already + // been called and may have allocated memory. + std::fill(_data.begin(),_data.end(),K()); + } +#endif //! Constructor making vector with identical coordinates explicit FieldVector (const K& t) @@ -141,8 +158,10 @@ namespace Dune { } using Base::operator=; + DUNE_CONSTEXPR size_type size () const { return vec_size(); } + // make this thing a vector - size_type vec_size() const { return SIZE; } + DUNE_CONSTEXPR size_type vec_size () const { return SIZE; } K & vec_access(size_type i) { return _data[i]; } const K & vec_access(size_type i) const { return _data[i]; } private: @@ -205,7 +224,9 @@ namespace Dune { //===== construction /** \brief Default constructor */ - FieldVector () {} + FieldVector () + : _data() + {} /** \brief Constructor with a given scalar */ FieldVector (const K& k) : _data(k) {} @@ -226,8 +247,10 @@ namespace Dune { return *this; } + DUNE_CONSTEXPR size_type size () const { return vec_size(); } + //===== forward methods to container - size_type vec_size() const { return 1; } + DUNE_CONSTEXPR size_type vec_size () const { return 1; } K & vec_access(size_type i) { assert(i == 0); diff --git a/dune/common/hash.hh b/dune/common/hash.hh index 1dea7760f54fac28408058c158b107d59d7e184e..b47532fc272d3594d66de62b82684098225974ae 100644 --- a/dune/common/hash.hh +++ b/dune/common/hash.hh @@ -3,6 +3,8 @@ #ifndef DUNE_COMMON_HASH_HH #define DUNE_COMMON_HASH_HH +#include <dune/common/typetraits.hh> + #if HAVE_STD_HASH #include <functional> #endif @@ -329,6 +331,90 @@ namespace Dune { // that implementation uses boost::hash internally, while we want to use Dune::hash. They // are also considered for inclusion in TR2 (then based on std::hash, of course). +#ifndef DOXYGEN + + // helper struct for providing different hash combining algorithms dependent on + // the size of size_t. + // hash_combiner has to be specialized for the size (in bytes) of std::size_t. + // Specialized versions should provide a method + // + // template <typename T> + // void operator()(std::size_t& seed, const T& arg) const; + // + // that will be called by the interface function hash_combine() described further below. + // + // There is no default implementation! + template<int sizeof_size_t> + struct hash_combiner; + + + // hash combining for 64-bit platforms. + template<> + struct hash_combiner<8> + { + + template<typename T> + void operator()(std::size_t& seed, const T& arg) const + { + // The following algorithm for combining two 64-bit hash values is inspired by a similar + // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.h), + // which is in turn based on ideas from the MurmurHash library. The basic idea is easy to + // grasp, though: New information is XORed into the existing hash multiple times at different + // places (using shift operations), and the resulting pattern is spread over the complete + // range of available bits via multiplication with a "magic" constant. The constants used + // below (47 and 0x9ddfea08eb382d69ULL) are taken from the CityHash implementation. + // + // We opted not to use the mixing algorithm proposed in the C++ working group defect list at + // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, p. 57f. because it + // has very bad hash distribution properties if you apply it to lists of very small numbers, + // an application that is frequent in PDELab's ordering framework. + + Dune::hash<T> hasher; + const std::size_t kMul = 0x9ddfea08eb382d69ULL; + std::size_t h = hasher(arg); + std::size_t a = (seed ^ h) * kMul; + a ^= (a >> 47); + std::size_t b = (h ^ a) * kMul; + b ^= (b >> 47); + b *= kMul; + seed = b; + } + + }; + + + // hash combining for 32-bit platforms. + template<> + struct hash_combiner<4> + { + + template<typename T> + void operator()(std::size_t& seed, const T& arg) const + { + // The default algorithm above requires a 64-bit std::size_t. The following algorithm is a + // 32-bit compatible fallback, again inspired by CityHash and MurmurHash + // (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.cc). + // It uses 32-bit constants and relies on rotation instead of multiplication to spread the + // mixed bits as that is apparently more efficient on IA-32. The constants used below are again + // taken from CityHash, in particular from the file referenced above. + + Dune::hash<T> hasher; + const std::size_t c1 = 0xcc9e2d51; + const std::size_t c2 = 0x1b873593; + const std::size_t c3 = 0xe6546b64; + std::size_t h = hasher(arg); + std::size_t a = seed * c1; + a = (a >> 17) | (a << (32 - 17)); + a *= c2; + h ^= a; + h = (h >> 19) | (h << (32 - 19)); + seed = h * 5 + c3; + } + + }; + +#endif // DOXYGEN + //! Calculates the hash value of arg and combines it in-place with seed. /** * \note This function is only available if the macro `HAVE_DUNE_HASH` is defined. @@ -339,27 +425,7 @@ namespace Dune { template<typename T> inline void hash_combine(std::size_t& seed, const T& arg) { - Dune::hash<T> hasher; - // The following algorithm for combining two 64-bit hash values is inspired by a similar - // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.h), - // which is in turn based on ideas from the MurmurHash library. The basic idea is easy to - // grasp, though: New information is XORed into the existing hash multiple times at different - // places (using shift operations), and the resulting pattern is spread over the complete - // range of available bits via multiplication with a "magic" constant. The constants used - // below (47 and 0x9ddfea08eb382d69ULL) are taken from the CityHash implementation. - // - // We opted not to use the mixing algorithm proposed in the C++ working group defect list at - // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, p. 57f. because it - // has very bad hash distribution properties if you apply it to lists of very small numbers, - // an application that is frequent in PDELab's ordering framework. - const std::size_t kMul = 0x9ddfea08eb382d69ULL; - std::size_t h = hasher(arg); - std::size_t a = (seed ^ h) * kMul; - a ^= (a >> 47); - std::size_t b = (h ^ a) * kMul; - b ^= (b >> 47); - b *= kMul; - seed = b; + hash_combiner<sizeof(std::size_t)>()(seed,arg); } //! Hashes all elements in the range [first,last) and returns the combined hash. diff --git a/dune/common/parallel/mpihelper.hh b/dune/common/parallel/mpihelper.hh index fb164eb31139a9fe950904af3d94a12f13ddaf80..fedc945151da24f19f1d4647ee719825bb70cd5c 100644 --- a/dune/common/parallel/mpihelper.hh +++ b/dune/common/parallel/mpihelper.hh @@ -12,6 +12,7 @@ #endif #include <dune/common/stdstreams.hh> +#include <dune/common/visibility.hh> namespace Dune { @@ -86,7 +87,7 @@ namespace Dune * * \returns a fake communicator */ - static MPICommunicator getCommunicator () + DUNE_EXPORT static MPICommunicator getCommunicator () { static MPICommunicator comm; return comm; @@ -126,7 +127,7 @@ namespace Dune * @param argc The number of arguments provided to main. * @param argv The arguments provided to main. */ - static FakeMPIHelper& instance(int argc, char** argv) + DUNE_EXPORT static FakeMPIHelper& instance(int argc, char** argv) { // create singleton instance static FakeMPIHelper singleton; @@ -213,7 +214,7 @@ namespace Dune * @param argc The number of arguments provided to main. * @param argv The arguments provided to main. */ - static MPIHelper& instance(int& argc, char**& argv) + DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv) { // create singleton instance static MPIHelper singleton (argc, argv); diff --git a/dune/common/std/CMakeLists.txt b/dune/common/std/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..72127b7bb33a24b580510b3745c71ae0872a2a47 --- /dev/null +++ b/dune/common/std/CMakeLists.txt @@ -0,0 +1,3 @@ +install(FILES + constexpr.hh +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/std) diff --git a/dune/common/std/Makefile.am b/dune/common/std/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..70c1b96e564c5d7625127b3065c3f7cf04e0c9fa --- /dev/null +++ b/dune/common/std/Makefile.am @@ -0,0 +1,7 @@ +stdincludedir = $(includedir)/dune/common/std +stdinclude_HEADERS = \ + constexpr.hh + +EXTRA_DIST = CMakeLists.txt + +include $(top_srcdir)/am/global-rules diff --git a/dune/common/std/constexpr.hh b/dune/common/std/constexpr.hh new file mode 100644 index 0000000000000000000000000000000000000000..7292d84395831acb4b1295fe131f8eea540d43d6 --- /dev/null +++ b/dune/common/std/constexpr.hh @@ -0,0 +1,10 @@ +#ifndef DUNE_COMMON_STD_CONSTEXPR_HH +#define DUNE_COMMON_STD_CONSTEXPR_HH + +#if HAVE_CONSTEXPR +#define DUNE_CONSTEXPR constexpr +#else // #if HAVE_CONSTEXPR +#define DUNE_CONSTEXPR +#endif // #else // #if HAVE_CONSTEXPR + +#endif // #ifndef DUNE_COMMON_STD_CONSTEXPR_HH diff --git a/dune/common/visibility.hh b/dune/common/visibility.hh new file mode 100644 index 0000000000000000000000000000000000000000..e01956567de3e83b1b277763ab9cdc6a27873dd2 --- /dev/null +++ b/dune/common/visibility.hh @@ -0,0 +1,43 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_VISIBILITY_HH +#define DUNE_COMMON_VISIBILITY_HH + +/** \file + * \brief Definition of macros controlling symbol visibility at the ABI level. + */ + +#ifdef DOXYGEN + +//! Export a symbol as part of the public ABI. +/** + * Mark a class, function or static variable as visible outside the current DSO. + * For now, this is mostly important for templated global variables and functions + * that contain static variables. + */ +#define DUNE_EXPORT implementation_defined + +//! Mark a symbol as being for internal use within the current DSO only. +/** + * Mark a class, function or static variable as inaccessible from outside the current DSO. + * Doing so will decrease the size of the symbol table, but you have to be sure that the + * symbol will never have to be accessed from another library or the main executable! + */ +#define DUNE_PRIVATE implementation_defined + +#else // DOXYGEN + +#if __GNUC__ >= 4 +// GCC and Clang both define __GNUC__ to 4 and they both support the visibility +// attribute +#define DUNE_EXPORT __attribute__((visibility("default"))) +#define DUNE_PRIVATE __attribute__((visibility("hidden"))) +#else +// We don't know about the active compiler, so just turn the visibility macros to no-ops. +#define DUNE_EXPORT +#define DUNE_PRIVATE +#endif + +#endif // DOXYGEN + +#endif // DUNE_COMMON_VISIBILITY diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt index 40c791eb1a29f6d3837fee16a753360a7a05ba01..60aac3a728997de320ffad5779b3b37533cfd0b1 100644 --- a/m4/CMakeLists.txt +++ b/m4/CMakeLists.txt @@ -13,6 +13,7 @@ install(PROGRAMS cxx0x_static_assert.m4 cxx0x_variadic.m4 cxx0x_variadic_constructor_sfinae.m4 + cxx11_initializer_list.m4 cxx11_conditional.m4 dune.m4 dune_all.m4 @@ -42,6 +43,7 @@ install(PROGRAMS opengl.m4 parmetis.m4 shared_ptr.m4 + umfpack.m4 xdr.m4 DESTINATION share/aclocal ) diff --git a/m4/Makefile.am b/m4/Makefile.am index 32fbabbd59d89418cc3fe28357981e2308b74613..c012a103c50449d15afeac46bf96f9d55ef1351e 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -17,6 +17,7 @@ ALLM4S = \ cxx0x_static_assert.m4 \ cxx0x_variadic.m4 \ cxx0x_variadic_constructor_sfinae.m4 \ + cxx11_initializer_list.m4 \ cxx11_conditional.m4 \ dune.m4 \ dune_all.m4 \ @@ -46,6 +47,7 @@ ALLM4S = \ opengl.m4 \ parmetis.m4 \ shared_ptr.m4 \ + umfpack.m4 \ xdr.m4 aclocaldir = $(datadir)/aclocal diff --git a/m4/cxx11_constexpr.m4 b/m4/cxx11_constexpr.m4 new file mode 100644 index 0000000000000000000000000000000000000000..12b7b7accf676b0c038cc6c84f2c7fb6b774ea8d --- /dev/null +++ b/m4/cxx11_constexpr.m4 @@ -0,0 +1,28 @@ +# tests for C++11 constexpr support +# the associated macro is called HAVE_CONSTEXPR + +AC_DEFUN([CXX11_CONSTEXPR_CHECK],[ + AC_CACHE_CHECK([for C++11 constexpr], dune_cv_cxx11_constexpr_support, [ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([GXX0X]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + constexpr int foo () { return 0; } + + template< int v > + struct A + { + static const int value = v; + }; + ],[ + return A< foo() >::value; + ])], + dune_cv_cxx11_constexpr_support=yes, + dune_cv_cxx11_constexpr_support=no) + AC_LANG_POP + ]) + if test "x$dune_cv_cxx11_constexpr_support" = xyes; then + AC_DEFINE(HAVE_CONSTEXPR, 1, [Define to 1 if C++11 constexpr is supported]) + fi +]) diff --git a/m4/cxx11_initializer_list.m4 b/m4/cxx11_initializer_list.m4 new file mode 100644 index 0000000000000000000000000000000000000000..04fc9ff86bc43fe9e90312a6a5f303585ca1f5aa --- /dev/null +++ b/m4/cxx11_initializer_list.m4 @@ -0,0 +1,37 @@ +# tests for C++11 initializer list support +# the associated macro is called HAVE_INITIALIZER_LIST + +AC_DEFUN([INITIALIZER_LIST_CHECK],[ + AC_CACHE_CHECK([whether std::initializer_list is supported], dune_cv_initializer_list_support, [ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([GXX0X]) + AC_LANG_PUSH([C++]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([ + + #include <initializer_list> + #include <vector> + + struct A + { + + A(std::initializer_list<int> il) + : vec(il) + {} + + std::vector<int> vec; + }; + + ], + [ + A a{1,3,4,5}; + return 0; + ])], + dune_cv_initializer_list_support=yes, + dune_cv_initializer_list_support=no) + AC_LANG_POP + ]) + if test "x$dune_cv_initializer_list_support" = xyes; then + AC_DEFINE(HAVE_INITIALIZER_LIST, 1, [Define to 1 if std::initializer_list is supported]) + fi +]) diff --git a/m4/dune_common.m4 b/m4/dune_common.m4 index 639397b43e64431b75c88374f574c0e325818cab..5b13851d610dfa2e28b01dc0c7a481e0ffe57947 100644 --- a/m4/dune_common.m4 +++ b/m4/dune_common.m4 @@ -24,7 +24,9 @@ AC_DEFUN([DUNE_COMMON_CHECKS], AC_REQUIRE([SHARED_PTR]) AC_REQUIRE([VARIADIC_TEMPLATES_CHECK]) AC_REQUIRE([RVALUE_REFERENCES_CHECK]) + AC_REQUIRE([INITIALIZER_LIST_CHECK]) AC_REQUIRE([CXX11_CONDITIONAL_CHECK]) + AC_REQUIRE([CXX11_CONSTEXPR_CHECK]) AC_REQUIRE([DUNE_BOOST_BASE]) AC_REQUIRE([MAKE_SHARED]) AC_REQUIRE([DUNE_LINKCXX]) @@ -78,7 +80,7 @@ AC_DEFUN([DUNE_COMMON_CHECKS], AC_DEFUN([DUNE_COMMON_CHECK_MODULE], [ DUNE_CHECK_MODULES([dune-common], [common/stdstreams.hh], - [#ifndef DUNE_MINIMAL_DEBUG_LEVEL + [#ifndef DUNE_MINIMAL_DEBUG_LEVEL #define DUNE_MINIMAL_DEBUG_LEVEL 1 #endif Dune::derr.active();]) diff --git a/m4/immdx_lib_metis.m4 b/m4/immdx_lib_metis.m4 index 25cef83d0b1de1f2d7676b9285011f8b380798d0..91f2863c8c0de3701e6085d4ccb81fdcaf7eb17f 100644 --- a/m4/immdx_lib_metis.m4 +++ b/m4/immdx_lib_metis.m4 @@ -48,7 +48,7 @@ AC_DEFUN([IMMDX_LIB_METIS], [ else with_metis=/usr if test ! -f "$with_metis/include/metis.h" ; then - if test ! -f "$with_metis/include/metis/metis.h" ; then + if test ! -f "$with_metis/include/metis/metis.h" ; then with_metis=/usr/local if test ! -f "$with_metis/include/metis.h" ; then with_metis="" @@ -56,7 +56,7 @@ AC_DEFUN([IMMDX_LIB_METIS], [ else AC_MSG_RESULT(yes) fi - fi + fi AC_MSG_RESULT(yes) else AC_MSG_RESULT(yes) @@ -91,9 +91,9 @@ AC_DEFUN([IMMDX_LIB_METIS], [ AC_LANG_SAVE AC_LANG_C - AC_CHECK_LIB(metis, METIS_PartMeshDual, + AC_CHECK_LIB(metis, METIS_PartGraphKway, [metis_lib=yes], [metis_lib=no], [-lm]) - + AC_CHECK_HEADER(metis.h, [metis_h=yes], [metis_h=no], [/* check */]) @@ -117,7 +117,7 @@ AC_DEFUN([IMMDX_LIB_METIS], [ # # # - + # tell automake AM_CONDITIONAL(METIS, test x$METIS_LIB = x1) if test x = x"$METIS_LIB" ; then diff --git a/m4/parmetis.m4 b/m4/parmetis.m4 index 8e8ae242f553e7feac1de207bf3544ad9d4c7ea1..cfba2eb90f71f1cde195ae7fb49050c29096b101 100644 --- a/m4/parmetis.m4 +++ b/m4/parmetis.m4 @@ -4,67 +4,58 @@ dnl vi: set et ts=8 sw=2 sts=2: # searches for ParMetis headers and libs AC_DEFUN([DUNE_PATH_PARMETIS],[ - AC_MSG_CHECKING(for ParMETIS library) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PATH_XTRA]) AC_REQUIRE([DUNE_MPI]) + # default locations + PARMETIS_DEFAULT="/usr /usr/local" + INCLUDE_DEFAULT="include include/parmetis" + # - # USer hints ... + # User hints ... # AC_ARG_VAR([PARMETIS], [ParMETIS library location]) AC_ARG_WITH([parmetis], [AC_HELP_STRING([--with-parmetis],[user defined path to ParMETIS library])], [ # --with-parmetis supersedes $PARMETIS - PARMETIS="" - if test "$withval" != no ; then - if test -d "$withval" ; then - # get absolute path - with_parmetis=`eval cd $withval 2>&1 && pwd` - if test -f "$with_parmetis/include/parmetis.h" ; then - lib_path=lib - include_path=include - fi - AC_MSG_RESULT(yes) - else - with_parmetis="no" - AC_MSG_RESULT(no) + PARMETIS="$withval" + ]) + # set PARMETIS to the usual locations, in case it is not defined + if test -n "$PARMETIS" ; then PARMETIS_DEFAULT=""; fi + with_parmetis="" + include_path="" + lib_path="" + # check for parmtirs include path + for p in "$PARMETIS" $PARMETIS_DEFAULT; do + for i in $INCLUDE_DEFAULT; do +# AC_MSG_NOTICE( ... checking for $p/$i ) + if test -f $p/$i/parmetis.h ; then +# AC_MSG_NOTICE( ... found $p/$i/parmetis.h ) + with_parmetis="$p" + include_path="$i" + lib_path=lib + break 2; fi - else - AC_MSG_RESULT(no) - fi - ], - [ - #echo with_parmetis1=$withparmetis PARMETIS=$PARMETIS - if test -n "$PARMETIS" ; then - if test -d "$PARMETIS" ; then - # get absolute path - with_parmetis=`eval cd $PARMETIS 2>&1 && pwd` - PARMETIS="" - AC_MSG_RESULT(yes) - else - PARMETIS="" - with_parmetis=no - AC_MSG_RESULT(no) - fi - else - with_parmetis=/usr/ - include_path=include - lib_path=lib - if test ! -f "$with_parmetis/$include_path/parmetis.h" ; then - with_parmetis=/usr/local/ - if test ! -f "$with_metis/$include_path/parmetis.h" ; then - with_parmetis="no" - AC_MSG_RESULT(failed) - else - AC_MSG_RESULT(yes) - fi - else - AC_MSG_RESULT(yes) - fi - fi - ]) + done + done + # report test result + if test -n "$with_parmetis" ; then + # defaultpath + PARMETIS_LIB_PATH="$with_parmetis/$lib_path" + PARMETIS_INCLUDE_PATH="$with_parmetis/$include_path" + + AC_MSG_RESULT(yes) + else + if test -n "$PARMETIS" ; then + AC_MSG_ERROR(no) + else + AC_MSG_RESULT(no) + fi + fi + + AC_MSG_NOTICE( PARMETIS: checking for $p/$i ) AC_ARG_WITH([parmetis-lib], [AC_HELP_STRING([--with-parmetis-lib], [name of the parmetis libraries (default is parmetis)])], ,[with_parmetis_lib=parmetis]) @@ -77,19 +68,15 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[ ac_save_LDFLAGS="$LDFLAGS" ac_save_CPPFLAGS="$CPPFLAGS" ac_save_LIBS="$LIBS" - + # call IMDX_LIB_METIS directly and not via AC_REQUIRE # because AC_REQUIRE support not allow parameters # without any parameters a missing METIS would halt configure IMMDX_LIB_METIS(,[true]) - + ## do nothing if --without-parmetis is used if test x"$with_mpi" != x"no" && test x"$with_parmetis" != x"no" ; then - # defaultpath - PARMETIS_LIB_PATH="$with_parmetis/$lib_path" - PARMETIS_INCLUDE_PATH="$with_parmetis/$include_path" - PARMETIS_LIBS="-L$PARMETIS_LIB_PATH -l$with_metis_lib $DUNEMPILIBS -lm" PARMETIS_LDFLAGS="$DUNEMPILDFLAGS" @@ -107,11 +94,11 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[ PARMETIS_CPPFLAGS="${DUNEMPICPPFLAGS} ${PARMETIS_CPPFLAGS} -DENABLE_PARMETIS=1" # AC_LANG_PUSH([C++]) - + # if header is found check for the libs LIBS="$DUNEMPILIBS -lm $LIBS" - + if test x$HAVE_PARMETIS = x1 ; then DUNE_CHECK_LIB_EXT([$PARMETIS_LIB_PATH], [$with_metis_lib], [metis_partgraphkway], [ @@ -134,10 +121,10 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[ fi # AC_LANG_POP([C++]) - + # pre-set variable for summary #with_parmetis="no" - + # did it work? AC_MSG_CHECKING(ParMETIS in $with_parmetis) if test x$HAVE_PARMETIS = x1 ; then @@ -145,7 +132,7 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[ AC_SUBST(PARMETIS_LDFLAGS, $PARMETIS_LDFLAGS) AC_SUBST(PARMETIS_CPPFLAGS, $PARMETIS_CPPFLAGS) AC_DEFINE(HAVE_PARMETIS,ENABLE_PARMETIS,[Define if you have the Parmetis library. - This is only true if MPI was found by configure + This is only true if MPI was found by configure _and_ if the application uses the PARMETIS_CPPFLAGS]) AC_MSG_RESULT(ok) @@ -156,23 +143,26 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[ # re-set variable correctly with_parmetis="yes" else + AC_SUBST(PARMETIS_LIBS, "") + AC_SUBST(PARMETIS_LDFLAGS, "") + AC_SUBST(PARMETIS_CPPFLAGS, "") with_parmetis="no" AC_MSG_RESULT(failed) - fi - + fi + # end of "no --without-parmetis" else with_parmetis="no" fi - - # tell automake + + # tell automake AM_CONDITIONAL(PARMETIS, test x$HAVE_PARMETIS = x1) - + # restore variables LDFLAGS="$ac_save_LDFLAGS" CPPFLAGS="$ac_save_CPPFLAGS" LIBS="$ac_save_LIBS" - + DUNE_ADD_SUMMARY_ENTRY([ParMETIS],[$with_parmetis]) ]) diff --git a/m4/umfpack.m4 b/m4/umfpack.m4 new file mode 100644 index 0000000000000000000000000000000000000000..189b04a7a369bd712a289e3e22ac7268f60a5248 --- /dev/null +++ b/m4/umfpack.m4 @@ -0,0 +1,141 @@ +# courtesy of the dune-fem maintainers + +AC_DEFUN([DUNE_PATH_UMFPACK],[ + AC_REQUIRE([AC_PROG_CC]) + + AC_ARG_WITH(umfpack, + AC_HELP_STRING([--with-umfpack=PATH],[directory with UMFPACK inside])) + AC_ARG_WITH(umfpack-includedir, + AC_HELP_STRING([--with-umfpack-includedir=PATH],[directory with UMFPACK headers inside])) + AC_ARG_WITH(umfpack-libdir, + AC_HELP_STRING([--with-umfpack-libdir=PATH],[directory with UMFPACK libraries inside])) + +# store old values +ac_save_LDFLAGS="$LDFLAGS" +ac_save_CPPFLAGS="$CPPFLAGS" +ac_save_LIBS="$LIBS" + +UMFPACKYES=0 +## do nothing if no --with-umfpack was supplied +if test x$with_umfpack != x && test x$with_umfpack != xno ; then + UMFPACKYES=1 +fi +if test x$with_umfpack_includedir != x && test x$with_umfpack_includedir != xno ; then + UMFPACKYES=1 +fi +if test x$with_umfpack_libdir != x && test x$with_umfpack_libdir != xno ; then + UMFPACKYES=1 +fi + +if test x$UMFPACKYES = x1 ; then + + # is --with-umfpack=bla used? + if test "x$with_umfpack" != x ; then + UMFPACKROOT=`cd $with_umfpack && pwd` + if ! test -d $UMFPACKROOT; then + AC_MSG_WARN([UMFPACK directory $with_umfpack does not exist]) + fi + + if test "x$UMFPACKROOT" = x; then + # use some default value... + UMFPACKROOT="/usr/local/umfpack" + fi + + UMFAMD_LIB_PATH="$UMFPACKROOT/AMD/Lib" + UMFPACK_LIB_PATH="$UMFPACKROOT/UMFPACK/Lib" + UMFPACK_INCLUDE_PATH="$UMFPACKROOT/UMFPACK/Include" + else + if test "x$with_umfpack_includedir" != x ; then + UMFPACK_INCLUDE_PATH=`cd $with_umfpack_includedir && pwd` + if ! test -d $UMFPACK_INCLUDE_PATH; then + AC_MSG_WARN([UMFPACK directory $with_umfpack_includedir does not exist]) + fi + fi + if test "x$with_umfpack_libdir" != x ; then + UMFPACK_LIB_PATH=`cd $with_umfpack_libdir && pwd` + if ! test -d $UMFPACK_LIB_PATH; then + AC_MSG_WARN([UMFPACK directory $with_umfpack_libdir does not exist]) + fi + fi + UMFAMD_LIB_PATH=$UMFPACK_LIB_PATH + fi + + # set variables so that tests can use them + REM_CPPFLAGS=$CPPFLAGS + + LDFLAGS="$LDFLAGS -L$UMFPACK_LIB_PATH -L$UMFAMD_LIB_PATH" + UMFPACK_INC_FLAG="-I$UMFPACK_INCLUDE_PATH -I$UMFPACKROOT/UFconfig -I$UMFPACKROOT/AMD/Include -I$UMFPACKROOT/SuiteSparse_config -DENABLE_UMFPACK=1" + CPPFLAGS="$CPPFLAGS $UMFPACK_INC_FLAG $MPI_CPPFLAGS" + + # check for header + AC_LANG_PUSH([C]) + AC_CHECK_HEADERS([umfpack.h], + [UMFPACK_CPPFLAGS="$UMFPACK_INC_FLAG" + HAVE_UMFPACK="1"], + AC_MSG_WARN([umfpack.h not found in $UMFPACK_INCLUDE_PATH])) + + CPPFLAGS="$REM_CPPFLAGS" + REM_CPPFLAGS= + + REM_LDFLAGS=$LDFLAGS + + # if header is found... + if test x$HAVE_UMFPACK = x1 ; then + AC_CHECK_LIB(umfpack,[main], + [UMFPACK_LIBS="-lumfpack" + UMFPACK_LDFLAGS="-L$UMFPACK_LIB_PATH"], + [HAVE_UMFPACK="0" + AC_MSG_WARN(libumfpack not found!)]) + fi + + # if lib is found... + if test x$HAVE_UMFPACK = x1 ; then + AC_CHECK_LIB(amd,[main], + [UMFPACK_LIBS="$UMFPACK_LIBS -lamd" + UMFPACK_LDFLAGS="$UMFPACK_LDFLAGS -L$UMFAMD_LIB_PATH" + LIBS="$LIBS $UMFPACK_LIBS"], + [HAVE_UMFPACK="0" + AC_MSG_WARN(libamd not found!)]) + fi + + LDFLAGS=$REM_LDFLAGS + AC_LANG_POP + +## end of umfpack check (--without wasn't set) +fi + +# survived all tests? +if test x$HAVE_UMFPACK = x1 ; then + AC_SUBST(UMFPACK_LIBS, $UMFPACK_LIBS) + AC_SUBST(UMFPACK_LDFLAGS, $UMFPACK_LDFLAGS) + AC_SUBST(UMFPACK_CPPFLAGS, $UMFPACK_CPPFLAGS) + AC_DEFINE(HAVE_UMFPACK, ENABLE_UMFPACK, + [This is only true if umfpack-library was found by configure + _and_ if the application uses the UMFPACK_CPPFLAGS]) + + # add to global list + DUNE_ADD_ALL_PKG([UMFPACK], [\${UMFPACK_CPPFLAGS}], + [\${UMFPACK_LDFLAGS}], [\${UMFPACK_LIBS}]) + + # set variable for summary + with_umfpack="yes" + +else + AC_SUBST(UMFPACK_LIBS, "") + AC_SUBST(UMFPACK_LDFLAGS, "") + AC_SUBST(UMFPACK_CPPFLAGS, "") + + # set variable for summary + with_umfpack="no" +fi + +# also tell automake +AM_CONDITIONAL(UMFPACK, test x$HAVE_UMFPACK = x1) + +# reset old values +LIBS="$ac_save_LIBS" +CPPFLAGS="$ac_save_CPPFLAGS" +LDFLAGS="$ac_save_LDFLAGS" + + DUNE_ADD_SUMMARY_ENTRY([UMFPACK],[$with_umfpack]) +])