bootstrap 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  1. #!/bin/sh
  2. #=============================================================================
  3. # CMake - Cross Platform Makefile Generator
  4. # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
  5. #
  6. # Distributed under the OSI-approved BSD License (the "License");
  7. # see accompanying file Copyright.txt for details.
  8. #
  9. # This software is distributed WITHOUT ANY WARRANTY; without even the
  10. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. # See the License for more information.
  12. #=============================================================================
  13. die() {
  14. echo "$@" 1>&2 ; exit 1
  15. }
  16. # Version number extraction function.
  17. cmake_version_component()
  18. {
  19. cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
  20. /^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
  21. "
  22. }
  23. # Install destination extraction function.
  24. cmake_install_dest_default()
  25. {
  26. cat "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake" | sed -n '
  27. /^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ {
  28. s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/
  29. s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/
  30. s/${CMake_VERSION_MINOR}/'"${cmake_version_minor}"'/
  31. s/${CMake_VERSION_PATCH}/'"${cmake_version_patch}"'/
  32. p
  33. q
  34. }
  35. '
  36. }
  37. cmake_toupper()
  38. {
  39. echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
  40. }
  41. # Detect system and directory information.
  42. cmake_system=`uname`
  43. cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
  44. cmake_binary_dir=`pwd`
  45. # Load version information.
  46. cmake_version_major="`cmake_version_component MAJOR`"
  47. cmake_version_minor="`cmake_version_component MINOR`"
  48. cmake_version_patch="`cmake_version_component PATCH`"
  49. cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
  50. cmake_version_rc="`cmake_version_component RC`"
  51. if [ "$cmake_version_rc" != "" ]; then
  52. cmake_version="${cmake_version}-rc${cmake_version_rc}"
  53. fi
  54. cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`"
  55. cmake_data_dir_keyword="OTHER"
  56. cmake_doc_dir_keyword="OTHER"
  57. cmake_man_dir_keyword="OTHER"
  58. cmake_data_dir=""
  59. cmake_doc_dir=""
  60. cmake_man_dir=""
  61. cmake_init_file=""
  62. cmake_bootstrap_system_libs=""
  63. cmake_bootstrap_qt_gui=""
  64. cmake_bootstrap_qt_qmake=""
  65. cmake_sphinx_man=""
  66. cmake_sphinx_html=""
  67. cmake_sphinx_qthelp=""
  68. cmake_sphinx_build=""
  69. cmake_sphinx_flags=""
  70. # Determine whether this is a Cygwin environment.
  71. if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
  72. cmake_system_cygwin=true
  73. cmake_doc_dir_keyword="CYGWIN"
  74. cmake_man_dir_keyword="CYGWIN"
  75. else
  76. cmake_system_cygwin=false
  77. fi
  78. # Determine whether this is a MinGW environment.
  79. if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
  80. cmake_system_mingw=true
  81. else
  82. cmake_system_mingw=false
  83. fi
  84. # Determine whether this is OS X
  85. if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
  86. cmake_system_darwin=true
  87. else
  88. cmake_system_darwin=false
  89. fi
  90. # Determine whether this is BeOS
  91. if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
  92. cmake_system_beos=true
  93. cmake_doc_dir_keyword="HAIKU"
  94. cmake_man_dir_keyword="HAIKU"
  95. else
  96. cmake_system_beos=false
  97. fi
  98. # Determine whether this is Haiku
  99. if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
  100. cmake_system_haiku=true
  101. cmake_doc_dir_keyword="HAIKU"
  102. cmake_man_dir_keyword="HAIKU"
  103. else
  104. cmake_system_haiku=false
  105. fi
  106. # Determine whether this is OpenVMS
  107. if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
  108. cmake_system_openvms=true
  109. else
  110. cmake_system_openvms=false
  111. fi
  112. # Determine whether this is HP-UX
  113. if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then
  114. cmake_system_hpux=true
  115. else
  116. cmake_system_hpux=false
  117. fi
  118. # Determine whether this is Linux
  119. if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
  120. cmake_system_linux=true
  121. else
  122. cmake_system_linux=false
  123. fi
  124. # Determine whether this is a PA-RISC machine
  125. # This only works for Linux or HP-UX, not other PA-RISC OSs (BSD maybe?). Also
  126. # may falsely detect parisc on HP-UX m68k
  127. cmake_machine_parisc=false
  128. if ${cmake_system_linux}; then
  129. if uname -m | grep parisc >/dev/null 2>&1; then
  130. cmake_machine_parisc=true
  131. fi
  132. elif ${cmake_system_hpux}; then
  133. if uname -m | grep ia64 >/dev/null 2>&1; then : ; else
  134. cmake_machine_parisc=true
  135. fi
  136. fi
  137. # Choose the generator to use for bootstrapping.
  138. if ${cmake_system_mingw}; then
  139. # Bootstrapping from an MSYS prompt.
  140. cmake_bootstrap_generator="MSYS Makefiles"
  141. else
  142. # Bootstrapping from a standard UNIX prompt.
  143. cmake_bootstrap_generator="Unix Makefiles"
  144. fi
  145. # Choose tools and extensions for this platform.
  146. if ${cmake_system_openvms}; then
  147. _tmp="_tmp"
  148. _cmk="_cmk"
  149. _diff=`which diff`
  150. else
  151. _tmp=".tmp"
  152. _cmk=".cmk"
  153. _diff="diff"
  154. fi
  155. # Construct bootstrap directory name.
  156. cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
  157. # Helper function to fix windows paths.
  158. case "${cmake_system}" in
  159. *MINGW*)
  160. cmake_fix_slashes()
  161. {
  162. cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
  163. }
  164. ;;
  165. *)
  166. cmake_fix_slashes()
  167. {
  168. echo "$1" | sed 's/\\/\//g'
  169. }
  170. ;;
  171. esac
  172. # Choose the default install prefix.
  173. if ${cmake_system_mingw}; then
  174. if [ "x${PROGRAMFILES}" != "x" ]; then
  175. cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
  176. elif [ "x${ProgramFiles}" != "x" ]; then
  177. cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
  178. elif [ "x${SYSTEMDRIVE}" != "x" ]; then
  179. cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
  180. elif [ "x${SystemDrive}" != "x" ]; then
  181. cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
  182. else
  183. cmake_default_prefix="c:/Program Files/CMake"
  184. fi
  185. elif ${cmake_system_haiku}; then
  186. cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
  187. else
  188. cmake_default_prefix="/usr/local"
  189. fi
  190. # Lookup default install destinations.
  191. cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`"
  192. cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`"
  193. cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`"
  194. CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
  195. CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
  196. CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
  197. CMAKE_PROBLEMATIC_FILES="\
  198. CMakeCache.txt \
  199. CMakeSystem.cmake \
  200. CMakeCCompiler.cmake \
  201. CMakeCXXCompiler.cmake \
  202. */CMakeSystem.cmake \
  203. */CMakeCCompiler.cmake \
  204. */CMakeCXXCompiler.cmake \
  205. Source/cmConfigure.h \
  206. Source/CTest/Curl/config.h \
  207. Utilities/cmexpat/expatConfig.h \
  208. Utilities/cmexpat/expatDllConfig.h \
  209. "
  210. CMAKE_UNUSED_SOURCES="\
  211. cmGlobalXCodeGenerator \
  212. cmLocalXCodeGenerator \
  213. cmXCodeObject \
  214. cmXCode21Object \
  215. cmSourceGroup \
  216. "
  217. CMAKE_CXX_SOURCES="\
  218. cmake \
  219. cmakemain \
  220. cmcmd \
  221. cmCommandArgumentLexer \
  222. cmCommandArgumentParser \
  223. cmCommandArgumentParserHelper \
  224. cmCommonTargetGenerator \
  225. cmCPackPropertiesGenerator \
  226. cmDefinitions \
  227. cmDepends \
  228. cmDependsC \
  229. cmDocumentationFormatter \
  230. cmPolicies \
  231. cmProperty \
  232. cmPropertyMap \
  233. cmPropertyDefinition \
  234. cmPropertyDefinitionMap \
  235. cmMakefile \
  236. cmExportBuildFileGenerator \
  237. cmExportFileGenerator \
  238. cmExportInstallFileGenerator \
  239. cmExportTryCompileFileGenerator \
  240. cmExportSet \
  241. cmExportSetMap \
  242. cmExternalMakefileProjectGenerator \
  243. cmGeneratorExpressionEvaluationFile \
  244. cmGeneratedFileStream \
  245. cmGeneratorTarget \
  246. cmGeneratorExpressionContext \
  247. cmGeneratorExpressionDAGChecker \
  248. cmGeneratorExpressionEvaluator \
  249. cmGeneratorExpressionLexer \
  250. cmGeneratorExpressionNode \
  251. cmGeneratorExpressionParser \
  252. cmGeneratorExpression \
  253. cmGlobalCommonGenerator \
  254. cmGlobalGenerator \
  255. cmInstallDirectoryGenerator \
  256. cmLocalCommonGenerator \
  257. cmLocalGenerator \
  258. cmInstalledFile \
  259. cmInstallGenerator \
  260. cmInstallExportGenerator \
  261. cmInstallFilesGenerator \
  262. cmInstallScriptGenerator \
  263. cmInstallTargetGenerator \
  264. cmScriptGenerator \
  265. cmSourceFile \
  266. cmSourceFileLocation \
  267. cmState \
  268. cmSystemTools \
  269. cmTestGenerator \
  270. cmVersion \
  271. cmFileTimeComparison \
  272. cmGlobalUnixMakefileGenerator3 \
  273. cmLocalUnixMakefileGenerator3 \
  274. cmMakefileExecutableTargetGenerator \
  275. cmMakefileLibraryTargetGenerator \
  276. cmMakefileTargetGenerator \
  277. cmMakefileUtilityTargetGenerator \
  278. cmOutputConverter \
  279. cmOSXBundleGenerator \
  280. cmNewLineStyle \
  281. cmBootstrapCommands1 \
  282. cmBootstrapCommands2 \
  283. cmCommandsForBootstrap \
  284. cmTarget \
  285. cmTest \
  286. cmCustomCommand \
  287. cmCustomCommandGenerator \
  288. cmCacheManager \
  289. cmListFileCache \
  290. cmComputeLinkDepends \
  291. cmComputeLinkInformation \
  292. cmOrderDirectories \
  293. cmComputeTargetDepends \
  294. cmComputeComponentGraph \
  295. cmExprLexer \
  296. cmExprParser \
  297. cmExprParserHelper \
  298. "
  299. if ${cmake_system_mingw}; then
  300. CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
  301. cmGlobalMSYSMakefileGenerator \
  302. cmGlobalMinGWMakefileGenerator"
  303. fi
  304. CMAKE_C_SOURCES="\
  305. cmListFileLexer \
  306. "
  307. if ${cmake_system_mingw}; then
  308. KWSYS_C_SOURCES="\
  309. EncodingC \
  310. ProcessWin32 \
  311. String \
  312. System \
  313. Terminal"
  314. else
  315. KWSYS_C_SOURCES="\
  316. EncodingC \
  317. ProcessUNIX \
  318. String \
  319. System \
  320. Terminal"
  321. fi
  322. KWSYS_CXX_SOURCES="\
  323. Directory \
  324. EncodingCXX \
  325. FStream \
  326. Glob \
  327. RegularExpression \
  328. SystemTools"
  329. KWSYS_FILES="\
  330. auto_ptr.hxx \
  331. Directory.hxx \
  332. Encoding.h \
  333. Encoding.hxx \
  334. FStream.hxx \
  335. Glob.hxx \
  336. Process.h \
  337. RegularExpression.hxx \
  338. String.h \
  339. String.hxx \
  340. System.h \
  341. SystemTools.hxx \
  342. Terminal.h"
  343. KWIML_FILES='
  344. ABI.h
  345. INT.h
  346. '
  347. # Display CMake bootstrap usage
  348. cmake_usage()
  349. {
  350. echo '
  351. Usage: '"$0"' [<options>...] [-- <cmake-options>...]
  352. Options: [defaults in brackets after descriptions]
  353. Configuration:
  354. --help print this message
  355. --version only print version information
  356. --verbose display more information
  357. --parallel=n bootstrap cmake in parallel, where n is
  358. number of nodes [1]
  359. --enable-ccache Enable ccache when building cmake
  360. --init=FILE load FILE as script to populate cache
  361. --system-libs use all system-installed third-party libraries
  362. (for use only by package maintainers)
  363. --no-system-libs use all cmake-provided third-party libraries
  364. (default)
  365. --system-curl use system-installed curl library
  366. --no-system-curl use cmake-provided curl library (default)
  367. --system-expat use system-installed expat library
  368. --no-system-expat use cmake-provided expat library (default)
  369. --system-jsoncpp use system-installed jsoncpp library
  370. --no-system-jsoncpp use cmake-provided jsoncpp library (default)
  371. --system-zlib use system-installed zlib library
  372. --no-system-zlib use cmake-provided zlib library (default)
  373. --system-bzip2 use system-installed bzip2 library
  374. --no-system-bzip2 use cmake-provided bzip2 library (default)
  375. --system-libarchive use system-installed libarchive library
  376. --no-system-libarchive use cmake-provided libarchive library (default)
  377. --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
  378. --no-qt-gui do not build the Qt-based GUI (default)
  379. --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
  380. --sphinx-man build man pages with Sphinx
  381. --sphinx-html build html help with Sphinx
  382. --sphinx-qthelp build qch help with Sphinx
  383. --sphinx-build=<sb> use <sb> as the sphinx-build executable
  384. --sphinx-flags=<flags> pass <flags> to sphinx-build executable
  385. Directory and file names:
  386. --prefix=PREFIX install files in tree rooted at PREFIX
  387. ['"${cmake_default_prefix}"']
  388. --datadir=DIR install data files in PREFIX/DIR
  389. ['"${cmake_data_dir_default}"']
  390. --docdir=DIR install documentation files in PREFIX/DIR
  391. ['"${cmake_doc_dir_default}"']
  392. --mandir=DIR install man pages files in PREFIX/DIR/manN
  393. ['"${cmake_man_dir_default}"']
  394. '
  395. exit 10
  396. }
  397. # Display CMake bootstrap usage
  398. cmake_version_display()
  399. {
  400. echo "CMake ${cmake_version}, ${cmake_copyright}"
  401. }
  402. # Display CMake bootstrap error, display the log file and exit
  403. cmake_error()
  404. {
  405. res=$1
  406. shift 1
  407. echo "---------------------------------------------"
  408. echo "Error when bootstrapping CMake:"
  409. echo "$*"
  410. echo "---------------------------------------------"
  411. if [ -f cmake_bootstrap.log ]; then
  412. echo "Log of errors: `pwd`/cmake_bootstrap.log"
  413. #cat cmake_bootstrap.log
  414. echo "---------------------------------------------"
  415. fi
  416. exit ${res}
  417. }
  418. # Replace KWSYS_NAMESPACE with cmsys
  419. cmake_replace_string ()
  420. {
  421. INFILE="$1"
  422. OUTFILE="$2"
  423. SEARCHFOR="$3"
  424. REPLACEWITH="$4"
  425. if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
  426. cat "${INFILE}" |
  427. sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
  428. if [ -f "${OUTFILE}${_tmp}" ]; then
  429. if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
  430. #echo "Files are the same"
  431. rm -f "${OUTFILE}${_tmp}"
  432. else
  433. mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
  434. fi
  435. fi
  436. else
  437. cmake_error 1 "Cannot find file ${INFILE}"
  438. fi
  439. }
  440. cmake_kwsys_config_replace_string ()
  441. {
  442. INFILE="$1"
  443. OUTFILE="$2"
  444. shift 2
  445. APPEND="$*"
  446. if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
  447. echo "${APPEND}" > "${OUTFILE}${_tmp}"
  448. cat "${INFILE}" |
  449. sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
  450. s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
  451. s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
  452. s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
  453. s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
  454. s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
  455. }" >> "${OUTFILE}${_tmp}"
  456. if [ -f "${OUTFILE}${_tmp}" ]; then
  457. if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
  458. #echo "Files are the same"
  459. rm -f "${OUTFILE}${_tmp}"
  460. else
  461. mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
  462. fi
  463. fi
  464. else
  465. cmake_error 2 "Cannot find file ${INFILE}"
  466. fi
  467. }
  468. # Write string into a file
  469. cmake_report ()
  470. {
  471. FILE=$1
  472. shift
  473. echo "$*" >> ${FILE}
  474. }
  475. # Escape spaces in strings
  476. cmake_escape ()
  477. {
  478. echo $1 | sed "s/ /\\\\ /g"
  479. }
  480. # Strip prefix from argument
  481. cmake_arg ()
  482. {
  483. echo "$1" | sed "s/^${2-[^=]*=}//"
  484. }
  485. # Write message to the log
  486. cmake_log ()
  487. {
  488. echo "$*" >> cmake_bootstrap.log
  489. }
  490. # Return temp file
  491. cmake_tmp_file ()
  492. {
  493. echo "cmake_bootstrap_$$_test"
  494. }
  495. # Run a compiler test. First argument is compiler, second one are compiler
  496. # flags, third one is test source file to be compiled
  497. cmake_try_run ()
  498. {
  499. COMPILER=$1
  500. FLAGS=$2
  501. TESTFILE=$3
  502. if [ ! -f "${TESTFILE}" ]; then
  503. echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
  504. exit 4
  505. fi
  506. TMPFILE=`cmake_tmp_file`
  507. echo "Try: ${COMPILER}"
  508. echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  509. echo "---------- file -----------------------"
  510. cat "${TESTFILE}"
  511. echo "------------------------------------------"
  512. "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  513. RES=$?
  514. if [ "${RES}" -ne "0" ]; then
  515. echo "Test failed to compile"
  516. return 1
  517. fi
  518. if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
  519. echo "Test failed to produce executable"
  520. return 2
  521. fi
  522. ./${TMPFILE}
  523. RES=$?
  524. rm -f "${TMPFILE}"
  525. if [ "${RES}" -ne "0" ]; then
  526. echo "Test produced non-zero return code"
  527. return 3
  528. fi
  529. echo "Test succeeded"
  530. return 0
  531. }
  532. # Run a make test. First argument is the make interpreter.
  533. cmake_try_make ()
  534. {
  535. MAKE_PROC="$1"
  536. MAKE_FLAGS="$2"
  537. echo "Try: ${MAKE_PROC}"
  538. "${MAKE_PROC}" ${MAKE_FLAGS}
  539. RES=$?
  540. if [ "${RES}" -ne "0" ]; then
  541. echo "${MAKE_PROC} does not work"
  542. return 1
  543. fi
  544. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  545. echo "${COMPILER} does not produce output"
  546. return 2
  547. fi
  548. ./test
  549. RES=$?
  550. rm -f "test"
  551. if [ "${RES}" -ne "0" ]; then
  552. echo "${MAKE_PROC} produces strange executable"
  553. return 3
  554. fi
  555. echo "${MAKE_PROC} works"
  556. return 0
  557. }
  558. # Parse arguments
  559. cmake_verbose=
  560. cmake_parallel_make=
  561. cmake_ccache_enabled=
  562. cmake_prefix_dir="${cmake_default_prefix}"
  563. while test $# != 0; do
  564. case "$1" in
  565. --prefix=*) dir=`cmake_arg "$1"`
  566. cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
  567. --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
  568. --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
  569. --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
  570. --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
  571. --init=*) cmake_init_file=`cmake_arg "$1"` ;;
  572. --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
  573. --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
  574. --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-zlib)
  575. lib=`cmake_arg "$1" "--system-"`
  576. cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
  577. --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-zlib)
  578. lib=`cmake_arg "$1" "--no-system-"`
  579. cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
  580. --qt-gui) cmake_bootstrap_qt_gui="1" ;;
  581. --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
  582. --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
  583. --sphinx-man) cmake_sphinx_man="1" ;;
  584. --sphinx-html) cmake_sphinx_html="1" ;;
  585. --sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
  586. --sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
  587. --sphinx-flags=*) cmake_sphinx_flags=`cmake_arg "$1"` ;;
  588. --help) cmake_usage ;;
  589. --version) cmake_version_display ; exit 2 ;;
  590. --verbose) cmake_verbose=TRUE ;;
  591. --enable-ccache) cmake_ccache_enabled=TRUE ;;
  592. --) shift; break ;;
  593. *) die "Unknown option: $1" ;;
  594. esac
  595. shift
  596. done
  597. # If verbose, display some information about bootstrap
  598. if [ -n "${cmake_verbose}" ]; then
  599. echo "---------------------------------------------"
  600. echo "Source directory: ${cmake_source_dir}"
  601. echo "Binary directory: ${cmake_binary_dir}"
  602. echo "Prefix directory: ${cmake_prefix_dir}"
  603. echo "System: ${cmake_system}"
  604. if [ "x${cmake_parallel_make}" != "x" ]; then
  605. echo "Doing parallel make: ${cmake_parallel_make}"
  606. fi
  607. echo ""
  608. fi
  609. echo "---------------------------------------------"
  610. # Get CMake version
  611. echo "`cmake_version_display`"
  612. # Check for in-source build
  613. cmake_in_source_build=
  614. if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
  615. -f "${cmake_binary_dir}/Source/cmake.h" ]; then
  616. if [ -n "${cmake_verbose}" ]; then
  617. echo "Warning: This is an in-source build"
  618. fi
  619. cmake_in_source_build=TRUE
  620. fi
  621. # If this is not an in-source build, then Bootstrap stuff should not exist.
  622. if [ -z "${cmake_in_source_build}" ]; then
  623. # Did somebody bootstrap in the source tree?
  624. if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
  625. cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
  626. Looks like somebody did bootstrap CMake in the source tree, but now you are
  627. trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
  628. directory from the source tree."
  629. fi
  630. # Is there a cache in the source tree?
  631. for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
  632. if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
  633. cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
  634. Looks like somebody tried to build CMake in the source tree, but now you are
  635. trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
  636. from the source tree."
  637. fi
  638. done
  639. fi
  640. # Make bootstrap directory
  641. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  642. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  643. cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  644. fi
  645. cd "${cmake_bootstrap_dir}"
  646. [ -d "cmsys" ] || mkdir "cmsys"
  647. if [ ! -d "cmsys" ]; then
  648. cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  649. fi
  650. for a in stl ios; do
  651. [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
  652. if [ ! -d "cmsys/${a}" ]; then
  653. cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
  654. fi
  655. done
  656. [ -d "cmIML" ] || mkdir "cmIML"
  657. if [ ! -d "cmIML" ]; then
  658. cmake_error 12 "Cannot create directory ${cmake_bootstrap_dir}/cmIML"
  659. fi
  660. # Delete all the bootstrap files
  661. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  662. rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
  663. rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
  664. # If exist compiler flags, set them
  665. cmake_c_flags=${CFLAGS}
  666. cmake_cxx_flags=${CXXFLAGS}
  667. cmake_ld_flags=${LDFLAGS}
  668. # Add Cygwin-specific flags
  669. if ${cmake_system_cygwin}; then
  670. cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
  671. fi
  672. # Add CoreFoundation framework on Darwin
  673. if ${cmake_system_darwin}; then
  674. cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
  675. fi
  676. # Add BeOS toolkits...
  677. if ${cmake_system_beos}; then
  678. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  679. fi
  680. # Add Haiku toolkits...
  681. if ${cmake_system_haiku}; then
  682. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  683. fi
  684. # Workaround for short jump tables on PA-RISC
  685. if ${cmake_machine_parisc}; then
  686. if ${cmake_c_compiler_is_gnu}; then
  687. cmake_c_flags="${CFLAGS} -mlong-calls"
  688. fi
  689. if ${cmake_cxx_compiler_is_gnu}; then
  690. cmake_cxx_flags="${CXXFLAGS} -mlong-calls"
  691. fi
  692. fi
  693. #-----------------------------------------------------------------------------
  694. # Detect known toolchains on some platforms.
  695. cmake_toolchains=''
  696. case "${cmake_system}" in
  697. *AIX*) cmake_toolchains='XL GNU' ;;
  698. *CYGWIN*) cmake_toolchains='GNU' ;;
  699. *Darwin*) cmake_toolchains='GNU Clang' ;;
  700. *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
  701. *MINGW*) cmake_toolchains='GNU' ;;
  702. esac
  703. # Toolchain compiler name table.
  704. cmake_toolchain_Clang_CC='clang'
  705. cmake_toolchain_Clang_CXX='clang++'
  706. cmake_toolchain_GNU_CC='gcc'
  707. cmake_toolchain_GNU_CXX='g++'
  708. cmake_toolchain_PGI_CC='pgcc'
  709. cmake_toolchain_PGI_CXX='pgCC'
  710. cmake_toolchain_PathScale_CC='pathcc'
  711. cmake_toolchain_PathScale_CXX='pathCC'
  712. cmake_toolchain_XL_CC='xlc'
  713. cmake_toolchain_XL_CXX='xlC'
  714. cmake_toolchain_try()
  715. {
  716. tc="$1"
  717. TMPFILE=`cmake_tmp_file`
  718. eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
  719. echo 'int main() { return 0; }' > "${TMPFILE}.c"
  720. cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
  721. tc_result_CC="$?"
  722. rm -f "${TMPFILE}.c"
  723. test "${tc_result_CC}" = "0" || return 1
  724. eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
  725. echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
  726. cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
  727. tc_result_CXX="$?"
  728. rm -f "${TMPFILE}.cpp"
  729. test "${tc_result_CXX}" = "0" || return 1
  730. cmake_toolchain="$tc"
  731. }
  732. cmake_toolchain_detect()
  733. {
  734. cmake_toolchain=
  735. for tc in ${cmake_toolchains}; do
  736. echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
  737. cmake_toolchain_try "$tc" &&
  738. echo "Found $tc toolchain" &&
  739. break
  740. done
  741. }
  742. if [ -z "${CC}" -a -z "${CXX}" ]; then
  743. cmake_toolchain_detect
  744. fi
  745. #-----------------------------------------------------------------------------
  746. # Test C compiler
  747. cmake_c_compiler=
  748. # If CC is set, use that for compiler, otherwise use list of known compilers
  749. if [ -n "${cmake_toolchain}" ]; then
  750. eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
  751. elif [ -n "${CC}" ]; then
  752. cmake_c_compilers="${CC}"
  753. else
  754. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  755. fi
  756. # Check if C compiler works
  757. TMPFILE=`cmake_tmp_file`
  758. echo '
  759. #ifdef __cplusplus
  760. # error "The CMAKE_C_COMPILER is set to a C++ compiler"
  761. #endif
  762. #include<stdio.h>
  763. #if defined(__CLASSIC_C__)
  764. int main(argc, argv)
  765. int argc;
  766. char* argv[];
  767. #else
  768. int main(int argc, char* argv[])
  769. #endif
  770. {
  771. printf("%d%c", (argv != 0), (char)0x0a);
  772. return argc-1;
  773. }
  774. ' > "${TMPFILE}.c"
  775. for a in ${cmake_c_compilers}; do
  776. if [ -z "${cmake_c_compiler}" ] && \
  777. cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  778. cmake_c_compiler="${a}"
  779. fi
  780. done
  781. rm -f "${TMPFILE}.c"
  782. if [ -z "${cmake_c_compiler}" ]; then
  783. cmake_error 6 "Cannot find appropriate C compiler on this system.
  784. Please specify one using environment variable CC.
  785. See cmake_bootstrap.log for compilers attempted.
  786. "
  787. fi
  788. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  789. #-----------------------------------------------------------------------------
  790. # Test CXX compiler
  791. cmake_cxx_compiler=
  792. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  793. # If CC is set, use that for compiler, otherwise use list of known compilers
  794. if [ -n "${cmake_toolchain}" ]; then
  795. eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
  796. elif [ -n "${CXX}" ]; then
  797. cmake_cxx_compilers="${CXX}"
  798. else
  799. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  800. fi
  801. # Check if C++ compiler works
  802. TMPFILE=`cmake_tmp_file`
  803. echo '
  804. #if defined(TEST1)
  805. # include <iostream>
  806. #else
  807. # include <iostream.h>
  808. #endif
  809. class NeedCXX
  810. {
  811. public:
  812. NeedCXX() { this->Foo = 1; }
  813. int GetFoo() { return this->Foo; }
  814. private:
  815. int Foo;
  816. };
  817. int main()
  818. {
  819. NeedCXX c;
  820. #ifdef TEST3
  821. cout << c.GetFoo() << endl;
  822. #else
  823. std::cout << c.GetFoo() << std::endl;
  824. #endif
  825. return 0;
  826. }
  827. ' > "${TMPFILE}.cxx"
  828. for a in ${cmake_cxx_compilers}; do
  829. for b in 1 2 3; do
  830. if [ -z "${cmake_cxx_compiler}" ] && \
  831. cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  832. cmake_cxx_compiler="${a}"
  833. fi
  834. done
  835. done
  836. rm -f "${TMPFILE}.cxx"
  837. if [ -z "${cmake_cxx_compiler}" ]; then
  838. cmake_error 7 "Cannot find appropriate C++ compiler on this system.
  839. Please specify one using environment variable CXX.
  840. See cmake_bootstrap.log for compilers attempted."
  841. fi
  842. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  843. #-----------------------------------------------------------------------------
  844. # Test Make
  845. cmake_make_processor=
  846. cmake_make_flags=
  847. # If MAKE is set, use that for make processor, otherwise use list of known make
  848. if [ -n "${MAKE}" ]; then
  849. cmake_make_processors="${MAKE}"
  850. else
  851. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  852. fi
  853. TMPFILE="`cmake_tmp_file`_dir"
  854. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  855. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  856. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  857. echo '
  858. test: test.c
  859. "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
  860. '>"Makefile"
  861. echo '
  862. #include <stdio.h>
  863. int main(){ printf("1%c", (char)0x0a); return 0; }
  864. ' > "test.c"
  865. cmake_original_make_flags="${cmake_make_flags}"
  866. if [ "x${cmake_parallel_make}" != "x" ]; then
  867. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  868. fi
  869. for a in ${cmake_make_processors}; do
  870. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  871. cmake_make_processor="${a}"
  872. fi
  873. done
  874. cmake_full_make_flags="${cmake_make_flags}"
  875. if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
  876. if [ -z "${cmake_make_processor}" ]; then
  877. cmake_make_flags="${cmake_original_make_flags}"
  878. for a in ${cmake_make_processors}; do
  879. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  880. cmake_make_processor="${a}"
  881. fi
  882. done
  883. fi
  884. fi
  885. cd "${cmake_bootstrap_dir}"
  886. if [ -z "${cmake_make_processor}" ]; then
  887. cmake_error 8 "Cannot find appropriate Makefile processor on this system.
  888. Please specify one using environment variable MAKE."
  889. fi
  890. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  891. echo "Makefile processor on this system is: ${cmake_make_processor}"
  892. if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
  893. echo "---------------------------------------------"
  894. echo "Makefile processor ${cmake_make_processor} does not support parallel build"
  895. echo "---------------------------------------------"
  896. fi
  897. # Ok, we have CC, CXX, and MAKE.
  898. # Test C++ compiler features
  899. # Are we GCC?
  900. TMPFILE=`cmake_tmp_file`
  901. echo '
  902. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  903. #include <iostream>
  904. int main() { std::cout << "This is GNU" << std::endl; return 0;}
  905. #endif
  906. ' > ${TMPFILE}.cxx
  907. cmake_cxx_compiler_is_gnu=0
  908. if cmake_try_run "${cmake_cxx_compiler}" \
  909. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  910. cmake_cxx_compiler_is_gnu=1
  911. fi
  912. if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
  913. echo "${cmake_cxx_compiler} is GNU compiler"
  914. else
  915. echo "${cmake_cxx_compiler} is not GNU compiler"
  916. fi
  917. rm -f "${TMPFILE}.cxx"
  918. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  919. # Check for non-GNU compiler flags
  920. # If we are on IRIX, check for -LANG:std
  921. cmake_test_flags="-LANG:std"
  922. if [ "x${cmake_system}" = "xIRIX64" ]; then
  923. TMPFILE=`cmake_tmp_file`
  924. echo '
  925. #include <iostream>
  926. int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
  927. ' > ${TMPFILE}.cxx
  928. cmake_need_lang_std=0
  929. if cmake_try_run "${cmake_cxx_compiler}" \
  930. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  931. :
  932. else
  933. if cmake_try_run "${cmake_cxx_compiler}" \
  934. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  935. cmake_need_lang_std=1
  936. fi
  937. fi
  938. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  939. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  940. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  941. else
  942. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  943. fi
  944. rm -f "${TMPFILE}.cxx"
  945. fi
  946. cmake_test_flags=
  947. # If we are on OSF, check for -timplicit_local -no_implicit_include
  948. cmake_test_flags="-timplicit_local -no_implicit_include"
  949. if [ "x${cmake_system}" = "xOSF1" ]; then
  950. TMPFILE=`cmake_tmp_file`
  951. echo '
  952. #include <iostream>
  953. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  954. ' > ${TMPFILE}.cxx
  955. cmake_need_flags=1
  956. if cmake_try_run "${cmake_cxx_compiler}" \
  957. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  958. :
  959. else
  960. cmake_need_flags=0
  961. fi
  962. if [ "x${cmake_need_flags}" = "x1" ]; then
  963. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  964. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  965. else
  966. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  967. fi
  968. rm -f "${TMPFILE}.cxx"
  969. fi
  970. cmake_test_flags=
  971. # If we are on OSF, check for -std strict_ansi -nopure_cname
  972. cmake_test_flags="-std strict_ansi -nopure_cname"
  973. if [ "x${cmake_system}" = "xOSF1" ]; then
  974. TMPFILE=`cmake_tmp_file`
  975. echo '
  976. #include <iostream>
  977. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  978. ' > ${TMPFILE}.cxx
  979. cmake_need_flags=1
  980. if cmake_try_run "${cmake_cxx_compiler}" \
  981. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  982. :
  983. else
  984. cmake_need_flags=0
  985. fi
  986. if [ "x${cmake_need_flags}" = "x1" ]; then
  987. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  988. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  989. else
  990. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  991. fi
  992. rm -f "${TMPFILE}.cxx"
  993. fi
  994. cmake_test_flags=
  995. # If we are on HP-UX, check for -Ae for the C compiler.
  996. if [ "x${cmake_system}" = "xHP-UX" ]; then
  997. cmake_test_flags="-Ae"
  998. TMPFILE=`cmake_tmp_file`
  999. echo '
  1000. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  1001. ' > ${TMPFILE}.c
  1002. cmake_need_Ae=0
  1003. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  1004. :
  1005. else
  1006. if cmake_try_run "${cmake_c_compiler}" \
  1007. "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  1008. cmake_need_Ae=1
  1009. fi
  1010. fi
  1011. if [ "x${cmake_need_Ae}" = "x1" ]; then
  1012. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  1013. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  1014. else
  1015. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  1016. fi
  1017. rm -f "${TMPFILE}.c"
  1018. echo '
  1019. #include <iostream>
  1020. int main(int argc, char** argv) {
  1021. for(int i=0; i < 1; ++i);
  1022. for(int i=0; i < 1; ++i);
  1023. (void)argc; (void)argv; return 0; }
  1024. ' > ${TMPFILE}.cxx
  1025. cmake_need_AAstd98=0
  1026. cmake_test_flags="-AA +hpxstd98"
  1027. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1028. :
  1029. else
  1030. if cmake_try_run "${cmake_cxx_compiler}" \
  1031. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1032. cmake_need_AAstd98=1
  1033. fi
  1034. fi
  1035. if [ "x${cmake_need_AAstd98}" = "x1" ]; then
  1036. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  1037. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  1038. else
  1039. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  1040. fi
  1041. fi
  1042. cmake_test_flags=
  1043. fi
  1044. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  1045. # Are we SolarisStudio?
  1046. TMPFILE=`cmake_tmp_file`
  1047. echo '
  1048. #if defined(__SUNPRO_CC)
  1049. #include <iostream>
  1050. int main() { std::cout << "This is SolarisStudio" << std::endl; return 0;}
  1051. #endif
  1052. ' > ${TMPFILE}.cxx
  1053. cmake_cxx_compiler_is_solarisstudio=0
  1054. if cmake_try_run "${cmake_cxx_compiler}" \
  1055. "${cmake_cxx_flags} " "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1056. cmake_cxx_compiler_is_solarisstudio=1
  1057. fi
  1058. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1059. echo "${cmake_cxx_compiler} is SolarisStudio compiler"
  1060. else
  1061. echo "${cmake_cxx_compiler} is not SolarisStudio compiler"
  1062. fi
  1063. rm -f "${TMPFILE}.cxx"
  1064. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1065. cmake_cxx_flags="${cmake_cxx_flags} -library=stlport4"
  1066. fi
  1067. fi
  1068. # Test for kwsys features
  1069. KWSYS_NAME_IS_KWSYS=0
  1070. KWSYS_BUILD_SHARED=0
  1071. KWSYS_LFS_AVAILABLE=0
  1072. KWSYS_LFS_REQUESTED=0
  1073. KWSYS_STL_HAS_WSTRING=0
  1074. KWSYS_CXX_HAS_SETENV=0
  1075. KWSYS_CXX_HAS_UNSETENV=0
  1076. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
  1077. KWSYS_CXX_HAS_UTIMENSAT=0
  1078. KWSYS_CXX_HAS_UTIMES=0
  1079. if cmake_try_run "${cmake_cxx_compiler}" \
  1080. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
  1081. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1082. KWSYS_CXX_HAS_SETENV=1
  1083. echo "${cmake_cxx_compiler} has setenv"
  1084. else
  1085. echo "${cmake_cxx_compiler} does not have setenv"
  1086. fi
  1087. if cmake_try_run "${cmake_cxx_compiler}" \
  1088. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
  1089. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1090. KWSYS_CXX_HAS_UNSETENV=1
  1091. echo "${cmake_cxx_compiler} has unsetenv"
  1092. else
  1093. echo "${cmake_cxx_compiler} does not have unsetenv"
  1094. fi
  1095. if cmake_try_run "${cmake_cxx_compiler}" \
  1096. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
  1097. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1098. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
  1099. echo "${cmake_cxx_compiler} has environ in stdlib.h"
  1100. else
  1101. echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
  1102. fi
  1103. if cmake_try_run "${cmake_cxx_compiler}" \
  1104. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_WSTRING" \
  1105. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1106. KWSYS_STL_HAS_WSTRING=1
  1107. echo "${cmake_cxx_compiler} has stl wstring"
  1108. else
  1109. echo "${cmake_cxx_compiler} does not have stl wstring"
  1110. fi
  1111. # Just to be safe, let us store compiler and flags to the header file
  1112. cmake_bootstrap_version='$Revision$'
  1113. cmake_compiler_settings_comment="/*
  1114. * Generated by ${cmake_source_dir}/bootstrap
  1115. * Version: ${cmake_bootstrap_version}
  1116. *
  1117. * Source directory: ${cmake_source_dir}
  1118. * Binary directory: ${cmake_bootstrap_dir}
  1119. *
  1120. * C compiler: ${cmake_c_compiler}
  1121. * C flags: ${cmake_c_flags}
  1122. *
  1123. * C++ compiler: ${cmake_cxx_compiler}
  1124. * C++ flags: ${cmake_cxx_flags}
  1125. *
  1126. * Make: ${cmake_make_processor}
  1127. *
  1128. * Sources:
  1129. * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
  1130. * kwSys Sources:
  1131. * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
  1132. */
  1133. "
  1134. cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
  1135. # When bootstrapping on MinGW with MSYS we must convert the source
  1136. # directory to a windows path.
  1137. if ${cmake_system_mingw}; then
  1138. CMAKE_BOOTSTRAP_SOURCE_DIR=`cd "${cmake_source_dir}"; pwd -W`
  1139. CMAKE_BOOTSTRAP_BINARY_DIR=`cd "${cmake_binary_dir}"; pwd -W`
  1140. else
  1141. CMAKE_BOOTSTRAP_SOURCE_DIR="${cmake_source_dir}"
  1142. CMAKE_BOOTSTRAP_BINARY_DIR="${cmake_binary_dir}"
  1143. fi
  1144. # Write CMake version
  1145. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
  1146. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
  1147. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
  1148. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
  1149. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
  1150. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
  1151. cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
  1152. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
  1153. # Regenerate configured headers
  1154. for h in Configure VersionConfig; do
  1155. if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
  1156. rm -f cm${h}.h${_tmp}
  1157. else
  1158. mv -f cm${h}.h${_tmp} cm${h}.h
  1159. fi
  1160. done
  1161. # Prepare KWSYS
  1162. cmake_kwsys_config_replace_string \
  1163. "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
  1164. "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
  1165. "${cmake_compiler_settings_comment}"
  1166. cmake_kwsys_config_replace_string \
  1167. "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  1168. "${cmake_bootstrap_dir}/cmsys/Configure.h" \
  1169. "${cmake_compiler_settings_comment}"
  1170. for a in ${KWSYS_FILES}; do
  1171. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  1172. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  1173. done
  1174. for a in ${KWIML_FILES}; do
  1175. cmake_replace_string "${cmake_source_dir}/Utilities/KWIML/${a}.in" \
  1176. "${cmake_bootstrap_dir}/cmIML/${a}" KWIML cmIML
  1177. done
  1178. # Generate Makefile
  1179. dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  1180. objs=""
  1181. for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
  1182. objs="${objs} ${a}.o"
  1183. done
  1184. # Generate dependencies for cmBootstrapCommands1.cxx
  1185. for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands1.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
  1186. cmBootstrapCommands1Deps="${cmBootstrapCommands1Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
  1187. done
  1188. cmBootstrapCommands1Deps=`echo $cmBootstrapCommands1Deps`
  1189. for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands2.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
  1190. cmBootstrapCommands2Deps="${cmBootstrapCommands2Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
  1191. done
  1192. cmBootstrapCommands2Deps=`echo $cmBootstrapCommands2Deps`
  1193. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  1194. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  1195. fi
  1196. if [ "x${cmake_c_flags}" != "x" ]; then
  1197. cmake_c_flags="${cmake_c_flags} "
  1198. fi
  1199. if [ "x${cmake_cxx_flags}" != "x" ]; then
  1200. cmake_cxx_flags="${cmake_cxx_flags} "
  1201. fi
  1202. cmake_c_flags_String="-DKWSYS_STRING_C"
  1203. if ${cmake_system_mingw}; then
  1204. cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP"
  1205. fi
  1206. cmake_cxx_flags_SystemTools="
  1207. -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
  1208. -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
  1209. -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
  1210. -DKWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
  1211. -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
  1212. "
  1213. cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1214. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1215. cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1216. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1217. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  1218. echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  1219. for a in ${CMAKE_CXX_SOURCES}; do
  1220. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  1221. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1222. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1223. done
  1224. echo "cmBootstrapCommands1.o : $cmBootstrapCommands1Deps" >> "${cmake_bootstrap_dir}/Makefile"
  1225. echo "cmBootstrapCommands2.o : $cmBootstrapCommands2Deps" >> "${cmake_bootstrap_dir}/Makefile"
  1226. for a in ${CMAKE_C_SOURCES}; do
  1227. src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
  1228. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1229. echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1230. done
  1231. for a in ${KWSYS_C_SOURCES}; do
  1232. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  1233. src_flags=`eval echo \\${cmake_c_flags_\${a}}`
  1234. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1235. echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1236. done
  1237. for a in ${KWSYS_CXX_SOURCES}; do
  1238. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  1239. src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
  1240. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1241. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1242. done
  1243. echo '
  1244. rebuild_cache:
  1245. cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
  1246. ' >> "${cmake_bootstrap_dir}/Makefile"
  1247. # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
  1248. echo '
  1249. # Generated by '"${cmake_source_dir}"'/bootstrap
  1250. # Default cmake settings. These may be overridden any settings below.
  1251. set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  1252. set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  1253. set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  1254. set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  1255. ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1256. # Add configuration settings given as command-line options.
  1257. if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
  1258. echo '
  1259. set (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
  1260. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1261. fi
  1262. if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
  1263. echo '
  1264. set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
  1265. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1266. fi
  1267. if [ "x${cmake_sphinx_man}" != "x" ]; then
  1268. echo '
  1269. set (SPHINX_MAN "'"${cmake_sphinx_man}"'" CACHE BOOL "Build man pages with Sphinx" FORCE)
  1270. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1271. fi
  1272. if [ "x${cmake_sphinx_html}" != "x" ]; then
  1273. echo '
  1274. set (SPHINX_HTML "'"${cmake_sphinx_html}"'" CACHE BOOL "Build html help with Sphinx" FORCE)
  1275. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1276. fi
  1277. if [ "x${cmake_sphinx_qthelp}" != "x" ]; then
  1278. echo '
  1279. set (SPHINX_QTHELP "'"${cmake_sphinx_qthelp}"'" CACHE BOOL "Build qch help with Sphinx" FORCE)
  1280. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1281. fi
  1282. if [ "x${cmake_sphinx_build}" != "x" ]; then
  1283. echo '
  1284. set (SPHINX_EXECUTABLE "'"${cmake_sphinx_build}"'" CACHE FILEPATH "Location of Qt sphinx-build" FORCE)
  1285. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1286. fi
  1287. if [ "x${cmake_sphinx_flags}" != "x" ]; then
  1288. echo '
  1289. set (SPHINX_FLAGS [==['"${cmake_sphinx_flags}"']==] CACHE STRING "Flags to pass to sphinx-build" FORCE)
  1290. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1291. fi
  1292. # Add user-specified settings. Handle relative-path case for
  1293. # specification of cmake_init_file.
  1294. (
  1295. cd "${cmake_binary_dir}"
  1296. if [ -f "${cmake_init_file}" ]; then
  1297. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1298. fi
  1299. )
  1300. echo "---------------------------------------------"
  1301. # Run make to build bootstrap cmake
  1302. if [ "x${cmake_parallel_make}" != "x" ]; then
  1303. ${cmake_make_processor} ${cmake_make_flags}
  1304. else
  1305. ${cmake_make_processor}
  1306. fi
  1307. RES=$?
  1308. if [ "${RES}" -ne "0" ]; then
  1309. cmake_error 9 "Problem while running ${cmake_make_processor}"
  1310. fi
  1311. cd "${cmake_binary_dir}"
  1312. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  1313. # build with same compiler and make
  1314. CC="${cmake_c_compiler}"
  1315. CXX="${cmake_cxx_compiler}"
  1316. if [ -n "${cmake_ccache_enabled}" ]; then
  1317. CC="ccache ${CC}"
  1318. CXX="ccache ${CXX}"
  1319. fi
  1320. MAKE="${cmake_make_processor}"
  1321. export CC
  1322. export CXX
  1323. export MAKE
  1324. # Run bootstrap CMake to configure real CMake
  1325. cmake_options="-DCMAKE_BOOTSTRAP=1"
  1326. if [ -n "${cmake_verbose}" ]; then
  1327. cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1"
  1328. fi
  1329. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@"
  1330. RES=$?
  1331. if [ "${RES}" -ne "0" ]; then
  1332. cmake_error 11 "Problem while running initial CMake"
  1333. fi
  1334. echo "---------------------------------------------"
  1335. # And we are done. Now just run make
  1336. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."