> -----Original Message-----

> From: automake-bounces+jeff.daily=pnl....@gnu.org [mailto:automake-

> bounces+jeff.daily=pnl....@gnu.org] On Behalf Of Nicolai Stange

> Sent: Friday, July 29, 2011 2:17 AM

> To: automake@gnu.org

> Subject: Fortran and AC_DEFINE's

>

> Howdy everybody,

>

> we recognized here, that there are two problems with passing all the

> AC_DEFINE's to (preprocessed) Fortran compilation (through $DEFS or

> through a header file):

> 1.) If passed through $(DEFS): Some compilers (at least IBM xlf* on AIX)

> won't accept '-D' and bail out with an error. See

> https://lists.gnu.org/archive/html/autoconf-patches/2011-<https://lists.gnu.org/archive/html/autoconf-patches/2011-04/msg00004.html>

> 04/msg00004.html<https://lists.gnu.org/archive/html/autoconf-patches/2011-04/msg00004.html>
>  also.

> 2.) Most of the C-defines or aren't relevant for Fortran, and their 
> substitution

> within preprocessed Fortran might lead to surprising results, take

> AC_C_INLINE as an example.

> And for Fortran, it won't matther if we HAVE_UNISTD_H.

>

> A colleague of mine proposed that it would be cleaner to have language

> specific definers like "AC_DEFINE", "AC_FORTRAN_DEFINE" (and maybe

> others, but I only care about Fortran).

>

> Some clever Autoconf macro could then check how to pass defines to the

> Fortran compiler and build up FDEFS (which automake would use in turn for

> building up the compiling command line).

> On the other hand, if we find an

> AC_CONFIG_HEADERS ([ ... config.inc ...]) in configure.ac, just leave FDEFS

> empty. Of course it would be also nice if we had some 'autoheader --fortran'

> to create config.inc.in from the AC_FORTRAN_DEFINEs it can find.

>

> What do you think about all this: In your opinion, is this solution clean? 
> Does

> it suffice to implement just AC_FORTRAN_DEFINE or would you generalize

> that to other languages, too?

>

> Best,

>

> Nicolai



Our simple solution to this problem is to use sed to convert config.h to a 
config.fh.  You can't use config.h directly because it contains C-style 
comments.  This doesn't address the -D issue for IBM compilers, but the link 
you provided 
https://lists.gnu.org/archive/html/autoconf-patches/2011-04/msg00004.html does 
address that issue.



BUILT_SOURCES += config.fh

CLEANFILES += config.fh

nodist_libga_la_SOURCES += config.fh



config.fh: config.h

    @-rm -f $@

    $(SED_V) \

    $(SED) "/^#/!d" config.h > $@



# sed

SED_V = $(SED__v_$(V))

SED__v_ = $(SED__v_$(AM_DEFAULT_VERBOSITY))

SED__v_0 = @echo "  SED   " $@;
__________________________________________________
Jeff Daily
Scientist
DATA INTENSIVE SCIENTIFIC COMPUTING
Pacific Northwest National Laboratory
902 Battelle Boulevard
P.O. Box 999, MSIN K7-90
Richland, WA  99352 USA
Tel:  509-372-6548
Fax: 509-372-4720
jeff.da...@pnnl.gov
www.pnnl.gov



Reply via email to