- 论坛徽章:
- 0
|
This is a macro definition in m4 for the usage in autoconf/automake, who can explain how this will be expanded (calculated)? Thanks a lot!
# AM_ARCHITECTURE
# Determine command-line parameters for given target architecture
AC_DEFUN(AM_ARCHITECTURE,
[
AC_REQUIRE([AC_PROG_CC])
AC_PROVIDE([AM_ARCHITECTURE])
AC_ARG_WITH(arch, [ --with-arch=ARCH Compile for given architecture (optional)], [
if test x$withval = xv8plusa ; then
arch_flags="-mcpu=v8"
else
if test x$withval = xv9a ; then
arch_flags="-mcpu=v9 -m64"
else
arch_flags="-mcpu=$withval"
fi
fi
AC_LANG_SAVE
AC_LANG_C
saved_CFLAGS="$CFLAGS"
CFLAGS="$saved_CFLAGS -xarch=$withval"
AC_MSG_CHECKING([whether -xarch=$withval works])
AC_TRY_LINK(, [/* nothing */], [
AC_MSG_RESULT(yes)
ARCH="$withval"
ARCH_CFLAGS="-xarch=$withval"
ARCH_LDFLAGS="$ARCH_CFLAGS"
], [
AC_MSG_RESULT(no)
CFLAGS="$saved_CFLAGS $arch_flags"
AC_MSG_CHECKING([whether $arch_flags works])
AC_TRY_LINK(, [/* nothing */], [
AC_MSG_RESULT(yes)
ARCH="$withval"
ARCH_CFLAGS="$arch_flags"
ARCH_LDFLAGS="$ARCH_CFLAGS"
], [
AC_MSG_RESULT([no, ignoring switch])
ARCH=""
ARCH_CFLAGS=""
ARCH_LDFLAGS=""
])
])
CFLAGS="$saved_CFLAGS"
if test x$CXX = x ; then
ARCH_CXXFLAGS=""
else
AC_LANG_CPLUSPLUS
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$saved_CXXFLAGS -xarch=$withval"
AC_MSG_CHECKING([whether -xarch=$withval works for C++ compiler])
AC_TRY_LINK(, [/* nothing */], [
AC_MSG_RESULT(yes)
ARCH_CXXFLAGS="-xarch=$withval"
], [
AC_MSG_RESULT(no)
CXXFLAGS="$saved_CXXFLAGS $arch_flags"
AC_MSG_CHECKING([whether $arch_flags works for C++ compiler])
AC_TRY_LINK(, [/* nothing */], [
AC_MSG_RESULT(yes)
ARCH_CXXFLAGS="$arch_flags"
], [
AC_MSG_RESULT([no, ignoring switch])
ARCH_CXXFLAGS=""
])
])
CXXFLAGS="$saved_CXXFLAGS"
fi
if test x$F77 = x ; then
ARCH_FFLAGS=""
else
AC_LANG_FORTRAN77
saved_FFLAGS="$FFLAGS"
FFLAGS="$saved_FFLAGS -xarch=$withval"
AC_MSG_CHECKING([whether -xarch=$withval works for Fortran compiler])
AC_TRY_LINK(, [/* nothing */], [
AC_MSG_RESULT(yes)
ARCH_FFLAGS="-xarch=$withval"
], [
AC_MSG_RESULT(no)
FFLAGS="$saved_FFLAGS $arch_flags"
AC_MSG_CHECKING([whether $arch_flags works for Fortran compiler])
AC_TRY_LINK(, [exit], [
AC_MSG_RESULT(yes)
ARCH_FFLAGS="$arch_flags"
], [
AC_MSG_RESULT([no, ignoring switch])
ARCH_FFLAGS=""
])
])
FFLAGS="$saved_FFLAGS"
fi
AC_LANG_RESTORE
AC_DEFINE_UNQUOTED(ARCHITECTURE, $ARCH, [Target architecture])
AC_SUBST(ARCH)
AC_SUBST(ARCH_CFLAGS)
AC_SUBST(ARCH_CXXFLAGS)
AC_SUBST(ARCH_FFLAGS)
AC_SUBST(ARCH_LDFLAGS)
], )
]) |
|