免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 728 | 回复: 0
打印 上一主题 下一主题

Who can help with this macro? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-12-11 17:45 |只看该作者 |倒序浏览
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)
  ], )
])
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP