[Dune] dune m4 tests

Christian Engwer christi at uni-hd.de
Fri Aug 27 18:00:53 CEST 2010


On Fri, Aug 27, 2010 at 03:02:33PM +0200, Jö Fahlke wrote:
> Am Fri, 27. Aug 2010, 11:39:07 +0200 schrieb Oliver Sander:
> > The problem is the following: dune-common installs m4 files with the
> > same names as m4 files contained in the autoconf-archive into the
> > very same location (/usr/share/aclocal).  Some of the files are verbatim
> > copies, other have small modifications.  Now image you have the
> > autoconf archive or some of its tests globally installed on your system,
> > and you want to install dune-common.  If you are lucky you are
> > using a smart package manager, which will stop you because you are
> > overwriting system files.  If you install dune-common globally with just
> > 'make install', the m4 files from the original autoconf archive are tacitly
> > overwritten.
> > 
> > This is FlySpray # 813
> 
> I'd solve that by making the dune-dev packages depend on autoconf-archive and
> omit the offending .m4-files from the dune-dev packages.  This should work as
> long as those tests are exact copies of the same test from some suitable
> vesion of autoconf-archive.

the problem is that some of the tests are modified.

But I just got an idea how to deal with modified tests...
usually the only modification is that the original test is a hard
requirement, but we want to be able to continue without the lib.

we might write our own test and overload the AC_MSG_ERRROR macro. I
think of something like this:

AC_DEFINE([DUNE_FOO],
[
  AC_REQUIRE([AC_MSG_OVERLOAD]) # trick to pull in the necessary definitions
  DISABLE_AC_MSG_ERROR
  AX_FOO
  if (ac_succes); then
    ...
  fi
  RESTORE_AC_MSG_ERROR
])

and something like this for the overloads (untested!):

dnl trick to pull in this m4 file
AC_DEFINE([AC_MSG_OVERLOAD])

dnl new definitions of MSG_ERROR and MSG_FAILURE
m4_define([AC_MSG_ERROR_NEW],
[
  AC_MSG_WARN([$1])
  ac_success=no
]
)
m4_define([AC_MSG_FAILURE_NEW],AC_MSG_ERROR_NEW([$1],[$2]))

dnl original definitions of MSG_ERROR and MSG_FAILURE
m4_define([AC_MSG_ERROR_ORIG],AC_MSG_ERROR([$1],[$2]))
m4_define([AC_MSG_FAILURE_ORIG],AC_MSG_ERROR([$1],[$2]))

dnl disable MSG_ERROR by pointing it to the new definition
m4_define([DISABLE_AC_MSG_ERROR],[
  ac_success=yes
  m4_define([AC_MSG_ERROR],AC_MSG_ERROR_NEW([$1],[$2]))
  m4_define([AC_MSG_FAILURE],AC_MSG_ERROR_NEW([$1],[$2]))
])

dnl restring MSG_ERROR by pointing it back to the original definition
m4_define([RESTORE_AC_MSG_ERROR],[
  m4_define([AC_MSG_ERROR],AC_MSG_ERROR_ORIG([$1],[$2]))
  m4_define([AC_MSG_FAILURE],AC_MSG_ERROR_ORIG([$1],[$2]))
])


I already tested the general idea of overloading and restoring an m4
macro, but not the code above...

Cheers
Christian




More information about the Dune mailing list