bootstrap 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  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. [ -d "cmIML" ] || mkdir "cmIML"
  651. if [ ! -d "cmIML" ]; then
  652. cmake_error 12 "Cannot create directory ${cmake_bootstrap_dir}/cmIML"
  653. fi
  654. # Delete all the bootstrap files
  655. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  656. rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
  657. rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
  658. # If exist compiler flags, set them
  659. cmake_c_flags=${CFLAGS}
  660. cmake_cxx_flags=${CXXFLAGS}
  661. cmake_ld_flags=${LDFLAGS}
  662. # Add Cygwin-specific flags
  663. if ${cmake_system_cygwin}; then
  664. cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
  665. fi
  666. # Add CoreFoundation framework on Darwin
  667. if ${cmake_system_darwin}; then
  668. cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
  669. fi
  670. # Add BeOS toolkits...
  671. if ${cmake_system_beos}; then
  672. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  673. fi
  674. # Add Haiku toolkits...
  675. if ${cmake_system_haiku}; then
  676. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  677. fi
  678. # Workaround for short jump tables on PA-RISC
  679. if ${cmake_machine_parisc}; then
  680. if ${cmake_c_compiler_is_gnu}; then
  681. cmake_c_flags="${CFLAGS} -mlong-calls"
  682. fi
  683. if ${cmake_cxx_compiler_is_gnu}; then
  684. cmake_cxx_flags="${CXXFLAGS} -mlong-calls"
  685. fi
  686. fi
  687. #-----------------------------------------------------------------------------
  688. # Detect known toolchains on some platforms.
  689. cmake_toolchains=''
  690. case "${cmake_system}" in
  691. *AIX*) cmake_toolchains='XL GNU' ;;
  692. *CYGWIN*) cmake_toolchains='GNU' ;;
  693. *Darwin*) cmake_toolchains='GNU Clang' ;;
  694. *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
  695. *MINGW*) cmake_toolchains='GNU' ;;
  696. esac
  697. # Toolchain compiler name table.
  698. cmake_toolchain_Clang_CC='clang'
  699. cmake_toolchain_Clang_CXX='clang++'
  700. cmake_toolchain_GNU_CC='gcc'
  701. cmake_toolchain_GNU_CXX='g++'
  702. cmake_toolchain_PGI_CC='pgcc'
  703. cmake_toolchain_PGI_CXX='pgCC'
  704. cmake_toolchain_PathScale_CC='pathcc'
  705. cmake_toolchain_PathScale_CXX='pathCC'
  706. cmake_toolchain_XL_CC='xlc'
  707. cmake_toolchain_XL_CXX='xlC'
  708. cmake_toolchain_try()
  709. {
  710. tc="$1"
  711. TMPFILE=`cmake_tmp_file`
  712. eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
  713. echo 'int main() { return 0; }' > "${TMPFILE}.c"
  714. cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
  715. tc_result_CC="$?"
  716. rm -f "${TMPFILE}.c"
  717. test "${tc_result_CC}" = "0" || return 1
  718. eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
  719. echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
  720. cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
  721. tc_result_CXX="$?"
  722. rm -f "${TMPFILE}.cpp"
  723. test "${tc_result_CXX}" = "0" || return 1
  724. cmake_toolchain="$tc"
  725. }
  726. cmake_toolchain_detect()
  727. {
  728. cmake_toolchain=
  729. for tc in ${cmake_toolchains}; do
  730. echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
  731. cmake_toolchain_try "$tc" &&
  732. echo "Found $tc toolchain" &&
  733. break
  734. done
  735. }
  736. if [ -z "${CC}" -a -z "${CXX}" ]; then
  737. cmake_toolchain_detect
  738. fi
  739. #-----------------------------------------------------------------------------
  740. # Test C compiler
  741. cmake_c_compiler=
  742. # If CC is set, use that for compiler, otherwise use list of known compilers
  743. if [ -n "${cmake_toolchain}" ]; then
  744. eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
  745. elif [ -n "${CC}" ]; then
  746. cmake_c_compilers="${CC}"
  747. else
  748. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  749. fi
  750. # Check if C compiler works
  751. TMPFILE=`cmake_tmp_file`
  752. echo '
  753. #ifdef __cplusplus
  754. # error "The CMAKE_C_COMPILER is set to a C++ compiler"
  755. #endif
  756. #include<stdio.h>
  757. #if defined(__CLASSIC_C__)
  758. int main(argc, argv)
  759. int argc;
  760. char* argv[];
  761. #else
  762. int main(int argc, char* argv[])
  763. #endif
  764. {
  765. printf("%d%c", (argv != 0), (char)0x0a);
  766. return argc-1;
  767. }
  768. ' > "${TMPFILE}.c"
  769. for a in ${cmake_c_compilers}; do
  770. if [ -z "${cmake_c_compiler}" ] && \
  771. cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  772. cmake_c_compiler="${a}"
  773. fi
  774. done
  775. rm -f "${TMPFILE}.c"
  776. if [ -z "${cmake_c_compiler}" ]; then
  777. cmake_error 6 "Cannot find appropriate C compiler on this system.
  778. Please specify one using environment variable CC.
  779. See cmake_bootstrap.log for compilers attempted.
  780. "
  781. fi
  782. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  783. #-----------------------------------------------------------------------------
  784. # Test CXX compiler
  785. cmake_cxx_compiler=
  786. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  787. # If CC is set, use that for compiler, otherwise use list of known compilers
  788. if [ -n "${cmake_toolchain}" ]; then
  789. eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
  790. elif [ -n "${CXX}" ]; then
  791. cmake_cxx_compilers="${CXX}"
  792. else
  793. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  794. fi
  795. # Check if C++ compiler works
  796. TMPFILE=`cmake_tmp_file`
  797. echo '
  798. #if defined(TEST1)
  799. # include <iostream>
  800. #else
  801. # include <iostream.h>
  802. #endif
  803. class NeedCXX
  804. {
  805. public:
  806. NeedCXX() { this->Foo = 1; }
  807. int GetFoo() { return this->Foo; }
  808. private:
  809. int Foo;
  810. };
  811. int main()
  812. {
  813. NeedCXX c;
  814. #ifdef TEST3
  815. cout << c.GetFoo() << endl;
  816. #else
  817. std::cout << c.GetFoo() << std::endl;
  818. #endif
  819. return 0;
  820. }
  821. ' > "${TMPFILE}.cxx"
  822. for a in ${cmake_cxx_compilers}; do
  823. for b in 1 2 3; do
  824. if [ -z "${cmake_cxx_compiler}" ] && \
  825. cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  826. cmake_cxx_compiler="${a}"
  827. fi
  828. done
  829. done
  830. rm -f "${TMPFILE}.cxx"
  831. if [ -z "${cmake_cxx_compiler}" ]; then
  832. cmake_error 7 "Cannot find appropriate C++ compiler on this system.
  833. Please specify one using environment variable CXX.
  834. See cmake_bootstrap.log for compilers attempted."
  835. fi
  836. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  837. #-----------------------------------------------------------------------------
  838. # Test Make
  839. cmake_make_processor=
  840. cmake_make_flags=
  841. # If MAKE is set, use that for make processor, otherwise use list of known make
  842. if [ -n "${MAKE}" ]; then
  843. cmake_make_processors="${MAKE}"
  844. else
  845. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  846. fi
  847. TMPFILE="`cmake_tmp_file`_dir"
  848. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  849. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  850. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  851. echo '
  852. test: test.c
  853. "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
  854. '>"Makefile"
  855. echo '
  856. #include <stdio.h>
  857. int main(){ printf("1%c", (char)0x0a); return 0; }
  858. ' > "test.c"
  859. cmake_original_make_flags="${cmake_make_flags}"
  860. if [ "x${cmake_parallel_make}" != "x" ]; then
  861. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  862. fi
  863. for a in ${cmake_make_processors}; do
  864. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  865. cmake_make_processor="${a}"
  866. fi
  867. done
  868. cmake_full_make_flags="${cmake_make_flags}"
  869. if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
  870. if [ -z "${cmake_make_processor}" ]; then
  871. cmake_make_flags="${cmake_original_make_flags}"
  872. for a in ${cmake_make_processors}; do
  873. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  874. cmake_make_processor="${a}"
  875. fi
  876. done
  877. fi
  878. fi
  879. cd "${cmake_bootstrap_dir}"
  880. if [ -z "${cmake_make_processor}" ]; then
  881. cmake_error 8 "Cannot find appropriate Makefile processor on this system.
  882. Please specify one using environment variable MAKE."
  883. fi
  884. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  885. echo "Makefile processor on this system is: ${cmake_make_processor}"
  886. if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
  887. echo "---------------------------------------------"
  888. echo "Makefile processor ${cmake_make_processor} does not support parallel build"
  889. echo "---------------------------------------------"
  890. fi
  891. # Ok, we have CC, CXX, and MAKE.
  892. # Test C++ compiler features
  893. # Are we GCC?
  894. TMPFILE=`cmake_tmp_file`
  895. echo '
  896. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  897. #include <iostream>
  898. int main() { std::cout << "This is GNU" << std::endl; return 0;}
  899. #endif
  900. ' > ${TMPFILE}.cxx
  901. cmake_cxx_compiler_is_gnu=0
  902. if cmake_try_run "${cmake_cxx_compiler}" \
  903. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  904. cmake_cxx_compiler_is_gnu=1
  905. fi
  906. if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
  907. echo "${cmake_cxx_compiler} is GNU compiler"
  908. else
  909. echo "${cmake_cxx_compiler} is not GNU compiler"
  910. fi
  911. rm -f "${TMPFILE}.cxx"
  912. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  913. # Check for non-GNU compiler flags
  914. # If we are on IRIX, check for -LANG:std
  915. cmake_test_flags="-LANG:std"
  916. if [ "x${cmake_system}" = "xIRIX64" ]; then
  917. TMPFILE=`cmake_tmp_file`
  918. echo '
  919. #include <iostream>
  920. int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
  921. ' > ${TMPFILE}.cxx
  922. cmake_need_lang_std=0
  923. if cmake_try_run "${cmake_cxx_compiler}" \
  924. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  925. :
  926. else
  927. if cmake_try_run "${cmake_cxx_compiler}" \
  928. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  929. cmake_need_lang_std=1
  930. fi
  931. fi
  932. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  933. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  934. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  935. else
  936. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  937. fi
  938. rm -f "${TMPFILE}.cxx"
  939. fi
  940. cmake_test_flags=
  941. # If we are on OSF, check for -timplicit_local -no_implicit_include
  942. cmake_test_flags="-timplicit_local -no_implicit_include"
  943. if [ "x${cmake_system}" = "xOSF1" ]; then
  944. TMPFILE=`cmake_tmp_file`
  945. echo '
  946. #include <iostream>
  947. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  948. ' > ${TMPFILE}.cxx
  949. cmake_need_flags=1
  950. if cmake_try_run "${cmake_cxx_compiler}" \
  951. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  952. :
  953. else
  954. cmake_need_flags=0
  955. fi
  956. if [ "x${cmake_need_flags}" = "x1" ]; then
  957. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  958. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  959. else
  960. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  961. fi
  962. rm -f "${TMPFILE}.cxx"
  963. fi
  964. cmake_test_flags=
  965. # If we are on OSF, check for -std strict_ansi -nopure_cname
  966. cmake_test_flags="-std strict_ansi -nopure_cname"
  967. if [ "x${cmake_system}" = "xOSF1" ]; then
  968. TMPFILE=`cmake_tmp_file`
  969. echo '
  970. #include <iostream>
  971. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  972. ' > ${TMPFILE}.cxx
  973. cmake_need_flags=1
  974. if cmake_try_run "${cmake_cxx_compiler}" \
  975. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  976. :
  977. else
  978. cmake_need_flags=0
  979. fi
  980. if [ "x${cmake_need_flags}" = "x1" ]; then
  981. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  982. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  983. else
  984. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  985. fi
  986. rm -f "${TMPFILE}.cxx"
  987. fi
  988. cmake_test_flags=
  989. # If we are on HP-UX, check for -Ae for the C compiler.
  990. if [ "x${cmake_system}" = "xHP-UX" ]; then
  991. cmake_test_flags="-Ae"
  992. TMPFILE=`cmake_tmp_file`
  993. echo '
  994. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  995. ' > ${TMPFILE}.c
  996. cmake_need_Ae=0
  997. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  998. :
  999. else
  1000. if cmake_try_run "${cmake_c_compiler}" \
  1001. "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  1002. cmake_need_Ae=1
  1003. fi
  1004. fi
  1005. if [ "x${cmake_need_Ae}" = "x1" ]; then
  1006. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  1007. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  1008. else
  1009. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  1010. fi
  1011. rm -f "${TMPFILE}.c"
  1012. echo '
  1013. #include <iostream>
  1014. int main(int argc, char** argv) {
  1015. for(int i=0; i < 1; ++i);
  1016. for(int i=0; i < 1; ++i);
  1017. (void)argc; (void)argv; return 0; }
  1018. ' > ${TMPFILE}.cxx
  1019. cmake_need_AAstd98=0
  1020. cmake_test_flags="-AA +hpxstd98"
  1021. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1022. :
  1023. else
  1024. if cmake_try_run "${cmake_cxx_compiler}" \
  1025. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1026. cmake_need_AAstd98=1
  1027. fi
  1028. fi
  1029. if [ "x${cmake_need_AAstd98}" = "x1" ]; then
  1030. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  1031. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  1032. else
  1033. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  1034. fi
  1035. fi
  1036. cmake_test_flags=
  1037. fi
  1038. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  1039. # Are we SolarisStudio?
  1040. TMPFILE=`cmake_tmp_file`
  1041. echo '
  1042. #if defined(__SUNPRO_CC)
  1043. #include <iostream>
  1044. int main() { std::cout << "This is SolarisStudio" << std::endl; return 0;}
  1045. #endif
  1046. ' > ${TMPFILE}.cxx
  1047. cmake_cxx_compiler_is_solarisstudio=0
  1048. if cmake_try_run "${cmake_cxx_compiler}" \
  1049. "${cmake_cxx_flags} " "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1050. cmake_cxx_compiler_is_solarisstudio=1
  1051. fi
  1052. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1053. echo "${cmake_cxx_compiler} is SolarisStudio compiler"
  1054. else
  1055. echo "${cmake_cxx_compiler} is not SolarisStudio compiler"
  1056. fi
  1057. rm -f "${TMPFILE}.cxx"
  1058. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1059. cmake_cxx_flags="${cmake_cxx_flags} -library=stlport4"
  1060. fi
  1061. fi
  1062. # Test for kwsys features
  1063. KWSYS_NAME_IS_KWSYS=0
  1064. KWSYS_BUILD_SHARED=0
  1065. KWSYS_LFS_AVAILABLE=0
  1066. KWSYS_LFS_REQUESTED=0
  1067. KWSYS_STL_HAS_WSTRING=0
  1068. KWSYS_CXX_HAS_SETENV=0
  1069. KWSYS_CXX_HAS_UNSETENV=0
  1070. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
  1071. KWSYS_CXX_HAS_UTIMENSAT=0
  1072. KWSYS_CXX_HAS_UTIMES=0
  1073. if cmake_try_run "${cmake_cxx_compiler}" \
  1074. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
  1075. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1076. KWSYS_CXX_HAS_SETENV=1
  1077. echo "${cmake_cxx_compiler} has setenv"
  1078. else
  1079. echo "${cmake_cxx_compiler} does not have setenv"
  1080. fi
  1081. if cmake_try_run "${cmake_cxx_compiler}" \
  1082. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
  1083. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1084. KWSYS_CXX_HAS_UNSETENV=1
  1085. echo "${cmake_cxx_compiler} has unsetenv"
  1086. else
  1087. echo "${cmake_cxx_compiler} does not have unsetenv"
  1088. fi
  1089. if cmake_try_run "${cmake_cxx_compiler}" \
  1090. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
  1091. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1092. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
  1093. echo "${cmake_cxx_compiler} has environ in stdlib.h"
  1094. else
  1095. echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
  1096. fi
  1097. if cmake_try_run "${cmake_cxx_compiler}" \
  1098. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_WSTRING" \
  1099. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1100. KWSYS_STL_HAS_WSTRING=1
  1101. echo "${cmake_cxx_compiler} has stl wstring"
  1102. else
  1103. echo "${cmake_cxx_compiler} does not have stl wstring"
  1104. fi
  1105. # Just to be safe, let us store compiler and flags to the header file
  1106. cmake_bootstrap_version='$Revision$'
  1107. cmake_compiler_settings_comment="/*
  1108. * Generated by ${cmake_source_dir}/bootstrap
  1109. * Version: ${cmake_bootstrap_version}
  1110. *
  1111. * Source directory: ${cmake_source_dir}
  1112. * Binary directory: ${cmake_bootstrap_dir}
  1113. *
  1114. * C compiler: ${cmake_c_compiler}
  1115. * C flags: ${cmake_c_flags}
  1116. *
  1117. * C++ compiler: ${cmake_cxx_compiler}
  1118. * C++ flags: ${cmake_cxx_flags}
  1119. *
  1120. * Make: ${cmake_make_processor}
  1121. *
  1122. * Sources:
  1123. * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
  1124. * kwSys Sources:
  1125. * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
  1126. */
  1127. "
  1128. cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
  1129. # When bootstrapping on MinGW with MSYS we must convert the source
  1130. # directory to a windows path.
  1131. if ${cmake_system_mingw}; then
  1132. CMAKE_BOOTSTRAP_SOURCE_DIR=`cd "${cmake_source_dir}"; pwd -W`
  1133. CMAKE_BOOTSTRAP_BINARY_DIR=`cd "${cmake_binary_dir}"; pwd -W`
  1134. else
  1135. CMAKE_BOOTSTRAP_SOURCE_DIR="${cmake_source_dir}"
  1136. CMAKE_BOOTSTRAP_BINARY_DIR="${cmake_binary_dir}"
  1137. fi
  1138. # Write CMake version
  1139. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
  1140. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
  1141. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
  1142. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
  1143. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
  1144. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
  1145. cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
  1146. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
  1147. # Regenerate configured headers
  1148. for h in Configure VersionConfig; do
  1149. if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
  1150. rm -f cm${h}.h${_tmp}
  1151. else
  1152. mv -f cm${h}.h${_tmp} cm${h}.h
  1153. fi
  1154. done
  1155. # Prepare KWSYS
  1156. cmake_kwsys_config_replace_string \
  1157. "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
  1158. "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
  1159. "${cmake_compiler_settings_comment}"
  1160. cmake_kwsys_config_replace_string \
  1161. "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  1162. "${cmake_bootstrap_dir}/cmsys/Configure.h" \
  1163. "${cmake_compiler_settings_comment}"
  1164. for a in ${KWSYS_FILES}; do
  1165. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  1166. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  1167. done
  1168. for a in ${KWIML_FILES}; do
  1169. cmake_replace_string "${cmake_source_dir}/Utilities/KWIML/${a}.in" \
  1170. "${cmake_bootstrap_dir}/cmIML/${a}" KWIML cmIML
  1171. done
  1172. # Generate Makefile
  1173. dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  1174. objs=""
  1175. for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
  1176. objs="${objs} ${a}.o"
  1177. done
  1178. # Generate dependencies for cmBootstrapCommands1.cxx
  1179. for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands1.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
  1180. cmBootstrapCommands1Deps="${cmBootstrapCommands1Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
  1181. done
  1182. cmBootstrapCommands1Deps=`echo $cmBootstrapCommands1Deps`
  1183. for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands2.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
  1184. cmBootstrapCommands2Deps="${cmBootstrapCommands2Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
  1185. done
  1186. cmBootstrapCommands2Deps=`echo $cmBootstrapCommands2Deps`
  1187. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  1188. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  1189. fi
  1190. if [ "x${cmake_c_flags}" != "x" ]; then
  1191. cmake_c_flags="${cmake_c_flags} "
  1192. fi
  1193. if [ "x${cmake_cxx_flags}" != "x" ]; then
  1194. cmake_cxx_flags="${cmake_cxx_flags} "
  1195. fi
  1196. cmake_c_flags_String="-DKWSYS_STRING_C"
  1197. if ${cmake_system_mingw}; then
  1198. cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP"
  1199. fi
  1200. cmake_cxx_flags_SystemTools="
  1201. -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
  1202. -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
  1203. -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
  1204. -DKWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
  1205. -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
  1206. "
  1207. cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1208. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1209. cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1210. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1211. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  1212. echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  1213. for a in ${CMAKE_CXX_SOURCES}; do
  1214. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  1215. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1216. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1217. done
  1218. echo "cmBootstrapCommands1.o : $cmBootstrapCommands1Deps" >> "${cmake_bootstrap_dir}/Makefile"
  1219. echo "cmBootstrapCommands2.o : $cmBootstrapCommands2Deps" >> "${cmake_bootstrap_dir}/Makefile"
  1220. for a in ${CMAKE_C_SOURCES}; do
  1221. src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
  1222. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1223. echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1224. done
  1225. for a in ${KWSYS_C_SOURCES}; do
  1226. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  1227. src_flags=`eval echo \\${cmake_c_flags_\${a}}`
  1228. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1229. echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1230. done
  1231. for a in ${KWSYS_CXX_SOURCES}; do
  1232. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  1233. src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
  1234. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1235. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1236. done
  1237. echo '
  1238. rebuild_cache:
  1239. cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
  1240. ' >> "${cmake_bootstrap_dir}/Makefile"
  1241. # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
  1242. echo '
  1243. # Generated by '"${cmake_source_dir}"'/bootstrap
  1244. # Default cmake settings. These may be overridden any settings below.
  1245. set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  1246. set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  1247. set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  1248. set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  1249. ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1250. # Add configuration settings given as command-line options.
  1251. if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
  1252. echo '
  1253. set (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
  1254. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1255. fi
  1256. if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
  1257. echo '
  1258. set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
  1259. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1260. fi
  1261. if [ "x${cmake_sphinx_man}" != "x" ]; then
  1262. echo '
  1263. set (SPHINX_MAN "'"${cmake_sphinx_man}"'" CACHE BOOL "Build man pages with Sphinx" FORCE)
  1264. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1265. fi
  1266. if [ "x${cmake_sphinx_html}" != "x" ]; then
  1267. echo '
  1268. set (SPHINX_HTML "'"${cmake_sphinx_html}"'" CACHE BOOL "Build html help with Sphinx" FORCE)
  1269. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1270. fi
  1271. if [ "x${cmake_sphinx_qthelp}" != "x" ]; then
  1272. echo '
  1273. set (SPHINX_QTHELP "'"${cmake_sphinx_qthelp}"'" CACHE BOOL "Build qch help with Sphinx" FORCE)
  1274. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1275. fi
  1276. if [ "x${cmake_sphinx_build}" != "x" ]; then
  1277. echo '
  1278. set (SPHINX_EXECUTABLE "'"${cmake_sphinx_build}"'" CACHE FILEPATH "Location of Qt sphinx-build" FORCE)
  1279. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1280. fi
  1281. if [ "x${cmake_sphinx_flags}" != "x" ]; then
  1282. echo '
  1283. set (SPHINX_FLAGS [==['"${cmake_sphinx_flags}"']==] CACHE STRING "Flags to pass to sphinx-build" FORCE)
  1284. ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1285. fi
  1286. # Add user-specified settings. Handle relative-path case for
  1287. # specification of cmake_init_file.
  1288. (
  1289. cd "${cmake_binary_dir}"
  1290. if [ -f "${cmake_init_file}" ]; then
  1291. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1292. fi
  1293. )
  1294. echo "---------------------------------------------"
  1295. # Run make to build bootstrap cmake
  1296. if [ "x${cmake_parallel_make}" != "x" ]; then
  1297. ${cmake_make_processor} ${cmake_make_flags}
  1298. else
  1299. ${cmake_make_processor}
  1300. fi
  1301. RES=$?
  1302. if [ "${RES}" -ne "0" ]; then
  1303. cmake_error 9 "Problem while running ${cmake_make_processor}"
  1304. fi
  1305. cd "${cmake_binary_dir}"
  1306. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  1307. # build with same compiler and make
  1308. CC="${cmake_c_compiler}"
  1309. CXX="${cmake_cxx_compiler}"
  1310. if [ -n "${cmake_ccache_enabled}" ]; then
  1311. CC="ccache ${CC}"
  1312. CXX="ccache ${CXX}"
  1313. fi
  1314. MAKE="${cmake_make_processor}"
  1315. export CC
  1316. export CXX
  1317. export MAKE
  1318. # Run bootstrap CMake to configure real CMake
  1319. cmake_options="-DCMAKE_BOOTSTRAP=1"
  1320. if [ -n "${cmake_verbose}" ]; then
  1321. cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1"
  1322. fi
  1323. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@"
  1324. RES=$?
  1325. if [ "${RES}" -ne "0" ]; then
  1326. cmake_error 11 "Problem while running initial CMake"
  1327. fi
  1328. echo "---------------------------------------------"
  1329. # And we are done. Now just run make
  1330. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."