bootstrap 53 KB

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