From edb5f6e614776000b1746344f0f450d8b18f9898 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Thu, 27 Feb 2014 21:51:39 +0000
Subject: [PATCH] Regenerate build system using duneproject

This takes care of shipping cmake files, installing documentation
properly, etc.

[[Imported from SVN: r12963]]
---
 CMakeLists.txt                             | 21 +++++++---
 Makefile.am                                | 17 +++++---
 README                                     |  6 +--
 cmake/Makefile.am                          |  3 ++
 cmake/modules/CMakeLists.txt               |  3 ++
 cmake/modules/DuneSolversMacros.cmake      |  1 +
 cmake/modules/Makefile.am                  |  6 +++
 config.h.cmake                             | 45 ++++++++++++++++++++++
 configure.ac                               | 12 ++++--
 doc/CMakeLists.txt                         |  4 +-
 doc/Makefile.am                            |  7 +++-
 doc/doxygen/Doxylocal                      | 38 ++++++++++++++----
 doc/doxygen/Makefile.am                    | 15 +-------
 dune-solvers.pc.in                         |  4 +-
 dune/CMakeLists.txt                        |  2 +-
 dune/Makefile.am                           |  4 +-
 dune/solvers/Makefile.am                   |  2 +
 dune/solvers/common/Makefile.am            |  2 +
 dune/solvers/iterationsteps/Makefile.am    |  2 +
 dune/solvers/norms/Makefile.am             |  2 +
 dune/solvers/operators/Makefile.am         |  2 +
 dune/solvers/solvers/Makefile.am           |  2 +
 dune/solvers/transferoperators/Makefile.am |  2 +
 m4/CMakeLists.txt                          |  8 ++--
 m4/Makefile.am                             |  2 +-
 m4/dune-solvers.m4                         | 18 +++++++--
 26 files changed, 174 insertions(+), 56 deletions(-)
 create mode 100644 cmake/Makefile.am
 create mode 100644 cmake/modules/CMakeLists.txt
 create mode 100644 cmake/modules/DuneSolversMacros.cmake
 create mode 100644 cmake/modules/Makefile.am
 create mode 100644 config.h.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index db9b193..7ae77a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,18 +1,27 @@
-project("dune-solvers" CXX)
 cmake_minimum_required(VERSION 2.8.6)
+project(dune-solvers CXX)
 
-if(NOT (dune-common_DIR OR dune-common_ROOT))
-  string(REPLACE ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR ${PROJECT_BINARY_DIR})
+if(NOT (dune-common_DIR OR dune-common_ROOT OR
+      "${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
+    string(REPLACE  ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR
+      ${PROJECT_BINARY_DIR})
 endif()
 
+#find dune-common and set the module path
 find_package(dune-common REQUIRED)
-list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH})
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules"
+  ${dune-common_MODULE_PATH})
+
+#include the dune macros
 include(DuneMacros)
 
+# start a dune project with information from dune.module
 dune_project()
 
-add_subdirectory("doc")
-add_subdirectory("dune")
 add_subdirectory("m4")
+add_subdirectory("dune")
+add_subdirectory("doc")
+add_subdirectory("cmake/modules")
 
+# finalize the dune project, e.g. generating config.h etc.
 finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
diff --git a/Makefile.am b/Makefile.am
index 17c3a97..6429c75 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,17 +1,19 @@
-# $Id: duneproject 5500 2009-04-03 13:45:04Z sander $
+# $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
 
-SUBDIRS = m4 dune
+SUBDIRS = m4 dune doc cmake
 
 if BUILD_DOCS
 SUBDIRS += doc
 endif
 
 # don't follow the full GNU-standard
-# we need automake 1.5
-AUTOMAKE_OPTIONS = foreign 1.5
+# we need automake 1.9 or newer
+AUTOMAKE_OPTIONS = foreign 1.9
 
 # pass most important options when "make distcheck" is used
 # dune-geometry is a dependency of dune-grid.
@@ -19,3 +21,8 @@ DISTCHECK_CONFIGURE_FLAGS = --with-dune-common=$(DUNE_COMMON_ROOT) --with-dune-g
 
 include $(top_srcdir)/am/top-rules
 include $(top_srcdir)/am/global-rules
+
+# Generate package configuration files for finding
+# installed modules with CMake
+include $(top_srcdir)/am/cmake-pkg-config
+
diff --git a/README b/README
index 8edb463..7ea5ff0 100644
--- a/README
+++ b/README
@@ -4,9 +4,9 @@ Preparing the Sources
 Additional to the software mentioned in README you'll need the
 following programs installed on your system:
 
-  automake >= 1.5
+  automake >= 1.9
 
