bootstrap 45 KB

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