From ce7cf5ed726a8709e7ae2cc7f9abdd911ff4b48f Mon Sep 17 00:00:00 2001 From: Christian Engwer <christi@dune-project.org> Date: Thu, 29 Sep 2005 15:10:40 +0000 Subject: [PATCH] changed configure and headers, so that DIM and DIM_OF_WORLD are local to albertagrid. This fixes task #33. [[Imported from SVN: r2987]] --- grid/albertagrid.hh | 8 + grid/albertagrid/alberta_undefs.hh | 448 +++++++++++++++++++++++++++++ grid/albertagrid/undefAllMacros.pl | 98 +++++++ m4/alberta.m4 | 11 +- m4/dimension.m4 | 8 +- 5 files changed, 564 insertions(+), 9 deletions(-) create mode 100644 grid/albertagrid/alberta_undefs.hh create mode 100755 grid/albertagrid/undefAllMacros.pl diff --git a/grid/albertagrid.hh b/grid/albertagrid.hh index 2b0fbfff9..1256c335e 100644 --- a/grid/albertagrid.hh +++ b/grid/albertagrid.hh @@ -9,6 +9,9 @@ #include <assert.h> #include <algorithm> +#define DIM DUNE_PROBLEM_DIM +#define DIM_OF_WORLD DUNE_WORLD_DIM + // Dune includes #include <dune/common/misc.hh> #include <dune/common/interfaces.hh> @@ -1858,4 +1861,9 @@ namespace Dune #include <dune/io/file/asciiparser.hh> #include "albertagrid/albertagrid.cc" +// undef all dangerous defines +#undef DIM +#undef DIM_OF_WORLD +#include "albertagrid/alberta_undefs.hh" + #endif diff --git a/grid/albertagrid/alberta_undefs.hh b/grid/albertagrid/alberta_undefs.hh new file mode 100644 index 000000000..f111f64cf --- /dev/null +++ b/grid/albertagrid/alberta_undefs.hh @@ -0,0 +1,448 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +/** \file + * \brief Contains <tt>#undef</tt>s for all preprocessor macros + * defined by alberta. + * + * This file is created automatically by the perl script <tt>undefAllMacros.pl</tt>. + */ + +#ifdef _ALBERTA_H_ + #undef _ALBERTA_H_ +#endif // _ALBERTA_H_ + +#ifdef ALBERTA_VERSION + #undef ALBERTA_VERSION +#endif // ALBERTA_VERSION + +#ifdef NEIGH_IN_EL + #undef NEIGH_IN_EL +#endif // NEIGH_IN_EL + +#ifdef N_VERTICES_1D + #undef N_VERTICES_1D +#endif // N_VERTICES_1D + +#ifdef N_NEIGH_1D + #undef N_NEIGH_1D +#endif // N_NEIGH_1D + +#ifdef N_VERTICES + #undef N_VERTICES +#endif // N_VERTICES + +#ifdef N_NEIGH + #undef N_NEIGH +#endif // N_NEIGH + +#ifdef N_VERTICES_2D + #undef N_VERTICES_2D +#endif // N_VERTICES_2D + +#ifdef N_EDGES_2D + #undef N_EDGES_2D +#endif // N_EDGES_2D + +#ifdef N_NEIGH_2D + #undef N_NEIGH_2D +#endif // N_NEIGH_2D + +#ifdef N_VERTICES + #undef N_VERTICES +#endif // N_VERTICES + +#ifdef N_EDGES + #undef N_EDGES +#endif // N_EDGES + +#ifdef N_NEIGH + #undef N_NEIGH +#endif // N_NEIGH + +#ifdef N_VERTICES_3D + #undef N_VERTICES_3D +#endif // N_VERTICES_3D + +#ifdef N_EDGES_3D + #undef N_EDGES_3D +#endif // N_EDGES_3D + +#ifdef N_FACES_3D + #undef N_FACES_3D +#endif // N_FACES_3D + +#ifdef N_NEIGH_3D + #undef N_NEIGH_3D +#endif // N_NEIGH_3D + +#ifdef N_VERTICES + #undef N_VERTICES +#endif // N_VERTICES + +#ifdef N_EDGES + #undef N_EDGES +#endif // N_EDGES + +#ifdef N_FACES + #undef N_FACES +#endif // N_FACES + +#ifdef N_NEIGH + #undef N_NEIGH +#endif // N_NEIGH + +#ifdef COPY_DOW + #undef COPY_DOW +#endif // COPY_DOW + +#ifdef SCP_DOW + #undef SCP_DOW +#endif // SCP_DOW + +#ifdef SET_DOW + #undef SET_DOW +#endif // SET_DOW + +#ifdef SCAL_DOW + #undef SCAL_DOW +#endif // SCAL_DOW + +#ifdef DIST_DOW + #undef DIST_DOW +#endif // DIST_DOW + +#ifdef COPY_DOW + #undef COPY_DOW +#endif // COPY_DOW + +#ifdef SCP_DOW + #undef SCP_DOW +#endif // SCP_DOW + +#ifdef SET_DOW + #undef SET_DOW +#endif // SET_DOW + +#ifdef SCAL_DOW + #undef SCAL_DOW +#endif // SCAL_DOW + +#ifdef DIST_DOW + #undef DIST_DOW +#endif // DIST_DOW + +#ifdef COPY_DOW + #undef COPY_DOW +#endif // COPY_DOW + +#ifdef SCP_DOW + #undef SCP_DOW +#endif // SCP_DOW + +#ifdef SET_DOW + #undef SET_DOW +#endif // SET_DOW + +#ifdef SCAL_DOW + #undef SCAL_DOW +#endif // SCAL_DOW + +#ifdef DIST_DOW + #undef DIST_DOW +#endif // DIST_DOW + +#ifdef NORM_DOW + #undef NORM_DOW +#endif // NORM_DOW + +#ifdef NEIGH + #undef NEIGH +#endif // NEIGH + +#ifdef OPP_VERTEX + #undef OPP_VERTEX +#endif // OPP_VERTEX + +#ifdef EL_TYPE + #undef EL_TYPE +#endif // EL_TYPE + +#ifdef NEIGH + #undef NEIGH +#endif // NEIGH + +#ifdef OPP_VERTEX + #undef OPP_VERTEX +#endif // OPP_VERTEX + +#ifdef EL_TYPE + #undef EL_TYPE +#endif // EL_TYPE + +#ifdef INDEX + #undef INDEX +#endif // INDEX + +#ifdef INDEX + #undef INDEX +#endif // INDEX + +#ifdef IS_LEAF_EL + #undef IS_LEAF_EL +#endif // IS_LEAF_EL + +#ifdef LEAF_DATA + #undef LEAF_DATA +#endif // LEAF_DATA + +#ifdef INTERIOR + #undef INTERIOR +#endif // INTERIOR + +#ifdef DIRICHLET + #undef DIRICHLET +#endif // DIRICHLET + +#ifdef NEUMANN + #undef NEUMANN +#endif // NEUMANN + +#ifdef VERTEX + #undef VERTEX +#endif // VERTEX + +#ifdef CENTER + #undef CENTER +#endif // CENTER + +#ifdef VERTEX + #undef VERTEX +#endif // VERTEX + +#ifdef EDGE + #undef EDGE +#endif // EDGE + +#ifdef CENTER + #undef CENTER +#endif // CENTER + +#ifdef VERTEX + #undef VERTEX +#endif // VERTEX + +#ifdef EDGE + #undef EDGE +#endif // EDGE + +#ifdef FACE + #undef FACE +#endif // FACE + +#ifdef CENTER + #undef CENTER +#endif // CENTER + +#ifdef IS_INTERIOR + #undef IS_INTERIOR +#endif // IS_INTERIOR + +#ifdef IS_DIRICHLET + #undef IS_DIRICHLET +#endif // IS_DIRICHLET + +#ifdef IS_NEUMANN + #undef IS_NEUMANN +#endif // IS_NEUMANN + +#ifdef GET_BOUND + #undef GET_BOUND +#endif // GET_BOUND + +#ifdef FILL_NOTHING + #undef FILL_NOTHING +#endif // FILL_NOTHING + +#ifdef FILL_COORDS + #undef FILL_COORDS +#endif // FILL_COORDS + +#ifdef FILL_BOUND + #undef FILL_BOUND +#endif // FILL_BOUND + +#ifdef FILL_NEIGH + #undef FILL_NEIGH +#endif // FILL_NEIGH + +#ifdef FILL_OPP_COORDS + #undef FILL_OPP_COORDS +#endif // FILL_OPP_COORDS + +#ifdef FILL_ORIENTATION + #undef FILL_ORIENTATION +#endif // FILL_ORIENTATION + +#ifdef FILL_EL_TYPE + #undef FILL_EL_TYPE +#endif // FILL_EL_TYPE + +#ifdef FILL_ANY_2D + #undef FILL_ANY_2D +#endif // FILL_ANY_2D + +#ifdef FILL_ANY + #undef FILL_ANY +#endif // FILL_ANY + +#ifdef FILL_ANY_3D + #undef FILL_ANY_3D +#endif // FILL_ANY_3D + +#ifdef FILL_ANY + #undef FILL_ANY +#endif // FILL_ANY + +#ifdef CALL_EVERY_EL_PREORDER + #undef CALL_EVERY_EL_PREORDER +#endif // CALL_EVERY_EL_PREORDER + +#ifdef CALL_EVERY_EL_INORDER + #undef CALL_EVERY_EL_INORDER +#endif // CALL_EVERY_EL_INORDER + +#ifdef CALL_EVERY_EL_POSTORDER + #undef CALL_EVERY_EL_POSTORDER +#endif // CALL_EVERY_EL_POSTORDER + +#ifdef CALL_LEAF_EL + #undef CALL_LEAF_EL +#endif // CALL_LEAF_EL + +#ifdef CALL_LEAF_EL_LEVEL + #undef CALL_LEAF_EL_LEVEL +#endif // CALL_LEAF_EL_LEVEL + +#ifdef CALL_EL_LEVEL + #undef CALL_EL_LEVEL +#endif // CALL_EL_LEVEL + +#ifdef CALL_MG_LEVEL + #undef CALL_MG_LEVEL +#endif // CALL_MG_LEVEL + +#ifdef TEST_FLAG + #undef TEST_FLAG +#endif // TEST_FLAG + +#ifdef DOF_ADMIN_DEF + #undef DOF_ADMIN_DEF +#endif // DOF_ADMIN_DEF + +#ifdef DOF_FREE_SIZE + #undef DOF_FREE_SIZE +#endif // DOF_FREE_SIZE + +#ifdef DOF_UNIT_ALL_FREE + #undef DOF_UNIT_ALL_FREE +#endif // DOF_UNIT_ALL_FREE + +#ifdef FOR_ALL_DOFS + #undef FOR_ALL_DOFS +#endif // FOR_ALL_DOFS + +#ifdef FOR_ALL_FREE_DOFS + #undef FOR_ALL_FREE_DOFS +#endif // FOR_ALL_FREE_DOFS + +#ifdef ROW_LENGTH + #undef ROW_LENGTH +#endif // ROW_LENGTH + +#ifdef ENTRY_USED + #undef ENTRY_USED +#endif // ENTRY_USED + +#ifdef ENTRY_NOT_USED + #undef ENTRY_NOT_USED +#endif // ENTRY_NOT_USED + +#ifdef UNUSED_ENTRY + #undef UNUSED_ENTRY +#endif // UNUSED_ENTRY + +#ifdef NO_MORE_ENTRIES + #undef NO_MORE_ENTRIES +#endif // NO_MORE_ENTRIES + +#ifdef MAX_N_QUAD_POINTS + #undef MAX_N_QUAD_POINTS +#endif // MAX_N_QUAD_POINTS + +#ifdef MAX_N_QUAD_POINTS + #undef MAX_N_QUAD_POINTS +#endif // MAX_N_QUAD_POINTS + +#ifdef MAX_N_QUAD_POINTS + #undef MAX_N_QUAD_POINTS +#endif // MAX_N_QUAD_POINTS + +#ifdef INIT_PHI + #undef INIT_PHI +#endif // INIT_PHI + +#ifdef INIT_GRD_PHI + #undef INIT_GRD_PHI +#endif // INIT_GRD_PHI + +#ifdef INIT_D2_PHI + #undef INIT_D2_PHI +#endif // INIT_D2_PHI + +#ifdef MESH_REFINED + #undef MESH_REFINED +#endif // MESH_REFINED + +#ifdef MESH_COARSENED + #undef MESH_COARSENED +#endif // MESH_COARSENED + +#ifdef H1_NORM + #undef H1_NORM +#endif // H1_NORM + +#ifdef L2_NORM + #undef L2_NORM +#endif // L2_NORM + +#ifdef GRAPH_MESH_BOUNDARY + #undef GRAPH_MESH_BOUNDARY +#endif // GRAPH_MESH_BOUNDARY + +#ifdef GRAPH_MESH_ELEMENT_MARK + #undef GRAPH_MESH_ELEMENT_MARK +#endif // GRAPH_MESH_ELEMENT_MARK + +#ifdef GRAPH_MESH_VERTEX_DOF + #undef GRAPH_MESH_VERTEX_DOF +#endif // GRAPH_MESH_VERTEX_DOF + +#ifdef GRAPH_MESH_ELEMENT_INDEX + #undef GRAPH_MESH_ELEMENT_INDEX +#endif // GRAPH_MESH_ELEMENT_INDEX + +#ifdef GET_MESH + #undef GET_MESH +#endif // GET_MESH + +#ifdef GET_DOF_VEC + #undef GET_DOF_VEC +#endif // GET_DOF_VEC + +#ifdef INIT_UH + #undef INIT_UH +#endif // INIT_UH + +#ifdef INIT_GRD_UH + #undef INIT_GRD_UH +#endif // INIT_GRD_UH diff --git a/grid/albertagrid/undefAllMacros.pl b/grid/albertagrid/undefAllMacros.pl new file mode 100755 index 000000000..b25ce206c --- /dev/null +++ b/grid/albertagrid/undefAllMacros.pl @@ -0,0 +1,98 @@ +#!/usr/bin/perl -w + +use strict; + +# configuration +my $packagename = 'alberta'; +my $outfilename = $packagename."_undefs.hh"; +my $cppflagname = 'ALBERTA_CPPFLAGS'; + +# Detect location of Package +open MAKEFILE, "> Makefile.undef"; +print MAKEFILE <<END_MAKE; +include Makefile +Y: + @ for i in \$($cppflagname); do echo \$\$i; done | \\ + grep '^-I' | sed -e 's/^-I/-Y/' +END_MAKE +close MAKEFILE; +my $Yinclude = `make -f Makefile.undef Y`; +# print $Yinclude; +unlink 'Makefile.undef'; + +# Counts the total number of #undefs emitted +my $counter = 0; + +# open output file +unless (open OUTFILE, ">$outfilename") { + die "Couldn't open $outfilename for writing!\n"; +} + +# Loop over all the files given in the command line and +# recursively parse them for macro definitions. +foreach my $file (@ARGV) { + + # Write header comment + print OUTFILE "/** \\file\n"; + print OUTFILE "* \\brief Contains <tt>#undef</tt>s for all preprocessor macros\n"; + print OUTFILE "* defined by $packagename.\n"; + print OUTFILE "*\n"; + print OUTFILE "* This file is created automatically by the perl script <tt>undefAllMacros.pl</tt>.\n"; + print OUTFILE "*/\n\n"; + + # Parse the file itself + emitUndefs($file); + + # Makedepend recursively searches for more included headers. + # Warnings appear because the system headers will not be found. + # Those warnings get piped to /dev/null. + foreach $_ (`makedepend -f- -w 20 $Yinclude $file 2>/dev/null`) { + + # The output of makedepend has the form + # file.o: header.h + # We look for the ".o:" Everything that follows must be a header file + if (/\.o\:\s(\S+\.h)/) { + + emitUndefs($1); + + } + + } + +} + + +print "Undef'ed $counter #defines!\n"; + +close(OUTFILE); + + +############################################################## +# This subroutine reads the file given as the first argument +# and issues an #undef for each macro found. +############################################################## +sub emitUndefs { + + print "Parsing $_[0]\n"; + + unless (open INFILE, "$_[0]") { + die "Couldn't open $_[0] for reading!\n"; + } + + while(<INFILE>) { + + # looks for lines that define a C macro + if (/\#define\s+(\w+)/) { + + print OUTFILE "#ifdef $1\n"; + print OUTFILE " #undef $1\n"; + print OUTFILE "#endif // $1\n\n"; + $counter = $counter + 1; + + } + + } + + close (INFILE); + +} diff --git a/m4/alberta.m4 b/m4/alberta.m4 index f65bc7f38..8ea88a5ca 100644 --- a/m4/alberta.m4 +++ b/m4/alberta.m4 @@ -51,23 +51,20 @@ if test x$with_alberta != x && test x$with_alberta != xno ; then ALBERTA_LIB_PATH="$ALBERTAROOT/lib" ALBERTA_INCLUDE_PATH="$ALBERTAROOT/include" -# Alberta needs special defined symbols - -ALBERTADEF="-DDIM=$with_problem_dim -DDIM_OF_WORLD=$with_world_dim" - # set variables so that tests can use them REM_CPPFLAGS=$CPPFLAGS LDFLAGS="$LDFLAGS -L$ALBERTA_LIB_PATH" -CPPFLAGS="$CPPFLAGS $ALBERTADEF -DEL_INDEX=0 -I$ALBERTA_INCLUDE_PATH" +ALBERTADIM="-DDIM=$with_problem_dim -DDIM_OF_WORLD=$with_world_dim" +CPPFLAGS="$CPPFLAGS $ALBERTADIM -DEL_INDEX=0 -I$ALBERTA_INCLUDE_PATH" # check for header AC_CHECK_HEADER([alberta.h], - [ALBERTA_CPPFLAGS="$ALBERTADEF -I$ALBERTA_INCLUDE_PATH" + [ALBERTA_CPPFLAGS="-I$ALBERTA_INCLUDE_PATH" HAVE_ALBERTA="1"], AC_MSG_WARN([alberta.h not found in $ALBERTA_INCLUDE_PATH])) -CPPFLAGS="$REM_CPPFLAGS $ALBERTADEF -I$ALBERTA_INCLUDE_PATH" +CPPFLAGS="$REM_CPPFLAGS -I$ALBERTA_INCLUDE_PATH" REM_CPPFLAGS= REM_LDFLAGS=$LDFLAGS diff --git a/m4/dimension.m4 b/m4/dimension.m4 index 6eefe032f..882638386 100644 --- a/m4/dimension.m4 +++ b/m4/dimension.m4 @@ -7,12 +7,16 @@ AC_DEFUN([DUNE_DIMENSION],[ AC_ARG_WITH(problem_dim, AC_HELP_STRING([--with-problem-dim=2|3], [which dimension of the problem]),,with_problem_dim=2) -AC_SUBST(PROBLEMDIM, $with_problem_dim) +AC_SUBST(DUNE_PROBLEM_DIM, $with_problem_dim) +AC_DEFINE_UNQUOTED(DUNE_PROBLEM_DIM, $with_problem_dim, + [Dimension of grid]) # default dimension of the world coordinates is 2 AC_ARG_WITH(world_dim, AC_HELP_STRING([--with-world-dim=2|3], [which dimension of the world coordinates]),,with_world_dim=2) -AC_SUBST(PROBLEMDIM, $with_world_dim) +AC_SUBST(DUNE_WORLD_DIM, $with_world_dim) +AC_DEFINE_UNQUOTED(DUNE_WORLD_DIM, $with_world_dim, + [Dimension of world]) ]) \ No newline at end of file -- GitLab