-  autoconf >= 2.50
+  autoconf >= 2.62
 
   libtool
 
@@ -69,5 +69,5 @@ for further options.
 
 The full build-system is described in the dune-common/doc/buildsystem (SVN version) or under share/doc/dune-common/buildsystem if you installed DUNE!
 
-$Id: duneproject 5500 2009-04-03 13:45:04Z sander $
+$Id$
 
diff --git a/cmake/Makefile.am b/cmake/Makefile.am
new file mode 100644
index 0000000..26735eb
--- /dev/null
+++ b/cmake/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = modules
+
+include $(top_srcdir)/am/global-rules
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
new file mode 100644
index 0000000..0aba9c3
--- /dev/null
+++ b/cmake/modules/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(modules "DuneSolversMacros.cmake")
+
+install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
diff --git a/cmake/modules/DuneSolversMacros.cmake b/cmake/modules/DuneSolversMacros.cmake
new file mode 100644
index 0000000..613dfb6
--- /dev/null
+++ b/cmake/modules/DuneSolversMacros.cmake
@@ -0,0 +1 @@
+# File for module specific CMake tests.
diff --git a/cmake/modules/Makefile.am b/cmake/modules/Makefile.am
new file mode 100644
index 0000000..f9d2b9a
--- /dev/null
+++ b/cmake/modules/Makefile.am
@@ -0,0 +1,6 @@
+MODULES = DuneSolversMacros.cmake
+modulesdir = $(datadir)/dune/cmake/modules
+dist_modules_DATA = ${MODULES}
+
+include $(top_srcdir)/am/global-rules
+EXTRA_DIST = CMakeLists.txt
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..6fc20f0
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,45 @@
+/* begin solvers
+   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 dune-solvers */
+#define DUNE_SOLVERS_VERSION "@DUNE_SOLVERS_VERSION@"
+
+/* Define to the major version of dune-solvers */
+#define DUNE_SOLVERS_VERSION_MAJOR @DUNE_SOLVERS_VERSION_MAJOR@
+
+/* Define to the minor version of dune-solvers */
+#define DUNE_SOLVERS_VERSION_MINOR @DUNE_SOLVERS_VERSION_MINOR@
+
+/* Define to the revision of dune-solvers */
+#define DUNE_SOLVERS_VERSION_REVISION @DUNE_SOLVERS_VERSION_REVISION@
+
+/* end solvers
+   Everything below here will be overwritten
+*/
diff --git a/configure.ac b/configure.ac
index d316432..65e70c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,13 +1,15 @@
 # -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.50)
+AC_PREREQ([2.62])
 DUNE_AC_INIT # gets module version from dune.module file
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([dune-solvers.pc.in])
 AC_CONFIG_HEADERS([config.h])
 
 
-# Run all checks
+# we need no more than the standard DE-stuff
+# this module depends on dune-common dune-grid dune-istl dune-localfunctions
+# this implies checking for [dune-common], [dune-geometry], [dune-grid], [dune-istl], [dune-localfunctions]
 DUNE_CHECK_ALL
 
 # implicitly set the Dune-flags everywhere
