#1468 DUNE_DEFINE_GRIDTYPE from dune-grid conflicts with that from dune-alugrid module
Metadata
Property | Value |
---|---|
Reported by | Claus-Justus Heine (claus-justus.heine@ians.uni-stuttgart.de) |
Reported at | May 22, 2014 16:04 |
Type | Bug Report |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Robert K (robertk@posteo.org) |
Last edited at | Jul 21, 2015 10:53 |
Closed by | Robert K (robertk@posteo.org) |
Closed at | Jul 21, 2015 10:53 |
Closed in version | Unknown |
Resolution | Fixed |
Comment | The dune-alugrid module defined gridtypes are now guarded by an extra |
#if ! HAVE_ALUGRID | |
... | |
#endif |
Description
Hi,
there is a problem with the GNU autotools build system when trying to use the separate dune-alugrid module. The problem is that both, dune-grid and dune-alugrid, issue the DUNE_DEFINE_GRIDTYPE() macro with the same parameters, and this results in emitting conflicting definitions for dune-alugrid into the config.h.in template. The point is that DUNE_DEFINE_GRIDTYPE() "calls" AH_BOTTOM(). Now AH_BOTTOM([STUFF]) is a m4-macro which finally results into pasting STUFF into config.h.in. The problem with this is that AH_BOTTOM() is executed even when surrounded by a (not-so-) protecting shell "if". This means that line 197 in dune-grid/m4/alugrid.m4
if test x$HAVE_ALUGRID = x1 ; then ....
does not prevent the AH_BOTTOM stuff to be executed (cannot, as AH_... macros are read by autoheader, while the shell-script "if" is only examined when the user finally runs the configure script). Also, there does not seem to be a guarantee by autoconf in which particular order AH_BOTTOM() takes action. In my first two of the three grid-types from dune-alugrid are "AH_BOTTOMed", then come the three from dune-grid, finally comes the third from dune-alugrid.
A possible workaround could be to optionally allow for an additional "disable" preprocessor construct which would result in something like this in the config.h file:
#if HAVE_DUNE_GRID && HAVE_ALUGRID == 1 && all the other stuff .... #endif
A patch is attached. Not overly pretty, but might work. It introduces a new m4-macro
DUNE_DEFINE_GRIDTYPE_IF([GRIDTYPE],[CONDITION],[ASSERTION],[DUNETYPE],[HEADER],...)
where CONDITION is e.g. HAVE_ALUGRID == 1. Arguably, one could also alter the DUNE_DEFINE_GRIDTYPE() calls in the dune-alugrid module. But then code using either ALUGrid or the dune-alugrid module would have to consider different grid-type preprocessor symbols.