Subject: Re: bug#8599: upc (Unified Parallel C) support in automake (was: Re: AM_PROG_UPC)

From: Stefano Lattarini <[email-masked]>
Date: Wed, 4 May 2011 17:54:20 +0200

On Monday 02 May 2011, Justin  wrote:
> Hi Stefano
Hi Justin, sorry for the delay.

> On 4/30/11 1:10 PM, "Stefano Lattarini" <[email-masked]>
> wrote:
> 
> >[adding automake and bug-automake lists]
> >[follow-ups might drop autoconf list IMHO]
> >[Reference: 
> ><http://lists.gnu.org/archive/html/autoconf/2011-04/msg00072.html>]
> >
> >Hello Justin and Ralf, and sorry for the delay.
> >
> >On Saturday 30 April 2011, Justin  wrote:
> >> On 4/29/11 8:57 PM, "Ralf Corsepius" <[email-masked]> wrote:
> >> 
> >> >On 04/30/2011 01:16 AM, Too, Justin A. wrote:
> >> >> Hi all,
> >> >>
> >> >> In my configure.ac I simply invoke: AC_PROG_UPC
> >> >>
> >> >> Š
> >> >> $ aclocal Š
> >> >>      aclocal:configure.ac:12: warning: macro `AM_PROG_UPC' not found
> >>in
> >> >>library
> >> >> Š
> >> >> $ autoconf
> >> >>      Configure.ac:12: error: possibly undefined macro: AM_PROG_UPC
> >> >> If this token and others are legitimate, please use m4patternallow.
> >> >> See the Autoconf documentation.
> >> >>
> >> >> Is this a non-standard macro?
> >> >Yes.
> >> >
> >No, it's not (well, it shouldn't be).  It is defined in the file
> >`upc.m4' provided by automake.  Thus the failure above, if not due
> >to some misconfiguration or user error, is an automake bug.
> 
> 
> Sorry, the problem was not critical.  It turns out that my system
> installation of Automake is 1.9, but /usr/share/aclocal/upc.m4 did not
> exist.  I've got 'upc.m4' in place now so it seems to make it pass
> 'aclocal' and 'automake' now.
> 
> I've got another somewhat related issue, and that is: how can I
> conditionally use the macro AM_PROG_UPC?
>

> Most users won't have UPC in
> their path so I'd like to only check for UPC if the user configures
> explicitly with UPC.  If I wrap the macro call like so:
> 
> if test "xwith_upc" = "xyes" ; then
>     AM_PROG_UPC
> fi
> 
> I get "configure: error: conditional "am__fastdepUPC" was never defined.
> Usually this means the macro was only invoked conditionally.".   In the
> configure script, it looks like UPC-related code is generated outside of
> my if..fi block in addition to inside of the block.
>
Yes, this is a known limitation. You can work around it using the
autoconf-provided AS_IF macro instead of an hand-written if/else
construct.  For example:

  $ cat > configure.ac <<'END'
  AC_INIT([x],0)
  AS_IF([test "x$with_upc" = "xyes"], [AM_PROG_UPC])
  END
  $ aclocal && autoconf
  $ ./configure; echo status = $?
  checking for gcc... gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for gcc option to accept ISO C89... none needed
  checking for style of include used by make... GNU
  status = 0
  $ ./configure with_upc=yes; status = $?
  checking for gcc... gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for gcc option to accept ISO C89... none needed
  checking for style of include used by make... GNU
  checking for upcc... no
  checking for upc... no
  configure: error: no Unified Parallel C compiler was found
  status = 77

You can find more details about AS_IF (and similar macros) here:
<http://www.gnu.org/software/autoconf/manual/html_node/Common-Shell-Constructs.html>

> Thanks for the advise,
> Justin
 
HTH,
  Stefano