Chinaunix首页 | 论坛 | 博客
  • 博客访问: 336103
  • 博文数量: 105
  • 博客积分: 2730
  • 博客等级: 少校
  • 技术积分: 1110
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-20 12:09
文章分类

全部博文(105)

文章存档

2013年(3)

2012年(2)

2011年(36)

2010年(34)

2009年(6)

2008年(20)

2007年(4)

分类: PHP

2011-12-12 16:50:43

AC_INIT([Haskell LLVM bindings], [0.9.1.2], [bos@serpentine.com], [llvm])

AC_INIT(package, version, [bug-report], [tarname], [url])

 

AC_CONFIG_SRCDIR([LLVM/ExecutionEngine.hs])

检查一个文件存在保证源目录正确性

 

AC_CONFIG_FILES([llvm.buildinfo])

列出的<文件>需要从<文件.in>生成.

 

AC_CONFIG_HEADERS([include/hs_llvm_config.h])

生成头文件,同上,但是正常时只要生成一个头文件.

 

AC_PROG_CXX

自动检查C++编译器

 

AC_LANG(C++)

声明用到的语言,对于C++,会用CXXCXXCPP, CPPFLAGS/CXXFLAGS.


配置configure提供给用户的选项语法:

AC_ARG_WITH (package, help-string, [action-if-given], [Macro]

[action-if-not-given])


AC_ARG_WITH(compiler,

  [AS_HELP_STRING([--with-compiler],

    [use the given Haskell compiler])],

  compiler="$withval",

  compiler=ghc)dnl

配置使用的haskell编译器,默认ghc

 

AC_ARG_WITH(llvm_prefix,

  [AS_HELP_STRING([--with-llvm-prefix],

    [use the version of LLVM at the given location])],

  llvm_prefix="$withval",

  llvm_prefix="$prefix")dnl

配置llvm-prefix,默认使用$prefix


AC_ARG_WITH(llvm_bindir,

  [AS_HELP_STRING([--with-llvm-bindir],

    [use LLVM binaries at the given location])],

  llvm_bindir="$withval",

  llvm_bindir="$llvm_prefix/bin")dnl

llvm的bin目录,类似上面,llvm如果没有分离bin目录则此处就不用配置,默认使用$llvm_prefix/bin

 

AC_PATH_PROGS(llvm_config, [llvm-config],

  [AC_MSG_ERROR(could not find llvm-config in $llvm_bindir)],

  ["$llvm_bindir:$PATH"])

查找程序llvm-config

 

dnl * Choose target platform

dnl

dnl We don't use the standard autoconf macros for this, but instead

dnl ask GHC what platform it is for.  Why?  We need to generate a library

dnl matching the compiler.

dnl NB: This code is from GHC's configure (where the corresponding code for

dnl guessing host and build variables can be found, too)

使用ghc的平台提供的platform信息.下面的内容也是参考了ghc的用法.ghc编译时会向可用的ghc询问平台.

******TODO:整理下面的.

dnl Guess target platform if necessary.

m4_divert_once([HELP_CANON],

[[

System types:

  --target=TARGET   configure for building compilers for TARGET [guessed]]])dnl

 

if test "$target" = ""

then

    if test "${compiler}" != ""

    then

        target=`${compiler} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`

        echo "Target platform inferred as: $target"

    else

        echo "Can't work out target platform"

        exit 1

    fi

fi

 

dnl Determine target-specific options

dnl This is important as Snow Leopard (Mac OS X 10.6) defaults to generating

dnl 64-bit code.

case $target in

i386-apple-darwin)

    TARGET_CPPFLAGS="-m32"

    TAGRET_LDFLAGS="-m32"

    ;;

x86_64-apple-darwin)

    TARGET_CPPFLAGS="-m64"

    TAGRET_LDFLAGS="-m64"

    ;;

esac

 

llvm_version="`$llvm_config --version`"

llvm_cppflags="`$llvm_config --cppflags`"

llvm_includedir="`$llvm_config --includedir`"

llvm_ldflags="`$llvm_config --ldflags`"

 

llvm_all_libs="`$llvm_config --libs all`"

llvm_target="`$llvm_config --libs engine | sed 's/.*LLVM\(.[[^ ]]*\)CodeGen.*/\1/'`"

 

CPPFLAGS="$llvm_cppflags $CPPFLAGS $TARGET_CPPFLAGS"

LDFLAGS="$llvm_ldflags $LDFLAGS $TARGET_LDFLAGS"

 

llvm_extra_ghci_libs=""

 

AC_SEARCH_LIBS([LLVMModuleCreateWithName],[LLVM-2.7 LLVM-2.8 LLVM-2.9 LLVM-3.0])

if test "$ac_cv_search_LLVMModuleCreateWithName" = "no"; then

   llvm_all_libs="`$llvm_config --libs all`"

else

   llvm_extra_ghci_libs="LLVM-$llvm_version"

   llvm_all_libs="$LIBS"

fi

 

dnl We need to separate libraries that need to be linked from other linker options.

llvm_extra_libs=""

llvm_extra_libdirs=""

llvm_ldoptions=""

for opt in $llvm_all_libs $llvm_ldflags; do

  case $opt in

    -l*) llvm_extra_libs="$llvm_extra_libs `echo $opt | sed 's/^-l//'`";;

    -L*) llvm_extra_libdirs="$llvm_extra_libdirs `echo $opt | sed 's/^-L//'`";;

    *)   llvm_ldoptions="$llvm_ldoptions $opt";;

  esac

done

 

AC_CHECK_HEADERS([llvm-c/Core.h], [],

  [AC_MSG_ERROR(could not find LLVM C bindings)])

 

AC_CHECK_HEADERS([llvm/Support/DynamicLibrary.h],[],[],

[#include

])

 

save_LIBS="$LIBS"

LIBS="-lLLVMSupport -lpthread -ldl $LIBS"

 

AC_CHECK_LIB(LLVMCore, LLVMModuleCreateWithName, [], [])

if test "$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" = "no"; then

  unset ac_cv_lib_LLVMCore_LLVMModuleCreateWithName

  LIBS="-lLLVMSupport $save_LIBS"

  AC_CHECK_LIB(LLVMCore, LLVMModuleCreateWithName, [],

    [AC_MSG_ERROR(could not find LLVM C bindings)])

fi

 

AC_SUBST([llvm_version])

AC_SUBST([llvm_cppflags])

AC_SUBST([llvm_extra_libs])

AC_SUBST([llvm_extra_libdirs])

AC_SUBST([llvm_extra_ghci_libs])

AC_SUBST([llvm_target])

AC_SUBST([llvm_includedir])

AC_SUBST([llvm_ldoptions])

 

AC_OUTPUT

阅读(1940) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~