+dnl Allow enablement of doxygen generated documentation
+AC_ARG_ENABLE(doxygen,
+ AS_HELP_STRING([--enable-doxygen],
+ [Build doxygen documentation (default is NO)]),,
+ enableval=default)
+case "$enableval" in
+ yes) AC_SUBST(ENABLE_DOXYGEN,[1]) ;;
+ no) AC_SUBST(ENABLE_DOXYGEN,[0]) ;;
+ default) AC_SUBST(ENABLE_DOXYGEN,[0]) ;;
+ *) AC_MSG_ERROR([Invalid setting for --enable-doxygen. Use "yes" or "no"]) ;;
+esac
+
+dnl Allow disablement of threads
+AC_ARG_ENABLE(threads,
+ AS_HELP_STRING([--enable-threads],
+ [Use threads if available (default is YES)]),,
+ enableval=default)
+case "$enableval" in
+ yes) AC_SUBST(ENABLE_THREADS,[1]) ;;
+ no) AC_SUBST(ENABLE_THREADS,[0]) ;;
+ default) AC_SUBST(ENABLE_THREADS,[1]) ;;
+ *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
+esac
+AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
+
+dnl Allow building with position independent code
+AC_ARG_ENABLE(pic,
+ AS_HELP_STRING([--enable-pic],
+ [Build LLVM with Position Independent Code (default is NO)]),,
+ enableval=default)
+case "$enableval" in
+ yes) AC_SUBST(ENABLE_PIC,[1]) ;;
+ no) AC_SUBST(ENABLE_PIC,[0]) ;;
+ default) AC_SUBST(ENABLE_PIC,[0]) ;;
+ *) AC_MSG_ERROR([Invalid setting for --enable-pic. Use "yes" or "no"]) ;;
+esac
+AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC,
+ [Define if position independent code is enabled])
+
+dnl Allow specific targets to be specified for building (or not)
+TARGETS_TO_BUILD=""
+AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
+ [Build specific host targets: all,host-only,{target-name} (default=all)]),,
+ enableval=all)
+case "$enableval" in
+ all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha IA64 ARM Mips CellSPU PIC16 CBackend MSIL CppBackend" ;;
+ host-only)
+ case "$llvm_cv_target_arch" in
+ x86) TARGETS_TO_BUILD="X86" ;;
+ x86_64) TARGETS_TO_BUILD="X86" ;;
+ Sparc) TARGETS_TO_BUILD="Sparc" ;;
+ PowerPC) TARGETS_TO_BUILD="PowerPC" ;;
+ Alpha) TARGETS_TO_BUILD="Alpha" ;;
+ IA64) TARGETS_TO_BUILD="IA64" ;;
+ ARM) TARGETS_TO_BUILD="ARM" ;;
+ Mips) TARGETS_TO_BUILD="Mips" ;;
+ CellSPU|SPU) TARGETS_TO_BUILD="CellSPU" ;;
+ PIC16) TARGETS_TO_BUILD="PIC16" ;;
+ *) AC_MSG_ERROR([Can not set target to build]) ;;
+ esac
+ ;;
+ *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
+ case "$a_target" in
+ x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
+ x86_64) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
+ sparc) TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
+ powerpc) TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
+ alpha) TARGETS_TO_BUILD="Alpha $TARGETS_TO_BUILD" ;;
+ ia64) TARGETS_TO_BUILD="IA64 $TARGETS_TO_BUILD" ;;
+ arm) TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
+ mips) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
+ spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;;
+ pic16) TARGETS_TO_BUILD="PIC16 $TARGETS_TO_BUILD" ;;
+ cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;;
+ msil) TARGETS_TO_BUILD="MSIL $TARGETS_TO_BUILD" ;;
+ cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
+ *) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
+ esac
+ done
+ ;;
+esac
+AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD)
+
+dnl Prevent the CBackend from using printf("%a") for floating point so older
+dnl C compilers that cannot deal with the 0x0p+0 hex floating point format
+dnl can still compile the CBE's output
+AC_ARG_ENABLE([cbe-printf-a],AS_HELP_STRING([--enable-cbe-printf-a],
+ [Enable C Backend output with hex floating point via %a (default is YES)]),,
+ enableval=default)
+case "$enableval" in
+ yes) AC_SUBST(ENABLE_CBE_PRINTF_A,[1]) ;;
+ no) AC_SUBST(ENABLE_CBE_PRINTF_A,[0]) ;;
+ default) AC_SUBST(ENABLE_CBE_PRINTF_A,[1]) ;;
+ *) AC_MSG_ERROR([Invalid setting for --enable-cbe-printf-a. Use "yes" or "no"]) ;;
+esac
+AC_DEFINE_UNQUOTED([ENABLE_CBE_PRINTF_A],$ENABLE_CBE_PRINTF_A,
+ [Define if CBE is enabled for printf %a output])
+
+dnl Allow a specific llvm-gcc/llvm-g++ pair to be used with this LLVM config.
+AC_ARG_WITH(llvmgccdir,
+ AS_HELP_STRING([--with-llvmgccdir],
+ [Specify location of llvm-gcc install dir (default searches PATH)]),,
+ withval=default)
+case "$withval" in
+ default) WITH_LLVMGCCDIR=default ;;
+ /* | [[A-Za-z]]:[[\\/]]*) WITH_LLVMGCCDIR=$withval ;;
+ *) AC_MSG_ERROR([Invalid path for --with-llvmgccdir. Provide full path]) ;;
+esac
+
+dnl Allow a specific llvm-gcc compiler to be used with this LLVM config.
+AC_ARG_WITH(llvmgcc,
+ AS_HELP_STRING([--with-llvmgcc],
+ [Specify location of llvm-gcc driver (default searches PATH)]),
+ LLVMGCC=$with_llvmgcc
+ WITH_LLVMGCCDIR="",)
+
+dnl Allow a specific llvm-g++ compiler to be used with this LLVM config.
+AC_ARG_WITH(llvmgxx,
+ AS_HELP_STRING([--with-llvmgxx],
+ [Specify location of llvm-g++ driver (default searches PATH)]),
+ LLVMGXX=$with_llvmgxx
+ WITH_LLVMGCCDIR="",)
+
+if test -n "$LLVMGCC" && test -z "$LLVMGXX"; then
+ AC_MSG_ERROR([Invalid llvm-g++. Use --with-llvmgxx when --with-llvmgcc is used]);
+fi
+
+if test -n "$LLVMGXX" && test -z "$LLVMGCC"; then
+ AC_MSG_ERROR([Invalid llvm-gcc. Use --with-llvmgcc when --with-llvmgxx is used]);
+fi
+
+dnl Specify extra build options
+AC_ARG_WITH(extra-options,
+ AS_HELP_STRING([--with-extra-options],
+ [Specify addtional options to compile LLVM with]),,
+ withval=default)
+case "$withval" in
+ default) EXTRA_OPTIONS= ;;
+ *) EXTRA_OPTIONS=$withval ;;
+esac
+AC_SUBST(EXTRA_OPTIONS,$EXTRA_OPTIONS)
+
+dnl Allow specific bindings to be specified for building (or not)
+AC_ARG_ENABLE([bindings],AS_HELP_STRING([--enable-bindings],
+ [Build specific language bindings: all,auto,none,{binding-name} (default=auto)]),,
+ enableval=default)
+BINDINGS_TO_BUILD=""
+case "$enableval" in
+ yes | default | auto) BINDINGS_TO_BUILD="auto" ;;
+ all ) BINDINGS_TO_BUILD="ocaml" ;;
+ none | no) BINDINGS_TO_BUILD="" ;;
+ *)for a_binding in `echo $enableval|sed -e 's/,/ /g' ` ; do
+ case "$a_binding" in
+ ocaml) BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD" ;;
+ *) AC_MSG_ERROR([Unrecognized binding $a_binding]) ;;
+ esac
+ done
+ ;;
+esac
+
+dnl Allow the ocaml libdir to be overridden. This could go in a configure
+dnl script for bindings/ocaml/configure, except that its auto value depends on
+dnl OCAMLC, which is found here to support tests.
+AC_ARG_WITH([ocaml-libdir],
+ [AS_HELP_STRING([--with-ocaml-libdir],
+ [Specify install location for ocaml bindings (default is stdlib)])],
+ [],
+ [withval=auto])
+case "$withval" in
+ auto) with_ocaml_libdir="$withval" ;;
+ /* | [[A-Za-z]]:[[\\/]]*) with_ocaml_libdir="$withval" ;;
+ *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;;
+esac
+
+dnl===-----------------------------------------------------------------------===
+dnl===
+dnl=== SECTION 4: Check for programs we need and that they are the right version
+dnl===
+dnl===-----------------------------------------------------------------------===
+
+dnl Check for compilation tools
+AC_PROG_CPP
+AC_PROG_CC(gcc)
+AC_PROG_CXX(g++)