bootstrap 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  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. # Display CMake bootstrap usage
  344. cmake_usage()
  345. {
  346. echo '
  347. Usage: '"$0"' [<options>...] [-- <cmake-options>...]
  348. Options: [defaults in brackets after descriptions]
  349. Configuration:
  350. --help print this message
  351. --version only print version information
  352. --verbose display more information
  353. --parallel=n bootstrap cmake in parallel, where n is
  354. number of nodes [1]
  355. --enable-ccache Enable ccache when building cmake
  356. --init=FILE load FILE as script to populate cache
  357. --system-libs use all system-installed third-party libraries
  358. (for use only by package maintainers)
  359. --no-system-libs use all cmake-provided third-party libraries
  360. (default)
  361. --system-curl use system-installed curl library
  362. --no-system-curl use cmake-provided curl library (default)
  363. --system-expat use system-installed expat library
  364. --no-system-expat use cmake-provided expat library (default)
  365. --system-jsoncpp use system-installed jsoncpp library
  366. --no-system-jsoncpp use cmake-provided jsoncpp library (default)
  367. --system-zlib use system-installed zlib library
  368. --no-system-zlib use cmake-provided zlib library (default)
  369. --system-bzip2 use system-installed bzip2 library
  370. --no-system-bzip2 use cmake-provided bzip2 library (default)
  371. --system-libarchive use system-installed libarchive library
  372. --no-system-libarchive use cmake-provided libarchive library (default)
  373. --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
  374. --no-qt-gui do not build the Qt-based GUI (default)
  375. --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
  376. --sphinx-man build man pages with Sphinx
  377. --sphinx-html build html help with Sphinx
  378. --sphinx-qthelp build qch help with Sphinx
  379. --sphinx-build=<sb> use <sb> as the sphinx-build executable
  380. --sphinx-flags=<flags> pass <flags> to sphinx-build executable
  381. Directory and file names:
  382. --prefix=PREFIX install files in tree rooted at PREFIX
  383. ['"${cmake_default_prefix}"']
  384. --datadir=DIR install data files in PREFIX/DIR
  385. ['"${cmake_data_dir_default}"']
  386. --docdir=DIR install documentation files in PREFIX/DIR
  387. ['"${cmake_doc_dir_default}"']
  388. --mandir=DIR install man pages files in PREFIX/DIR/manN
  389. ['"${cmake_man_dir_default}"']
  390. '
  391. exit 10
  392. }
  393. # Display CMake bootstrap usage
  394. cmake_version_display()
  395. {
  396. echo "CMake ${cmake_version}, ${cmake_copyright}"
  397. }
  398. # Display CMake bootstrap error, display the log file and exit
  399. cmake_error()
  400. {
  401. res=$1
  402. shift 1
  403. echo "---------------------------------------------"
  404. echo "Error when bootstrapping CMake:"
  405. echo "$*"
  406. echo "---------------------------------------------"
  407. if [ -f cmake_bootstrap.log ]; then
  408. echo "Log of errors: `pwd`/cmake_bootstrap.log"
  409. #cat cmake_bootstrap.log
  410. echo "---------------------------------------------"
  411. fi
  412. exit ${res}
  413. }
  414. cmake_generate_file ()
  415. {
  416. OUTFILE="$1"
  417. CONTENT="$2"
  418. echo "$CONTENT" > "$OUTFILE.tmp"
  419. if "${_diff}" "$OUTFILE.tmp" "$OUTFILE" > /dev/null 2> /dev/null ; then
  420. rm -f "$OUTFILE.tmp"
  421. else
  422. mv -f "$OUTFILE.tmp" "$OUTFILE"
  423. fi
  424. }
  425. # Replace KWSYS_NAMESPACE with cmsys
  426. cmake_replace_string ()
  427. {
  428. INFILE="$1"
  429. OUTFILE="$2"
  430. SEARCHFOR="$3"
  431. REPLACEWITH="$4"
  432. if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
  433. cat "${INFILE}" |
  434. sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
  435. if [ -f "${OUTFILE}${_tmp}" ]; then
  436. if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
  437. #echo "Files are the same"
  438. rm -f "${OUTFILE}${_tmp}"
  439. else
  440. mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
  441. fi
  442. fi
  443. else
  444. cmake_error 1 "Cannot find file ${INFILE}"
  445. fi
  446. }
  447. cmake_kwsys_config_replace_string ()
  448. {
  449. INFILE="$1"
  450. OUTFILE="$2"
  451. shift 2
  452. APPEND="$*"
  453. if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
  454. echo "${APPEND}" > "${OUTFILE}${_tmp}"
  455. cat "${INFILE}" |
  456. sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
  457. s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
  458. s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
  459. s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
  460. s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
  461. s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
  462. }" >> "${OUTFILE}${_tmp}"
  463. if [ -f "${OUTFILE}${_tmp}" ]; then
  464. if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
  465. #echo "Files are the same"
  466. rm -f "${OUTFILE}${_tmp}"
  467. else
  468. mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
  469. fi
  470. fi
  471. else
  472. cmake_error 2 "Cannot find file ${INFILE}"
  473. fi
  474. }
  475. # Write string into a file
  476. cmake_report ()
  477. {
  478. FILE=$1
  479. shift
  480. echo "$*" >> ${FILE}
  481. }
  482. # Escape spaces in strings
  483. cmake_escape ()
  484. {
  485. echo $1 | sed "s/ /\\\\ /g"
  486. }
  487. # Strip prefix from argument
  488. cmake_arg ()
  489. {
  490. echo "$1" | sed "s/^${2-[^=]*=}//"
  491. }
  492. # Write message to the log
  493. cmake_log ()
  494. {
  495. echo "$*" >> cmake_bootstrap.log
  496. }
  497. # Return temp file
  498. cmake_tmp_file ()
  499. {
  500. echo "cmake_bootstrap_$$_test"
  501. }
  502. # Run a compiler test. First argument is compiler, second one are compiler
  503. # flags, third one is test source file to be compiled
  504. cmake_try_run ()
  505. {
  506. COMPILER=$1
  507. FLAGS=$2
  508. TESTFILE=$3
  509. if [ ! -f "${TESTFILE}" ]; then
  510. echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
  511. exit 4
  512. fi
  513. TMPFILE=`cmake_tmp_file`
  514. echo "Try: ${COMPILER}"
  515. echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  516. echo "---------- file -----------------------"
  517. cat "${TESTFILE}"
  518. echo "------------------------------------------"
  519. "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  520. RES=$?
  521. if [ "${RES}" -ne "0" ]; then
  522. echo "Test failed to compile"
  523. return 1
  524. fi
  525. if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
  526. echo "Test failed to produce executable"
  527. return 2
  528. fi
  529. ./${TMPFILE}
  530. RES=$?
  531. rm -f "${TMPFILE}"
  532. if [ "${RES}" -ne "0" ]; then
  533. echo "Test produced non-zero return code"
  534. return 3
  535. fi
  536. echo "Test succeeded"
  537. return 0
  538. }
  539. # Run a make test. First argument is the make interpreter.
  540. cmake_try_make ()
  541. {
  542. MAKE_PROC="$1"
  543. MAKE_FLAGS="$2"
  544. echo "Try: ${MAKE_PROC}"
  545. "${MAKE_PROC}" ${MAKE_FLAGS}
  546. RES=$?
  547. if [ "${RES}" -ne "0" ]; then
  548. echo "${MAKE_PROC} does not work"
  549. return 1
  550. fi
  551. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  552. echo "${COMPILER} does not produce output"
  553. return 2
  554. fi
  555. ./test
  556. RES=$?
  557. rm -f "test"
  558. if [ "${RES}" -ne "0" ]; then
  559. echo "${MAKE_PROC} produces strange executable"
  560. return 3
  561. fi
  562. echo "${MAKE_PROC} works"
  563. return 0
  564. }
  565. # Parse arguments
  566. cmake_verbose=
  567. cmake_parallel_make=
  568. cmake_ccache_enabled=
  569. cmake_prefix_dir="${cmake_default_prefix}"
  570. while test $# != 0; do
  571. case "$1" in
  572. --prefix=*) dir=`cmake_arg "$1"`
  573. cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
  574. --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
  575. --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
  576. --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
  577. --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
  578. --init=*) cmake_init_file=`cmake_arg "$1"` ;;
  579. --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
  580. --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
  581. --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-zlib)
  582. lib=`cmake_arg "$1" "--system-"`
  583. cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
  584. --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-zlib)
  585. lib=`cmake_arg "$1" "--no-system-"`
  586. cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
  587. --qt-gui) cmake_bootstrap_qt_gui="1" ;;
  588. --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
  589. --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
  590. --sphinx-man) cmake_sphinx_man="1" ;;
  591. --sphinx-html) cmake_sphinx_html="1" ;;
  592. --sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
  593. --sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
  594. --sphinx-flags=*) cmake_sphinx_flags=`cmake_arg "$1"` ;;
  595. --help) cmake_usage ;;
  596. --version) cmake_version_display ; exit 2 ;;
  597. --verbose) cmake_verbose=TRUE ;;
  598. --enable-ccache) cmake_ccache_enabled=TRUE ;;
  599. --) shift; break ;;
  600. *) die "Unknown option: $1" ;;
  601. esac
  602. shift
  603. done
  604. # If verbose, display some information about bootstrap
  605. if [ -n "${cmake_verbose}" ]; then
  606. echo "---------------------------------------------"
  607. echo "Source directory: ${cmake_source_dir}"
  608. echo "Binary directory: ${cmake_binary_dir}"
  609. echo "Prefix directory: ${cmake_prefix_dir}"
  610. echo "System: ${cmake_system}"
  611. if [ "x${cmake_parallel_make}" != "x" ]; then
  612. echo "Doing parallel make: ${cmake_parallel_make}"
  613. fi
  614. echo ""
  615. fi
  616. echo "---------------------------------------------"
  617. # Get CMake version
  618. echo "`cmake_version_display`"
  619. # Check for in-source build
  620. cmake_in_source_build=
  621. if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
  622. -f "${cmake_binary_dir}/Source/cmake.h" ]; then
  623. if [ -n "${cmake_verbose}" ]; then
  624. echo "Warning: This is an in-source build"
  625. fi
  626. cmake_in_source_build=TRUE
  627. fi
  628. # If this is not an in-source build, then Bootstrap stuff should not exist.
  629. if [ -z "${cmake_in_source_build}" ]; then
  630. # Did somebody bootstrap in the source tree?
  631. if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
  632. cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
  633. Looks like somebody did bootstrap CMake in the source tree, but now you are
  634. trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
  635. directory from the source tree."
  636. fi
  637. # Is there a cache in the source tree?
  638. for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
  639. if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
  640. cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
  641. Looks like somebody tried to build CMake in the source tree, but now you are
  642. trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
  643. from the source tree."
  644. fi
  645. done
  646. fi
  647. # Make bootstrap directory
  648. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  649. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  650. cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  651. fi
  652. cd "${cmake_bootstrap_dir}"
  653. [ -d "cmsys" ] || mkdir "cmsys"
  654. if [ ! -d "cmsys" ]; then
  655. cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  656. fi
  657. # Delete all the bootstrap files
  658. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  659. rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
  660. rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
  661. # If exist compiler flags, set them
  662. cmake_c_flags=${CFLAGS}
  663. cmake_cxx_flags=${CXXFLAGS}
  664. cmake_ld_flags=${LDFLAGS}
  665. # Add Cygwin-specific flags
  666. if ${cmake_system_cygwin}; then
  667. cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
  668. fi
  669. # Add CoreFoundation framework on Darwin
  670. if ${cmake_system_darwin}; then
  671. cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
  672. fi
  673. # Add BeOS toolkits...
  674. if ${cmake_system_beos}; then
  675. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  676. fi
  677. # Add Haiku toolkits...
  678. if ${cmake_system_haiku}; then
  679. cmake_ld_flags="${LDFLAGS} -lroot -lbe"
  680. fi
  681. # Workaround for short jump tables on PA-RISC
  682. if ${cmake_machine_parisc}; then
  683. if ${cmake_c_compiler_is_gnu}; then
  684. cmake_c_flags="${CFLAGS} -mlong-calls"
  685. fi
  686. if ${cmake_cxx_compiler_is_gnu}; then
  687. cmake_cxx_flags="${CXXFLAGS} -mlong-calls"
  688. fi
  689. fi
  690. #-----------------------------------------------------------------------------
  691. # Detect known toolchains on some platforms.
  692. cmake_toolchains=''
  693. case "${cmake_system}" in
  694. *AIX*) cmake_toolchains='XL GNU' ;;
  695. *CYGWIN*) cmake_toolchains='GNU' ;;
  696. *Darwin*) cmake_toolchains='GNU Clang' ;;
  697. *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
  698. *MINGW*) cmake_toolchains='GNU' ;;
  699. esac
  700. # Toolchain compiler name table.
  701. cmake_toolchain_Clang_CC='clang'
  702. cmake_toolchain_Clang_CXX='clang++'
  703. cmake_toolchain_GNU_CC='gcc'
  704. cmake_toolchain_GNU_CXX='g++'
  705. cmake_toolchain_PGI_CC='pgcc'
  706. cmake_toolchain_PGI_CXX='pgCC'
  707. cmake_toolchain_PathScale_CC='pathcc'
  708. cmake_toolchain_PathScale_CXX='pathCC'
  709. cmake_toolchain_XL_CC='xlc'
  710. cmake_toolchain_XL_CXX='xlC'
  711. cmake_toolchain_try()
  712. {
  713. tc="$1"
  714. TMPFILE=`cmake_tmp_file`
  715. eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
  716. echo 'int main() { return 0; }' > "${TMPFILE}.c"
  717. cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
  718. tc_result_CC="$?"
  719. rm -f "${TMPFILE}.c"
  720. test "${tc_result_CC}" = "0" || return 1
  721. eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
  722. echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
  723. cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
  724. tc_result_CXX="$?"
  725. rm -f "${TMPFILE}.cpp"
  726. test "${tc_result_CXX}" = "0" || return 1
  727. cmake_toolchain="$tc"
  728. }
  729. cmake_toolchain_detect()
  730. {
  731. cmake_toolchain=
  732. for tc in ${cmake_toolchains}; do
  733. echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
  734. cmake_toolchain_try "$tc" &&
  735. echo "Found $tc toolchain" &&
  736. break
  737. done
  738. }
  739. if [ -z "${CC}" -a -z "${CXX}" ]; then
  740. cmake_toolchain_detect
  741. fi
  742. #-----------------------------------------------------------------------------
  743. # Test C compiler
  744. cmake_c_compiler=
  745. # If CC is set, use that for compiler, otherwise use list of known compilers
  746. if [ -n "${cmake_toolchain}" ]; then
  747. eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
  748. elif [ -n "${CC}" ]; then
  749. cmake_c_compilers="${CC}"
  750. else
  751. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  752. fi
  753. # Check if C compiler works
  754. TMPFILE=`cmake_tmp_file`
  755. echo '
  756. #ifdef __cplusplus
  757. # error "The CMAKE_C_COMPILER is set to a C++ compiler"
  758. #endif
  759. #include<stdio.h>
  760. #if defined(__CLASSIC_C__)
  761. int main(argc, argv)
  762. int argc;
  763. char* argv[];
  764. #else
  765. int main(int argc, char* argv[])
  766. #endif
  767. {
  768. printf("%d%c", (argv != 0), (char)0x0a);
  769. return argc-1;
  770. }
  771. ' > "${TMPFILE}.c"
  772. for a in ${cmake_c_compilers}; do
  773. if [ -z "${cmake_c_compiler}" ] && \
  774. cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  775. cmake_c_compiler="${a}"
  776. fi
  777. done
  778. rm -f "${TMPFILE}.c"
  779. if [ -z "${cmake_c_compiler}" ]; then
  780. cmake_error 6 "Cannot find appropriate C compiler on this system.
  781. Please specify one using environment variable CC.
  782. See cmake_bootstrap.log for compilers attempted.
  783. "
  784. fi
  785. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  786. #-----------------------------------------------------------------------------
  787. # Test CXX compiler
  788. cmake_cxx_compiler=
  789. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  790. # If CC is set, use that for compiler, otherwise use list of known compilers
  791. if [ -n "${cmake_toolchain}" ]; then
  792. eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
  793. elif [ -n "${CXX}" ]; then
  794. cmake_cxx_compilers="${CXX}"
  795. else
  796. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  797. fi
  798. # Check if C++ compiler works
  799. TMPFILE=`cmake_tmp_file`
  800. echo '
  801. #if defined(TEST1)
  802. # include <iostream>
  803. #else
  804. # include <iostream.h>
  805. #endif
  806. class NeedCXX
  807. {
  808. public:
  809. NeedCXX() { this->Foo = 1; }
  810. int GetFoo() { return this->Foo; }
  811. private:
  812. int Foo;
  813. };
  814. int main()
  815. {
  816. NeedCXX c;
  817. #ifdef TEST3
  818. cout << c.GetFoo() << endl;
  819. #else
  820. std::cout << c.GetFoo() << std::endl;
  821. #endif
  822. return 0;
  823. }
  824. ' > "${TMPFILE}.cxx"
  825. for a in ${cmake_cxx_compilers}; do
  826. for b in 1 2 3; do
  827. if [ -z "${cmake_cxx_compiler}" ] && \
  828. cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  829. cmake_cxx_compiler="${a}"
  830. fi
  831. done
  832. done
  833. rm -f "${TMPFILE}.cxx"
  834. if [ -z "${cmake_cxx_compiler}" ]; then
  835. cmake_error 7 "Cannot find appropriate C++ compiler on this system.
  836. Please specify one using environment variable CXX.
  837. See cmake_bootstrap.log for compilers attempted."
  838. fi
  839. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  840. #-----------------------------------------------------------------------------
  841. # Test Make
  842. cmake_make_processor=
  843. cmake_make_flags=
  844. # If MAKE is set, use that for make processor, otherwise use list of known make
  845. if [ -n "${MAKE}" ]; then
  846. cmake_make_processors="${MAKE}"
  847. else
  848. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  849. fi
  850. TMPFILE="`cmake_tmp_file`_dir"
  851. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  852. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  853. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  854. echo '
  855. test: test.c
  856. "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
  857. '>"Makefile"
  858. echo '
  859. #include <stdio.h>
  860. int main(){ printf("1%c", (char)0x0a); return 0; }
  861. ' > "test.c"
  862. cmake_original_make_flags="${cmake_make_flags}"
  863. if [ "x${cmake_parallel_make}" != "x" ]; then
  864. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  865. fi
  866. for a in ${cmake_make_processors}; do
  867. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  868. cmake_make_processor="${a}"
  869. fi
  870. done
  871. cmake_full_make_flags="${cmake_make_flags}"
  872. if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
  873. if [ -z "${cmake_make_processor}" ]; then
  874. cmake_make_flags="${cmake_original_make_flags}"
  875. for a in ${cmake_make_processors}; do
  876. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
  877. cmake_make_processor="${a}"
  878. fi
  879. done
  880. fi
  881. fi
  882. cd "${cmake_bootstrap_dir}"
  883. if [ -z "${cmake_make_processor}" ]; then
  884. cmake_error 8 "Cannot find appropriate Makefile processor on this system.
  885. Please specify one using environment variable MAKE."
  886. fi
  887. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  888. echo "Makefile processor on this system is: ${cmake_make_processor}"
  889. if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
  890. echo "---------------------------------------------"
  891. echo "Makefile processor ${cmake_make_processor} does not support parallel build"
  892. echo "---------------------------------------------"
  893. fi
  894. # Ok, we have CC, CXX, and MAKE.
  895. # Test C++ compiler features
  896. # Are we GCC?
  897. TMPFILE=`cmake_tmp_file`
  898. echo '
  899. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  900. #include <iostream>
  901. int main() { std::cout << "This is GNU" << std::endl; return 0;}
  902. #endif
  903. ' > ${TMPFILE}.cxx
  904. cmake_cxx_compiler_is_gnu=0
  905. if cmake_try_run "${cmake_cxx_compiler}" \
  906. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  907. cmake_cxx_compiler_is_gnu=1
  908. fi
  909. if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
  910. echo "${cmake_cxx_compiler} is GNU compiler"
  911. else
  912. echo "${cmake_cxx_compiler} is not GNU compiler"
  913. fi
  914. rm -f "${TMPFILE}.cxx"
  915. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  916. # Check for non-GNU compiler flags
  917. # If we are on IRIX, check for -LANG:std
  918. cmake_test_flags="-LANG:std"
  919. if [ "x${cmake_system}" = "xIRIX64" ]; then
  920. TMPFILE=`cmake_tmp_file`
  921. echo '
  922. #include <iostream>
  923. int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
  924. ' > ${TMPFILE}.cxx
  925. cmake_need_lang_std=0
  926. if cmake_try_run "${cmake_cxx_compiler}" \
  927. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  928. :
  929. else
  930. if cmake_try_run "${cmake_cxx_compiler}" \
  931. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  932. cmake_need_lang_std=1
  933. fi
  934. fi
  935. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  936. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  937. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  938. else
  939. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  940. fi
  941. rm -f "${TMPFILE}.cxx"
  942. fi
  943. cmake_test_flags=
  944. # If we are on OSF, check for -timplicit_local -no_implicit_include
  945. cmake_test_flags="-timplicit_local -no_implicit_include"
  946. if [ "x${cmake_system}" = "xOSF1" ]; then
  947. TMPFILE=`cmake_tmp_file`
  948. echo '
  949. #include <iostream>
  950. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  951. ' > ${TMPFILE}.cxx
  952. cmake_need_flags=1
  953. if cmake_try_run "${cmake_cxx_compiler}" \
  954. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  955. :
  956. else
  957. cmake_need_flags=0
  958. fi
  959. if [ "x${cmake_need_flags}" = "x1" ]; then
  960. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  961. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  962. else
  963. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  964. fi
  965. rm -f "${TMPFILE}.cxx"
  966. fi
  967. cmake_test_flags=
  968. # If we are on OSF, check for -std strict_ansi -nopure_cname
  969. cmake_test_flags="-std strict_ansi -nopure_cname"
  970. if [ "x${cmake_system}" = "xOSF1" ]; then
  971. TMPFILE=`cmake_tmp_file`
  972. echo '
  973. #include <iostream>
  974. int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
  975. ' > ${TMPFILE}.cxx
  976. cmake_need_flags=1
  977. if cmake_try_run "${cmake_cxx_compiler}" \
  978. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  979. :
  980. else
  981. cmake_need_flags=0
  982. fi
  983. if [ "x${cmake_need_flags}" = "x1" ]; then
  984. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  985. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  986. else
  987. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  988. fi
  989. rm -f "${TMPFILE}.cxx"
  990. fi
  991. cmake_test_flags=
  992. # If we are on HP-UX, check for -Ae for the C compiler.
  993. if [ "x${cmake_system}" = "xHP-UX" ]; then
  994. cmake_test_flags="-Ae"
  995. TMPFILE=`cmake_tmp_file`
  996. echo '
  997. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  998. ' > ${TMPFILE}.c
  999. cmake_need_Ae=0
  1000. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  1001. :
  1002. else
  1003. if cmake_try_run "${cmake_c_compiler}" \
  1004. "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  1005. cmake_need_Ae=1
  1006. fi
  1007. fi
  1008. if [ "x${cmake_need_Ae}" = "x1" ]; then
  1009. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  1010. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  1011. else
  1012. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  1013. fi
  1014. rm -f "${TMPFILE}.c"
  1015. echo '
  1016. #include <iostream>
  1017. int main(int argc, char** argv) {
  1018. for(int i=0; i < 1; ++i);
  1019. for(int i=0; i < 1; ++i);
  1020. (void)argc; (void)argv; return 0; }
  1021. ' > ${TMPFILE}.cxx
  1022. cmake_need_AAstd98=0
  1023. cmake_test_flags="-AA +hpxstd98"
  1024. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1025. :
  1026. else
  1027. if cmake_try_run "${cmake_cxx_compiler}" \
  1028. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1029. cmake_need_AAstd98=1
  1030. fi
  1031. fi
  1032. if [ "x${cmake_need_AAstd98}" = "x1" ]; then
  1033. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  1034. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  1035. else
  1036. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  1037. fi
  1038. fi
  1039. cmake_test_flags=
  1040. fi
  1041. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  1042. # Are we SolarisStudio?
  1043. TMPFILE=`cmake_tmp_file`
  1044. echo '
  1045. #if defined(__SUNPRO_CC)
  1046. #include <iostream>
  1047. int main() { std::cout << "This is SolarisStudio" << std::endl; return 0;}
  1048. #endif
  1049. ' > ${TMPFILE}.cxx
  1050. cmake_cxx_compiler_is_solarisstudio=0
  1051. if cmake_try_run "${cmake_cxx_compiler}" \
  1052. "${cmake_cxx_flags} " "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  1053. cmake_cxx_compiler_is_solarisstudio=1
  1054. fi
  1055. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1056. echo "${cmake_cxx_compiler} is SolarisStudio compiler"
  1057. else
  1058. echo "${cmake_cxx_compiler} is not SolarisStudio compiler"
  1059. fi
  1060. rm -f "${TMPFILE}.cxx"
  1061. if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then
  1062. cmake_cxx_flags="${cmake_cxx_flags} -library=stlport4"
  1063. fi
  1064. fi
  1065. # Test for kwsys features
  1066. KWSYS_NAME_IS_KWSYS=0
  1067. KWSYS_BUILD_SHARED=0
  1068. KWSYS_LFS_AVAILABLE=0
  1069. KWSYS_LFS_REQUESTED=0
  1070. KWSYS_STL_HAS_WSTRING=0
  1071. KWSYS_CXX_HAS_SETENV=0
  1072. KWSYS_CXX_HAS_UNSETENV=0
  1073. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
  1074. KWSYS_CXX_HAS_UTIMENSAT=0
  1075. KWSYS_CXX_HAS_UTIMES=0
  1076. if cmake_try_run "${cmake_cxx_compiler}" \
  1077. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
  1078. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1079. KWSYS_CXX_HAS_SETENV=1
  1080. echo "${cmake_cxx_compiler} has setenv"
  1081. else
  1082. echo "${cmake_cxx_compiler} does not have setenv"
  1083. fi
  1084. if cmake_try_run "${cmake_cxx_compiler}" \
  1085. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
  1086. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1087. KWSYS_CXX_HAS_UNSETENV=1
  1088. echo "${cmake_cxx_compiler} has unsetenv"
  1089. else
  1090. echo "${cmake_cxx_compiler} does not have unsetenv"
  1091. fi
  1092. if cmake_try_run "${cmake_cxx_compiler}" \
  1093. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
  1094. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1095. KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
  1096. echo "${cmake_cxx_compiler} has environ in stdlib.h"
  1097. else
  1098. echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
  1099. fi
  1100. if cmake_try_run "${cmake_cxx_compiler}" \
  1101. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_WSTRING" \
  1102. "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
  1103. KWSYS_STL_HAS_WSTRING=1
  1104. echo "${cmake_cxx_compiler} has stl wstring"
  1105. else
  1106. echo "${cmake_cxx_compiler} does not have stl wstring"
  1107. fi
  1108. # Just to be safe, let us store compiler and flags to the header file
  1109. cmake_bootstrap_version='$Revision$'
  1110. cmake_compiler_settings_comment="/*
  1111. * Generated by ${cmake_source_dir}/bootstrap
  1112. * Version: ${cmake_bootstrap_version}
  1113. *
  1114. * Source directory: ${cmake_source_dir}
  1115. * Binary directory: ${cmake_bootstrap_dir}
  1116. *
  1117. * C compiler: ${cmake_c_compiler}
  1118. * C flags: ${cmake_c_flags}
  1119. *
  1120. * C++ compiler: ${cmake_cxx_compiler}
  1121. * C++ flags: ${cmake_cxx_flags}
  1122. *
  1123. * Make: ${cmake_make_processor}
  1124. *
  1125. * Sources:
  1126. * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
  1127. * kwSys Sources:
  1128. * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
  1129. */
  1130. "
  1131. cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
  1132. # When bootstrapping on MinGW with MSYS we must convert the source
  1133. # directory to a windows path.
  1134. if ${cmake_system_mingw}; then
  1135. CMAKE_BOOTSTRAP_SOURCE_DIR=`cd "${cmake_source_dir}"; pwd -W`
  1136. CMAKE_BOOTSTRAP_BINARY_DIR=`cd "${cmake_binary_dir}"; pwd -W`
  1137. else
  1138. CMAKE_BOOTSTRAP_SOURCE_DIR="${cmake_source_dir}"
  1139. CMAKE_BOOTSTRAP_BINARY_DIR="${cmake_binary_dir}"
  1140. fi
  1141. # Write CMake version
  1142. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
  1143. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
  1144. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
  1145. cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
  1146. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
  1147. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
  1148. cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
  1149. cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
  1150. # Regenerate configured headers
  1151. for h in Configure VersionConfig; do
  1152. if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
  1153. rm -f cm${h}.h${_tmp}
  1154. else
  1155. mv -f cm${h}.h${_tmp} cm${h}.h
  1156. fi
  1157. done
  1158. # Prepare KWSYS
  1159. cmake_kwsys_config_replace_string \
  1160. "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
  1161. "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
  1162. "${cmake_compiler_settings_comment}"
  1163. cmake_kwsys_config_replace_string \
  1164. "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  1165. "${cmake_bootstrap_dir}/cmsys/Configure.h" \
  1166. "${cmake_compiler_settings_comment}"
  1167. for a in ${KWSYS_FILES}; do
  1168. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  1169. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  1170. done
  1171. cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" ""
  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_source_dir}/Utilities\"`"
  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_source_dir}/Utilities\"`"
  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}."