[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reusing the product of AC_LANG_PROGRAM().
From: |
Stefano Lattarini |
Subject: |
Re: Reusing the product of AC_LANG_PROGRAM(). |
Date: |
Tue, 25 May 2010 16:21:26 +0200 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; ) |
At Tuesday 25 May 2010, Stefano Lattarini <address@hidden> wrote:
> At Tuesday 25 May 2010, Václav Haisman <address@hidden> wrote:
> > Hi.
> >
> > Is it possible to reuse whatever AC_LANG_PROGRAM() produces?
>
> I'm not an expert about this macro. but I'd do something like this:
>
> m4_define([MY_PROLOGUE], [whatever])
> m4_define([MY_BODY], [whatever2])
> m4_define([MY_PROGRAM], [AC_LANG_PROGRAM([MY_PROLOGUE],
> [MY_BODY])]) ...
> AC_LINK_IFELSE([MY_PROGRAM], [action-if-true], [action-if-false])
> if <not cross compiling>; then
> AC_RUN_IFELSE([MY_PROGRAM], [action-if-true], [action-if-false])
> fi
>
Or you could avoid compiling the same source twice, by running
additional tests on the compiled program in the `action-if-true'
part of the `AC_LINK_IFELSE' call:
AC_LINK_IFELSE([AC_LANG_PROGRAM([prologue], [body])],
[if <not cross compiling>; then
if ./conftest$EXEEXT >/dev/null 2>&1; then
tested_program_works=yes
else
tested_program_works=no
fi
else # we are cross compiling
tested_program_works=yes # assume that if it links, it works
fi],
[tested_program_works=no])
Please note that the above snippet is just a rough sketch. You can
consider improving it by using caching mechanisms, by making it emit
useful messages/diagnostic to config.log, etc.
Regards,
Stefano