Skip to content
Snippets Groups Projects
bootstrap 56.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • #=============================================================================
    # CMake - Cross Platform Makefile Generator
    
    # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
    
    # Distributed under the OSI-approved BSD License (the "License");
    # see accompanying file Copyright.txt for details.
    
    # This software is distributed WITHOUT ANY WARRANTY; without even the
    # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    # See the License for more information.
    #=============================================================================
    
    die() {
      echo "$@" 1>&2 ; exit 1
    }
    
    
    # Version number extraction function.
    cmake_version_component()
    {
    
      cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
    
    /^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
    
    # Install destination extraction function.
    cmake_install_dest_default()
    {
      cat "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake" | sed -n '
    /^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ {
    
      s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/
      s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/
      s/${CMake_VERSION_MINOR}/'"${cmake_version_minor}"'/
      s/${CMake_VERSION_PATCH}/'"${cmake_version_patch}"'/
      p
      q
    }
    
    cmake_toupper()
    {
        echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
    }
    
    
    # Detect system and directory information.
    cmake_system=`uname`
    
    cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
    
    cmake_binary_dir=`pwd`
    
    
    # Load version information.
    
    cmake_version_major="`cmake_version_component MAJOR`"
    cmake_version_minor="`cmake_version_component MINOR`"
    
    cmake_version_patch="`cmake_version_component PATCH`"
    cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
    
    cmake_version_rc="`cmake_version_component RC`"
    if [ "$cmake_version_rc" != "" ]; then
      cmake_version="${cmake_version}-rc${cmake_version_rc}"
    fi
    
    cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`"
    
    
    cmake_data_dir_keyword="OTHER"
    cmake_doc_dir_keyword="OTHER"
    cmake_man_dir_keyword="OTHER"
    cmake_data_dir=""
    cmake_doc_dir=""
    cmake_man_dir=""
    
    cmake_bootstrap_qt_gui=""
    cmake_bootstrap_qt_qmake=""
    
    cmake_sphinx_man=""
    cmake_sphinx_html=""
    cmake_sphinx_build=""
    
    # Determine whether this is a Cygwin environment.
    if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
      cmake_system_cygwin=true
    
      cmake_doc_dir_keyword="CYGWIN"
      cmake_man_dir_keyword="CYGWIN"
    
    else
      cmake_system_cygwin=false
    fi
    
    
    # Determine whether this is a MinGW environment.
    if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
      cmake_system_mingw=true
    else
      cmake_system_mingw=false
    fi
    
    
    # Determine whether this is OS X
    if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
      cmake_system_darwin=true
    else
      cmake_system_darwin=false
    fi
    
    
    # Determine whether this is BeOS
    
    if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
      cmake_system_beos=true
    
      cmake_doc_dir_keyword="HAIKU"
      cmake_man_dir_keyword="HAIKU"
    
    else
      cmake_system_beos=false
    fi
    
    
    # Determine whether this is Haiku
    
    if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
      cmake_system_haiku=true
    
      cmake_doc_dir_keyword="HAIKU"
      cmake_man_dir_keyword="HAIKU"
    
    # Determine whether this is OpenVMS
    if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
      cmake_system_openvms=true
    else
      cmake_system_openvms=false
    fi
    
    
    # Determine whether this is Linux
    if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
      cmake_system_linux=true
      # find out if it is a HP PA-RISC machine
      if uname -m | grep parisc >/dev/null 2>&1; then
        cmake_machine_parisc=true
      else
        cmake_machine_parisc=false
      fi
    else
      cmake_system_linux=false
    fi
    
    
    # Choose the generator to use for bootstrapping.
    if ${cmake_system_mingw}; then
      # Bootstrapping from an MSYS prompt.
      cmake_bootstrap_generator="MSYS Makefiles"
    else
      # Bootstrapping from a standard UNIX prompt.
      cmake_bootstrap_generator="Unix Makefiles"
    fi
    
    
    # Choose tools and extensions for this platform.
    if ${cmake_system_openvms}; then
      _tmp="_tmp"
      _cmk="_cmk"
      _diff=`which diff`
    else
      _tmp=".tmp"
      _cmk=".cmk"
      _diff="diff"
    fi
    
    # Construct bootstrap directory name.
    cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
    
    
    # Helper function to fix windows paths.
    
    case "${cmake_system}" in
    *MINGW*)
      cmake_fix_slashes()
      {
        cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
      }
      ;;
    *)
      cmake_fix_slashes()
      {
        echo "$1" | sed 's/\\/\//g'
      }
      ;;
    esac
    
    
    # Choose the default install prefix.
    if ${cmake_system_mingw}; then
      if [ "x${PROGRAMFILES}" != "x" ]; then
        cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
      elif [ "x${ProgramFiles}" != "x" ]; then
        cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
      elif [ "x${SYSTEMDRIVE}" != "x" ]; then
        cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
      elif [ "x${SystemDrive}" != "x" ]; then
        cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
      else
        cmake_default_prefix="c:/Program Files/CMake"
      fi
    
    elif ${cmake_system_haiku}; then
    
      cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
    
    # Lookup default install destinations.
    cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`"
    cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`"
    cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`"
    
    
    CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
    
    CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
    
    CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
    
    CMAKE_PROBLEMATIC_FILES="\
      CMakeCache.txt \
      CMakeSystem.cmake \
      CMakeCCompiler.cmake \
      CMakeCXXCompiler.cmake \
    
      */CMakeSystem.cmake \
      */CMakeCCompiler.cmake \
      */CMakeCXXCompiler.cmake \
    
      Source/cmConfigure.h \
      Source/CTest/Curl/config.h \
      Utilities/cmexpat/expatConfig.h \
      Utilities/cmexpat/expatDllConfig.h \
      "
    
    
    CMAKE_UNUSED_SOURCES="\
      cmGlobalXCodeGenerator \
      cmLocalXCodeGenerator \
      cmXCodeObject \
      cmXCode21Object \
      cmSourceGroup \
    "
    
    
    CMAKE_CXX_SOURCES="\
    
      cmStandardIncludes \
    
      cmake  \
      cmakemain \
    
      cmCommandArgumentLexer \
      cmCommandArgumentParser \
      cmCommandArgumentParserHelper \
    
      cmCPackPropertiesGenerator \
    
    Ken Martin's avatar
    Ken Martin committed
      cmProperty \
      cmPropertyMap \
      cmPropertyDefinition \
      cmPropertyDefinitionMap \
    
      cmMakeDepend \
      cmMakefile \
    
      cmExportFileGenerator \
      cmExportInstallFileGenerator \
    
      cmExportTryCompileFileGenerator \
    
      cmExportSet \
    
      cmExportSetMap \
    
      cmInstallDirectoryGenerator \
    
      cmGeneratorExpressionDAGChecker \
    
      cmGeneratorExpressionEvaluator \
      cmGeneratorExpressionLexer \
      cmGeneratorExpressionParser \
    
      cmGeneratorExpression \
    
      cmGlobalGenerator \
      cmLocalGenerator \
    
      cmInstalledFile \
    
      cmInstallScriptGenerator \
      cmInstallTargetGenerator \
    
      cmScriptGenerator \
    
      cmSourceFile \
    
      cmSystemTools \
    
      cmTestGenerator \
    
      cmVersion \
    
      cmFileTimeComparison \
    
      cmGlobalUnixMakefileGenerator3 \
      cmLocalUnixMakefileGenerator3 \
    
      cmMakefileExecutableTargetGenerator \
      cmMakefileLibraryTargetGenerator \
      cmMakefileTargetGenerator \
      cmMakefileUtilityTargetGenerator \
    
      cmOSXBundleGenerator \
    
      cmNewLineStyle \
    
      cmBootstrapCommands1 \
      cmBootstrapCommands2 \
    
      cmCommandsForBootstrap \
    
      cmCustomCommand \
    
      cmCustomCommandGenerator \
    
      cmCacheManager \
      cmListFileCache \
    
      cmOrderDirectories \
    
      cmComputeTargetDepends \
    
      cmComputeComponentGraph \
    
      cmExprLexer \
      cmExprParser \
      cmExprParserHelper \
    
      cmGlobalNinjaGenerator \
      cmLocalNinjaGenerator \
      cmNinjaTargetGenerator \
      cmNinjaNormalTargetGenerator \
      cmNinjaUtilityTargetGenerator \
    
    if ${cmake_system_mingw}; then
      CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
        cmGlobalMSYSMakefileGenerator \
    
        cmGlobalMinGWMakefileGenerator"
    
    CMAKE_C_SOURCES="\
      cmListFileLexer \
      "
    
    
    if ${cmake_system_mingw}; then
      KWSYS_C_SOURCES="\
    
        EncodingC \
    
        ProcessWin32 \
    
        EncodingC \
    
        ProcessUNIX \
    
    
    KWSYS_CXX_SOURCES="\
    
      Directory \
    
      EncodingCXX \
    
      Glob \
    
      RegularExpression \
      SystemTools"
    
    KWSYS_FILES="\
    
      Directory.hxx \
    
      Encoding.h \
      Encoding.hxx \
      FStream.hxx \
    
      Glob.hxx \
    
      Process.h \
      RegularExpression.hxx \
    
      System.h \
    
      SystemTools.hxx"
    
    
      fstream \
      iosfwd \
      iostream \
      sstream"
    
    
    # Display CMake bootstrap usage
    
    cmake_usage()
    {
    
    Usage: '"$0"' [<options>...] [-- <cmake-options>...]
    
    Options: [defaults in brackets after descriptions]
    Configuration:
      --help                  print this message
    
      --version               only print version information
    
      --verbose               display more information
    
      --parallel=n            bootstrap cmake in parallel, where n is
                              number of nodes [1]
    
      --enable-ccache         Enable ccache when building cmake
    
      --init=FILE             load FILE as script to populate cache
    
      --system-libs           use all system-installed third-party libraries
    
      --no-system-libs        use all cmake-provided third-party libraries
    
      --system-curl           use system-installed curl library
      --no-system-curl        use cmake-provided curl library (default)
      --system-expat          use system-installed expat library
      --no-system-expat       use cmake-provided expat library (default)
      --system-zlib           use system-installed zlib library
      --no-system-zlib        use cmake-provided zlib library (default)
      --system-bzip2          use system-installed bzip2 library
      --no-system-bzip2       use cmake-provided bzip2 library (default)
      --system-libarchive     use system-installed libarchive library
      --no-system-libarchive  use cmake-provided libarchive library (default)
    
    
      --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
      --no-qt-gui             do not build the Qt-based GUI (default)
      --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt
    
      --sphinx-man            build man pages with Sphinx
      --sphinx-html           build html help with Sphinx
      --sphinx-build=<sb>     use <sb> as the sphinx-build executable
    
    
    Directory and file names:
    
      --prefix=PREFIX         install files in tree rooted at PREFIX
    
                              ['"${cmake_default_prefix}"']
    
      --datadir=DIR           install data files in PREFIX/DIR
    
                              ['"${cmake_data_dir_default}"']
    
      --docdir=DIR            install documentation files in PREFIX/DIR
    
                              ['"${cmake_doc_dir_default}"']
    
      --mandir=DIR            install man pages files in PREFIX/DIR/manN
    
                              ['"${cmake_man_dir_default}"']
    
    # Display CMake bootstrap usage
    
      echo "CMake ${cmake_version}, ${cmake_copyright}"
    
    }
    
    # Display CMake bootstrap error, display the log file and exit
    
    cmake_error()
    {
    
      echo "---------------------------------------------"
    
      echo "Error when bootstrapping CMake:"
    
      echo "$*"
      echo "---------------------------------------------"
      if [ -f cmake_bootstrap.log ]; then
    
        echo "Log of errors: `pwd`/cmake_bootstrap.log"
        #cat cmake_bootstrap.log
    
        echo "---------------------------------------------"
      fi
    
    # Replace KWSYS_NAMESPACE with cmsys
    cmake_replace_string ()
    {
      INFILE="$1"
      OUTFILE="$2"
      SEARCHFOR="$3"
      REPLACEWITH="$4"
    
      if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
    
        cat "${INFILE}" |
    
          sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
        if [ -f "${OUTFILE}${_tmp}" ]; then
          if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
    
            rm -f "${OUTFILE}${_tmp}"
    
            mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
    
        cmake_error 1 "Cannot find file ${INFILE}"
    
    cmake_kwsys_config_replace_string ()
    {
      INFILE="$1"
      OUTFILE="$2"
      shift 2
      APPEND="$*"
    
      if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
        echo "${APPEND}" > "${OUTFILE}${_tmp}"
    
        cat "${INFILE}" |
    
          sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
                    s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
    
                    s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
                    s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
    
                    s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
    
                    s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
    
                    s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
    
                    s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
                    s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
                    s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
    
                    s/@KWSYS_IOS_HAVE_BINARY@/${KWSYS_IOS_HAVE_BINARY}/g;
    
                    s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
    
                    s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
                    s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
    
                    s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
    
                    s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
                    s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
                    s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
    
                    s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
    
                    s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
    
                    s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
    
                    s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
    
                    s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
    
                    s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
    
                    s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
    
                    s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
                    s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
                    s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
    
                    s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
    
                    s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}"
        if [ -f "${OUTFILE}${_tmp}" ]; then
          if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
    
            rm -f "${OUTFILE}${_tmp}"
    
            mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
    
          fi
        fi
      else
        cmake_error 2 "Cannot find file ${INFILE}"
      fi
    }
    
    # Write string into a file
    
    cmake_report ()
    {
      FILE=$1
      shift
      echo "$*" >> ${FILE}
    }
    
    
    # Escape spaces in strings
    
    cmake_escape ()
    {
      echo $1 | sed "s/ /\\\\ /g"
    }
    
    
    # Strip prefix from argument
    cmake_arg ()
    {
      echo "$1" | sed "s/^${2-[^=]*=}//"
    }
    
    
    # Write message to the log
    
    cmake_log ()
    {
      echo "$*" >> cmake_bootstrap.log
    }
    
    
    cmake_tmp_file ()
    {
    
      echo "cmake_bootstrap_$$_test"
    
    # Run a compiler test. First argument is compiler, second one are compiler
    # flags, third one is test source file to be compiled
    
    cmake_try_run ()
    {
      COMPILER=$1
      FLAGS=$2
      TESTFILE=$3
      if [ ! -f "${TESTFILE}" ]; then
        echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
        exit 4
      fi
      TMPFILE=`cmake_tmp_file`
      echo "Try: ${COMPILER}"
    
      echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
      echo "----------  file   -----------------------"
    
      cat "${TESTFILE}"
    
      echo "------------------------------------------"
    
      "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
      RES=$?
      if [ "${RES}" -ne "0" ]; then
    
      fi
      if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
    
        echo "Test failed to produce executable"
    
        return 2
      fi
      ./${TMPFILE}
      RES=$?
      rm -f "${TMPFILE}"
      if [ "${RES}" -ne "0" ]; then
    
        echo "Test produced non-zero return code"
    
    # Run a make test. First argument is the make interpreter.
    
    cmake_try_make ()
    {
    
      echo "Try: ${MAKE_PROC}"
    
      RES=$?
      if [ "${RES}" -ne "0" ]; then
    
        echo "${MAKE_PROC} does not work"
        return 1
    
      fi
      if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
        echo "${COMPILER} does not produce output"
        return 2
      fi
      ./test
      RES=$?
      rm -f "test"
      if [ "${RES}" -ne "0" ]; then
        echo "${MAKE_PROC} produces strange executable"
        return 3
      fi
      echo "${MAKE_PROC} works"
      return 0
    }
    
    
    cmake_verbose=
    
    cmake_ccache_enabled=
    
    cmake_prefix_dir="${cmake_default_prefix}"
    
    while test $# != 0; do
      case "$1" in
    
      --prefix=*) dir=`cmake_arg "$1"`
                  cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
      --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
      --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
      --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
      --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
      --init=*) cmake_init_file=`cmake_arg "$1"` ;;
    
      --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
      --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
      --system-bzip2|--system-curl|--system-expat|--system-libarchive|--system-zlib)
    
        lib=`cmake_arg "$1" "--system-"`
        cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
    
      --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-libarchive|--no-system-zlib)
    
        lib=`cmake_arg "$1" "--no-system-"`
        cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
    
      --qt-gui) cmake_bootstrap_qt_gui="1" ;;
      --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
    
      --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
    
      --sphinx-man) cmake_sphinx_man="1" ;;
      --sphinx-html) cmake_sphinx_html="1" ;;
      --sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
    
      --help) cmake_usage ;;
      --version) cmake_version_display ; exit 2 ;;
      --verbose) cmake_verbose=TRUE ;;
      --enable-ccache) cmake_ccache_enabled=TRUE ;;
    
      --) shift; break ;;
    
      *) die "Unknown option: $1" ;;
      esac
      shift
    
    # If verbose, display some information about bootstrap
    
    if [ -n "${cmake_verbose}" ]; then
      echo "---------------------------------------------"
      echo "Source directory: ${cmake_source_dir}"
      echo "Binary directory: ${cmake_binary_dir}"
      echo "Prefix directory: ${cmake_prefix_dir}"
      echo "System:           ${cmake_system}"
    
      if [ "x${cmake_parallel_make}" != "x" ]; then
        echo "Doing parallel make: ${cmake_parallel_make}"
      fi
      echo ""
    
    fi
    
    echo "---------------------------------------------"
    
    # Check for in-source build
    cmake_in_source_build=
    if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
         -f "${cmake_binary_dir}/Source/cmake.h" ]; then
      if [ -n "${cmake_verbose}" ]; then
        echo "Warning: This is an in-source build"
      fi
      cmake_in_source_build=TRUE
    fi
    
    # If this is not an in-source build, then Bootstrap stuff should not exist.
    if [ -z "${cmake_in_source_build}" ]; then
      # Did somebody bootstrap in the source tree?
    
      if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
        cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
    
    Looks like somebody did bootstrap CMake in the source tree, but now you are
    
    trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
    
    directory from the source tree."
      fi
      # Is there a cache in the source tree?
      for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
    
    Will Schroeder's avatar
    Will Schroeder committed
        if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
    
          cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
    Looks like somebody tried to build CMake in the source tree, but now you are
    trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
    from the source tree."
        fi
      done
    fi
    
    
    # Make bootstrap directory
    
    [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
    if [ ! -d "${cmake_bootstrap_dir}" ]; then
    
      cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
    
    fi
    cd "${cmake_bootstrap_dir}"
    
    
    [ -d "cmsys" ] || mkdir "cmsys"
    if [ ! -d "cmsys" ]; then
    
      cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
    
    for a in stl ios; do
      [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
      if [ ! -d "cmsys/${a}" ]; then
        cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
      fi
    done
    
    [ -d "cmIML" ] || mkdir "cmIML"
    if [ ! -d "cmIML" ]; then
      cmake_error 12 "Cannot create directory ${cmake_bootstrap_dir}/cmIML"
    fi
    
    
    # Delete all the bootstrap files
    
    rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
    
    rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
    rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
    
    # If exist compiler flags, set them
    
    cmake_c_flags=${CFLAGS}
    cmake_cxx_flags=${CXXFLAGS}
    
    Bill Hoffman's avatar
    Bill Hoffman committed
    cmake_ld_flags=${LDFLAGS}
    
    # Add Cygwin-specific flags
    if ${cmake_system_cygwin}; then
      cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
    fi
    
    
    # Add CoreFoundation framework on Darwin
    
    if ${cmake_system_darwin}; then
    
      cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
    
    # Add BeOS toolkits...
    if ${cmake_system_beos}; then
      cmake_ld_flags="${LDFLAGS} -lroot -lbe"
    fi
    
    
    # Add Haiku toolkits...
    if ${cmake_system_haiku}; then
      cmake_ld_flags="${LDFLAGS} -lroot -lbe"
    fi
    
    
    if ${cmake_system_linux}; then
      # avoid binutils problem with large binaries, e.g. when building CMake in debug mode
      # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230
      if ${cmake_machine_parisc}; then
    
        cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text._*"
    
    #-----------------------------------------------------------------------------
    # Detect known toolchains on some platforms.
    cmake_toolchains=''
    case "${cmake_system}" in
      *AIX*)   cmake_toolchains='XL GNU' ;;
      *CYGWIN*) cmake_toolchains='GNU' ;;
      *Darwin*) cmake_toolchains='GNU Clang' ;;
      *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
      *MINGW*) cmake_toolchains='GNU' ;;
    esac
    
    # Toolchain compiler name table.
    cmake_toolchain_Clang_CC='clang'
    cmake_toolchain_Clang_CXX='clang++'
    cmake_toolchain_GNU_CC='gcc'
    cmake_toolchain_GNU_CXX='g++'
    cmake_toolchain_PGI_CC='pgcc'
    cmake_toolchain_PGI_CXX='pgCC'
    cmake_toolchain_PathScale_CC='pathcc'
    cmake_toolchain_PathScale_CXX='pathCC'
    cmake_toolchain_XL_CC='xlc'
    cmake_toolchain_XL_CXX='xlC'
    
    cmake_toolchain_try()
    {
      tc="$1"
      TMPFILE=`cmake_tmp_file`
    
      eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
      echo 'int main() { return 0; }' > "${TMPFILE}.c"
      cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
      tc_result_CC="$?"
      rm -f "${TMPFILE}.c"
      test "${tc_result_CC}" = "0" || return 1
    
      eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
      echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
      cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
      tc_result_CXX="$?"
      rm -f "${TMPFILE}.cpp"
      test "${tc_result_CXX}" = "0" || return 1
    
      cmake_toolchain="$tc"
    }
    
    cmake_toolchain_detect()
    {
      cmake_toolchain=
      for tc in ${cmake_toolchains}; do
        echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
        cmake_toolchain_try "$tc" &&
        echo "Found $tc toolchain" &&
        break
      done
    }
    
    if [ -z "${CC}" -a -z "${CXX}" ]; then
      cmake_toolchain_detect
    fi
    
    #-----------------------------------------------------------------------------
    
    # Test C compiler
    cmake_c_compiler=
    
    
    # If CC is set, use that for compiler, otherwise use list of known compilers
    
    if [ -n "${cmake_toolchain}" ]; then
      eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
    elif [ -n "${CC}" ]; then
    
      cmake_c_compilers="${CC}"
    else
      cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
    fi
    
    
    # Check if C compiler works
    
    TMPFILE=`cmake_tmp_file`
    
    #ifdef __cplusplus
    # error "The CMAKE_C_COMPILER is set to a C++ compiler"
    
    #include<stdio.h>
    
    #if defined(__CLASSIC_C__)
    
    int main(argc, argv)
      int argc;
      char* argv[];
    #else
    
    Andy Cedilnik's avatar
    Andy Cedilnik committed
    int main(int argc, char* argv[])
    
      printf("%d%c", (argv != 0), (char)0x0a);
    
    Andy Cedilnik's avatar
    Andy Cedilnik committed
      return argc-1;
    
    ' > "${TMPFILE}.c"
    
    for a in ${cmake_c_compilers}; do
    
      if [ -z "${cmake_c_compiler}" ] && \
        cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
    
        cmake_c_compiler="${a}"
      fi
    done
    rm -f "${TMPFILE}.c"
    
    if [ -z "${cmake_c_compiler}" ]; then
    
      cmake_error 6 "Cannot find appropriate C compiler on this system.
    
    Bill Hoffman's avatar
    Bill Hoffman committed
    Please specify one using environment variable CC.
    See cmake_bootstrap.log for compilers attempted.
    "
    
    fi
    echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
    
    
    #-----------------------------------------------------------------------------
    
    # Test CXX compiler
    cmake_cxx_compiler=
    
    # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
    
    
    # If CC is set, use that for compiler, otherwise use list of known compilers
    
    if [ -n "${cmake_toolchain}" ]; then
      eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
    elif [ -n "${CXX}" ]; then
    
      cmake_cxx_compilers="${CXX}"
    else
      cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
    fi
    
    
    # Check if C++ compiler works
    
    TMPFILE=`cmake_tmp_file`
    
    #if defined(TEST1)
    # include <iostream>
    #else
    # include <iostream.h>
    #endif
    
    
    class NeedCXX
    
    {
    public:
      NeedCXX() { this->Foo = 1; }
      int GetFoo() { return this->Foo; }
    private:
      int Foo;
    };
    
    #ifdef TEST3
      cout << c.GetFoo() << endl;
    #else
      std::cout << c.GetFoo() << std::endl;
    #endif
    
    ' > "${TMPFILE}.cxx"
    
    for a in ${cmake_cxx_compilers}; do
    
      for b in 1 2 3; do
        if [ -z "${cmake_cxx_compiler}" ] && \
          cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
          cmake_cxx_compiler="${a}"
        fi
      done
    
    done
    rm -f "${TMPFILE}.cxx"
    
    if [ -z "${cmake_cxx_compiler}" ]; then
    
      cmake_error 7 "Cannot find appropriate C++ compiler on this system.
    
    Bill Hoffman's avatar
    Bill Hoffman committed
    Please specify one using environment variable CXX.
    See cmake_bootstrap.log for compilers attempted."
    
    fi
    echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
    
    
    #-----------------------------------------------------------------------------
    
    # Test Make
    
    cmake_make_processor=
    
    
    # If MAKE is set, use that for make processor, otherwise use list of known make
    
    if [ -n "${MAKE}" ]; then
      cmake_make_processors="${MAKE}"
    else
      cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
    fi
    
    TMPFILE="`cmake_tmp_file`_dir"
    rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
    mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
    cd "${cmake_bootstrap_dir}/${TMPFILE}"
    
    test: test.c
    
    	"'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
    
    '>"Makefile"
    echo '
    
    #include <stdio.h>
    
    int main(){ printf("1%c", (char)0x0a); return 0; }
    
    cmake_original_make_flags="${cmake_make_flags}"
    
    if [ "x${cmake_parallel_make}" != "x" ]; then
      cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
    fi
    
    for a in ${cmake_make_processors}; do
    
      if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
    
        cmake_make_processor="${a}"
      fi
    done
    
    cmake_full_make_flags="${cmake_make_flags}"
    if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
      if [ -z "${cmake_make_processor}" ]; then
        cmake_make_flags="${cmake_original_make_flags}"
        for a in ${cmake_make_processors}; do
    
          if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
    
            cmake_make_processor="${a}"
          fi
        done
      fi
    fi
    
    cd "${cmake_bootstrap_dir}"
    
    
    if [ -z "${cmake_make_processor}" ]; then
    
      cmake_error 8 "Cannot find appropriate Makefile processor on this system.
    
    Please specify one using environment variable MAKE."
    fi
    
    rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
    
    echo "Makefile processor on this system is: ${cmake_make_processor}"
    if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
      echo "---------------------------------------------"
      echo "Makefile processor ${cmake_make_processor} does not support parallel build"
      echo "---------------------------------------------"
    fi
    
    # Ok, we have CC, CXX, and MAKE.
    
    
    # Test C++ compiler features
    
    #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
    #include <iostream>
    int main() { std::cout << "This is GNU" << std::endl; return 0;}
    #endif
    
    ' > ${TMPFILE}.cxx
    
    cmake_cxx_compiler_is_gnu=0
    if cmake_try_run "${cmake_cxx_compiler}" \
      "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
      cmake_cxx_compiler_is_gnu=1