bootstrap 44 KB

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