[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: autotools on aix
From: |
Daily, Jeff A |
Subject: |
RE: autotools on aix |
Date: |
Wed, 11 May 2011 18:28:53 -0700 |
> From: address@hidden address@hidden On Behalf Of Jim Edwards address@hidden
> Sent: Wednesday, May 11, 2011 4:51 PM
> To: address@hidden
> Subject: autotools on aix
>
> I am trying to port a model to AIX. The model uses cc cxx and fc
> compilers.
> The problem is that the IBM xlf compilers do not recognize the -D
> preprocessor flag and I am at my wits end trying to
> get the tools to do the right thing.
>
> I can handle a conditional edit of the FCFLAGS in configure.in
>
> FCFLAGS=$(echo $FCFLAGS | sed 's/-D/-WF,-D/g')
>
> but problems hound me.
>
> 1. CPPFLAGS is used in PPFCCOMPILE and LTPPFCCOMPILE but since CPPFLAGS is
> also used for c and cxx I can't substitute that.
> 2. DEFS= -DHAVE_CONFIG_H is also defined and used in the same places
> 3. libtool defines pic_flag=' -DPIC'
>
> Anyone have a good solution?
This is the solution we chose. We are aware of the IBM xlf compilers as well
as the Fujitsu compilers having this kind of behavior. We test for all three
cases, and if it's the more common -D case, we don't change anything. If it's
one of the unusual cases, we change FFLAGS. YMMV. I hope this helps.
Hopefully you can copy and past it into an *.m4 of your own. This comes from
our Global Arrays toolkit (http://www.emsl.pnl.gov/docs/global/), hence the
GA_* or ga_* prefix on most things.
# GA_F77_CPP_SYMBOL([ACTION-WHEN-FOUND])
# --------------------------------------
# Detect how to pass CPP symbols to preprocessed Fortran 77.
#
# Known:
# -D the usual
# -WF,-D IBM xlf
# -Wp,-D Fujitsu
#
AC_DEFUN([GA_F77_CPP_SYMBOL],
[AC_CACHE_CHECK([how to pass symbols to preprocessed $F77],
[ga_cv_f77_cpp_symbol],
[AC_LANG_PUSH([Fortran 77])
ac_ext=F
for symbol in -D -WF,-D -Wp,-D
do
ga_save_CPPFLAGS="$CPPFLAGS"
ga_save_FFLAGS="$FFLAGS"
CPPFLAGS="$CPPFLAGS ${symbol}GABLAHBLAH"
FFLAGS="$CPPFLAGS $FFLAGS"
AC_COMPILE_IFELSE(
[[#ifndef GABLAHBLAH
this is an error
#endif
end program]],
[ga_cv_f77_cpp_symbol="$symbol"])
CPPFLAGS="$ga_save_CPPFLAGS"
FFLAGS="$ga_save_FFLAGS"
AS_IF([test "x$ga_cv_f77_cpp_symbol" != x], [break])
done
AC_LANG_POP([Fortran 77])
])
AS_IF([test "x$ga_cv_f77_cpp_symbol" = x],
[AC_MSG_ERROR([don't know how to pass symbols to preprocessed Fortran])])
m4_default([$1],
[AS_CASE([$ga_cv_f77_cpp_symbol],
[-D], [],
[FFLAGS="$FFLAGS ${ga_cv_f77_cpp_symbol}HAVE_CONFIG_H"])])
]) # GA_F77_CPP_SYMBOL