avoiding AC_DEFINE in AC_RUN_IFELSE for Perl C code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

In GNU Texinfo, we have two types of C code files when it comes to
portability.  The first type is usual C code that makes use of Autoconf
and Gnulib portability features, through the include of config.h.  The
second type corresponds to C code that includes Perl headers, this code
do not use Autoconf nor Gnulib portability features and do not include
config.h.  We completly separate the two types of code because the
Autoconf + Gnulib and Perl portability redefinitions are incompatible.
On GNU/Linux it is not actually an issue, but in MinGW, where both
Autoconf + Gnulib and Perl add/redefine a lot of code, the two clash.

Most of the checks in configure.ac are for the code including config.h.
There is an AC_LINK_IFELSE test, however, that is for code including
Perl headers (to check that it is possible to embed a Perl interpreter),
which also uses AC_LANG_PROGRAM.

Here is an excerpt of this test:

AC_MSG_CHECKING(for embedded Perl)
LIBS="$PERL_EXTUTILS_EMBED_ldopts"
....

AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define context perl_context
....
#include "perl.h"

static PerlInterpreter *my_perl;

EXTERN_C void xs_init (pTHX);
....
int
call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref)
{
  ....
  my_perl = perl_alloc();
  ...
}
void
call_finish_perl (void)
{
  perl_destruct(my_perl);
....
}]], [[call_init_perl (0, 0, 0); call_finish_perl ();]])],
    [embedded_perl=yes], [embedded_perl=no])

AC_MSG_RESULT($embedded_perl)


Currently, the AC_DEFINE results performed previously includes are used
for this test.  It works correctly on GNU/Linux, but it should fail on
platforms where the Perl headers are incompatible with the Autoconf and
Gnulib defines.  To avoid this, the test should instead be performed
without the AC_DEFINE results performed previously includes, although
this is the default of AC_LANG_CONFTEST, and of AC_LANG_PROGRAM or
AC_LINK_IFELSE.  I couldn't find a way to do that.

In AC_LINK_IFELSE documentation, there is hint on how to avoid inserting
the AC_DEFINE results performed previously includes (maybe), but I could
not understand how to use that information in practice:

     If INPUT is nonempty use the equivalent of
     ‘AC_LANG_CONFTEST(INPUT)’ to generate the current test source file;
     otherwise reuse the already-existing test source file.  The INPUT
     can be made by ‘AC_LANG_PROGRAM’ and friends.

So it seems that the "already-existing test source file" can be reused,
which hints that it could be generated differently, but I did not find
anything about that.

How could I modify the test such that no other defines are added?

Thanks in advance,

PS: please CC me, I am not subscribed.

-- 
Pat




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux