At Tuesday 25 May 2010, Stefano Lattarini <stefano.lattar...@gmail.com> wrote:
> At Tuesday 25 May 2010, Václav Haisman <v.hais...@sh.cvut.cz> 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

_______________________________________________
Autoconf mailing list
Autoconf@gnu.org
http://lists.gnu.org/mailman/listinfo/autoconf

Reply via email to