@@ -17,6 +19,10 @@ LIBS="$DUNE_LIBS"
 
 AC_CONFIG_FILES([
   Makefile
+  cmake/Makefile
+  cmake/modules/Makefile
+  doc/Makefile
+  doc/doxygen/Makefile
   doc/doxygen/Doxyfile
   dune/Makefile
   dune/solvers/Makefile
@@ -27,8 +33,6 @@ AC_CONFIG_FILES([
   dune/solvers/solvers/Makefile
   dune/solvers/test/Makefile
   dune/solvers/transferoperators/Makefile
-  doc/Makefile
-  doc/doxygen/Makefile
   m4/Makefile
   dune-solvers.pc
 ])
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 4282985..80f4b3b 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1 +1,3 @@
-add_subdirectory(doxygen)
+add_subdirectory("doxygen")
+
+install(FILES LOWRANKBRANCH-BACKPORT-CHANGES ${CMAKE_INSTALL_DOCDIR})
\ No newline at end of file
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 12455f0..3e9b469 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -3,9 +3,12 @@ SUBDIRS = doxygen
 CURDIR = doc
 BASEDIR = ..
 
-docdir=$(datadir)/doc/dune/solvers
+# add list of html files to generate from wml
+PAGES=
 
-EXTRA_DIST = CMakeLists.txt
+docdir=$(datadir)/doc/dune-solvers
+
+EXTRA_DIST = CMakeLists.txt LOWRANKBRANCH-BACKPORT-CHANGES
 
 include $(top_srcdir)/am/webstuff
 include $(top_srcdir)/am/global-rules
diff --git a/doc/doxygen/Doxylocal b/doc/doxygen/Doxylocal
index 4b763b3..227177b 100644
--- a/doc/doxygen/Doxylocal
+++ b/doc/doxygen/Doxylocal
@@ -1,8 +1,30 @@
-INPUT                  += @top_srcdir@/dune/solvers
-EXCLUDE                += 
-EXAMPLE_PATH           +=
-EXAMPLE_PATTERNS       +=
-IMAGE_PATH             +=
-PREDEFINED             += DOXYGEN 
-
-EXTRA_PACKAGES         = amsmath amssymb
+# This file contains local changes to the doxygen configuration
+# please us '+=' to add file/directories to the lists
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT                 += @top_srcdir@/dune/
+# see e.g. dune-grid for the examples of mainpage and modules
+# INPUT                 += @srcdir@/mainpage #                          @srcdir@/modules
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+# EXCLUDE               += @top_srcdir@/dune/solvers/test
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+# EXAMPLE_PATH          += @top_srcdir@/src
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+# IMAGE_PATH            += @top_srcdir@/dune/solvers/pics
+
diff --git a/doc/doxygen/Makefile.am b/doc/doxygen/Makefile.am
index f3d8041..a4917f4 100644
--- a/doc/doxygen/Makefile.am
+++ b/doc/doxygen/Makefile.am
@@ -1,22 +1,9 @@
 
 BASEDIR=../..
 CURDIR=doc/doxygen
-WHAT=
 
-doxygendir = $(datadir)/doc/dune/solvers/doxygen
-doxygen_DATA = $(WHAT)
-
-#we need this in the distribution
-EXTRA_DIST = $(WHAT) $(DOXYGENDISTFILES)
-
-all: $(WHAT) $(DOXYGENFILES)
+EXTRA_DIST = CMakeLists.txt
 
 include $(top_srcdir)/am/doxygen
 include $(top_srcdir)/am/global-rules
 
-# file to clean only in svn and not in tarball tree
-SVNCLEANFILES = html $(WHAT) $(DOXYGENHEADER)
-
-clean-local:
-	if test "x$(VPATH)" != "x" && test ! -e $(srcdir)/doxygen-tag; then 	  if test -e $(top_srcdir)/doc/doxygen/Doxydep; then 	    rm -rf $(SVNCLEANFILES); 	  fi; 	fi
-
diff --git a/dune-solvers.pc.in b/dune-solvers.pc.in
index d0fff91..e67abba 100644
--- a/dune-solvers.pc.in
+++ b/dune-solvers.pc.in
@@ -11,5 +11,5 @@ Version: @VERSION@
 Description: dune-solvers module
 URL: http://dune-project.org/
 Requires: dune-common dune-grid dune-istl
-Libs: -L
-Cflags: -I
+Libs: -L${libdir}
+Cflags: -I${includedir}
diff --git a/dune/CMakeLists.txt b/dune/CMakeLists.txt
index f62b260..d9733c6 100644
--- a/dune/CMakeLists.txt
+++ b/dune/CMakeLists.txt
@@ -1 +1 @@
-add_subdirectory("solvers")
+add_subdirectory(solvers)
diff --git a/dune/Makefile.am b/dune/Makefile.am
index 6d4b6b1..b5abf08 100644
--- a/dune/Makefile.am
+++ b/dune/Makefile.am
@@ -1,5 +1,5 @@
-# $Id: $
-
 SUBDIRS = solvers
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/Makefile.am b/dune/solvers/Makefile.am
index 3ae1ab1..3d0a893 100644
--- a/dune/solvers/Makefile.am
+++ b/dune/solvers/Makefile.am
@@ -4,4 +4,6 @@ SUBDIRS = common iterationsteps norms operators solvers test transferoperators
 dune_solversdir = $(includedir)/dune/solvers
 dune_solvers_HEADERS = computeenergy.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/common/Makefile.am b/dune/solvers/common/Makefile.am
index 7abdcc5..14bd9a2 100644
--- a/dune/solvers/common/Makefile.am
+++ b/dune/solvers/common/Makefile.am
@@ -11,4 +11,6 @@ common_HEADERS = arithmetic.hh \
                  preconditioner.hh \
                  staticmatrixtools.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/iterationsteps/Makefile.am b/dune/solvers/iterationsteps/Makefile.am
index 050ac67..0b3b1c2 100644
--- a/dune/solvers/iterationsteps/Makefile.am
+++ b/dune/solvers/iterationsteps/Makefile.am
@@ -24,4 +24,6 @@ iterationsteps_HEADERS = amgstep.hh \
                          trustregiongsstep.cc \
                          trustregiongsstep.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/norms/Makefile.am b/dune/solvers/norms/Makefile.am
index cd74e77..0a28797 100644
--- a/dune/solvers/norms/Makefile.am
+++ b/dune/solvers/norms/Makefile.am
@@ -4,4 +4,6 @@ normsdir = $(includedir)/dune/solvers/norms
 norms_HEADERS = blocknorm.hh  diagnorm.hh  energynorm.hh  fullnorm.hh  h1seminorm.hh \
                 norm.hh  pnorm.hh  sumnorm.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
\ No newline at end of file
diff --git a/dune/solvers/operators/Makefile.am b/dune/solvers/operators/Makefile.am
index e1c13db..10ece4a 100644
--- a/dune/solvers/operators/Makefile.am
+++ b/dune/solvers/operators/Makefile.am
@@ -5,4 +5,6 @@ operators_HEADERS = lowrankoperator.hh \
                     nulloperator.hh \
                     sumoperator.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/solvers/Makefile.am b/dune/solvers/solvers/Makefile.am
index 798340a..fd48820 100644
--- a/dune/solvers/solvers/Makefile.am
+++ b/dune/solvers/solvers/Makefile.am
@@ -5,4 +5,6 @@ solvers_HEADERS = cgsolver.cc cgsolver.hh iterativesolver.cc iterativesolver.hh
                   loopsolver.cc loopsolver.hh quadraticipopt.hh solver.hh \
                   tcgsolver.cc tcgsolver.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
\ No newline at end of file
diff --git a/dune/solvers/transferoperators/Makefile.am b/dune/solvers/transferoperators/Makefile.am
index d5394ca..47e9926 100644
--- a/dune/solvers/transferoperators/Makefile.am
+++ b/dune/solvers/transferoperators/Makefile.am
@@ -7,4 +7,6 @@ transferoperators_HEADERS = compressedmultigridtransfer.hh multigridtransfer.hh
                 genericmultigridtransfer.hh mandelobsrestrictor.hh truncatedcompressedmgtransfer.cc \
                 truncateddensemgtransfer.hh
 
+EXTRA_DIST = CMakeLists.txt
+
 include $(top_srcdir)/am/global-rules
\ No newline at end of file
diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt
index 2c84197..ab4832e 100644
--- a/m4/CMakeLists.txt
+++ b/m4/CMakeLists.txt
@@ -1,4 +1,6 @@
+
 install(FILES
-    dune-solvers.m4
-    ipopt.m4
-    DESTINATION share/dune/aclocal)
+  dune-solvers.m4
+  ipopt.m4
+  DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dune/aclocal)
+
diff --git a/m4/Makefile.am b/m4/Makefile.am
index d861134..725c62c 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -3,6 +3,6 @@ M4FILES = dune-solvers.m4 ipopt.m4
 aclocaldir = $(datadir)/dune/aclocal
 aclocal_DATA = $(M4FILES)
 
-EXTRA_DIST = $(M4FILES)
+EXTRA_DIST = $(M4FILES) CMakeLists.txt
 
 include $(top_srcdir)/am/global-rules
diff --git a/m4/dune-solvers.m4 b/m4/dune-solvers.m4
index 7ac5399..22ef1d4 100644
--- a/m4/dune-solvers.m4
+++ b/m4/dune-solvers.m4
@@ -1,9 +1,19 @@
-# Additional checks needed to build the module
+dnl -*- autoconf -*-
+# Macros needed to find dune-solvers and dependent libraries.  They are called by
+# the macros in ${top_src_dir}/dependencies.m4, which is generated by
+# "dunecontrol autogen"
+
+# Additional checks needed to build dune-solvers
+# This macro should be invoked by every module which depends on dune-solvers, as
+# well as by dune-solvers itself
 AC_DEFUN([DUNE_SOLVERS_CHECKS],[
   AC_REQUIRE([DUNE_IPOPT])
 ])
 
-# Additional checks needed to find the module
-AC_DEFUN([DUNE_SOLVERS_CHECK_MODULE],[
-  DUNE_CHECK_MODULES([dune-solvers], [solvers/solvers/solver.hh])
+# Additional checks needed to find dune-solvers
+# This macro should be invoked by every module which depends on dune-solvers, but
+# not by dune-solvers itself
+AC_DEFUN([DUNE_SOLVERS_CHECK_MODULE],
+[
+  DUNE_CHECK_MODULES([dune-solvers],[solvers/solvers/solver.hh])
 ])
-- 
GitLab