[Top][All Lists]

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

RE: Fortran and AC_DEFINE's

From: Daily, Jeff A
Subject: RE: Fortran and AC_DEFINE's
Date: Mon, 1 Aug 2011 09:13:11 -0700

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

> From: address@hidden [mailto:automake-

> address@hidden On Behalf Of Nicolai Stange

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

> To: address@hidden

> 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


> 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 ([ ... ...]) in, just leave FDEFS

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

> to create 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 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_0 = @echo "  SED   " $@;
Jeff Daily
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]