bootstrap 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  1. #!/bin/sh
  2. #=========================================================================
  3. #
  4. # Program: CMake - Cross-Platform Makefile Generator
  5. # Module: $RCSfile$
  6. # Language: Bourne Shell
  7. # Date: $Date$
  8. # Version: $Revision$
  9. #
  10. # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  11. # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  12. #
  13. # This software is distributed WITHOUT ANY WARRANTY; without even
  14. # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. # PURPOSE. See the above copyright notices for more information.
  16. #
  17. #=========================================================================
  18. # Detect system and directory information.
  19. cmake_system=`uname`
  20. cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
  21. cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
  22. cmake_binary_dir=`pwd`
  23. cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
  24. cmake_data_dir="/share/CMake"
  25. cmake_doc_dir="/doc/CMake"
  26. cmake_man_dir="/man"
  27. cmake_init_file=""
  28. # Determine whether this is a MinGW environment.
  29. if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
  30. cmake_system_mingw=true
  31. else
  32. cmake_system_mingw=false
  33. fi
  34. # Choose the generator to use for bootstrapping.
  35. if ${cmake_system_mingw}; then
  36. # Bootstrapping from an MSYS prompt.
  37. cmake_bootstrap_generator="MSYS Makefiles"
  38. else
  39. # Bootstrapping from a standard UNIX prompt.
  40. cmake_bootstrap_generator="Unix Makefiles"
  41. fi
  42. # Helper function to fix windows paths.
  43. cmake_fix_slashes ()
  44. {
  45. echo "$1" | sed 's/\\/\//g'
  46. }
  47. # Choose the default install prefix.
  48. if ${cmake_system_mingw}; then
  49. if [ "x${PROGRAMFILES}" != "x" ]; then
  50. cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
  51. elif [ "x${ProgramFiles}" != "x" ]; then
  52. cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
  53. elif [ "x${SYSTEMDRIVE}" != "x" ]; then
  54. cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
  55. elif [ "x${SystemDrive}" != "x" ]; then
  56. cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
  57. else
  58. cmake_default_prefix="c:/Program Files/CMake"
  59. fi
  60. else
  61. cmake_default_prefix="/usr/local"
  62. fi
  63. CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
  64. CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
  65. CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
  66. CMAKE_PROBLEMATIC_FILES="\
  67. CMakeCache.txt \
  68. CMakeSystem.cmake \
  69. CMakeCCompiler.cmake \
  70. CMakeCXXCompiler.cmake \
  71. Source/cmConfigure.h \
  72. Source/CTest/Curl/config.h \
  73. Utilities/cmexpat/expatConfig.h \
  74. Utilities/cmexpat/expatDllConfig.h \
  75. "
  76. CMAKE_CXX_SOURCES="\
  77. cmake \
  78. cmakewizard \
  79. cmakemain \
  80. cmCommandArgumentLexer \
  81. cmCommandArgumentParser \
  82. cmCommandArgumentParserHelper \
  83. cmDepends \
  84. cmDependsC \
  85. cmMakeDepend \
  86. cmMakefile \
  87. cmGeneratedFileStream \
  88. cmGlobalGenerator \
  89. cmLocalGenerator \
  90. cmInstallGenerator \
  91. cmInstallFilesGenerator \
  92. cmInstallScriptGenerator \
  93. cmInstallTargetGenerator \
  94. cmSourceFile \
  95. cmSystemTools \
  96. cmFileTimeComparison \
  97. cmGlobalUnixMakefileGenerator3 \
  98. cmGlobalXCodeGenerator \
  99. cmLocalXCodeGenerator \
  100. cmXCodeObject \
  101. cmXCode21Object \
  102. cmLocalUnixMakefileGenerator3 \
  103. cmMakefileExecutableTargetGenerator \
  104. cmMakefileLibraryTargetGenerator \
  105. cmMakefileTargetGenerator \
  106. cmMakefileUtilityTargetGenerator \
  107. cmBootstrapCommands \
  108. cmCommands \
  109. cmTarget \
  110. cmTest \
  111. cmCustomCommand \
  112. cmCacheManager \
  113. cmListFileCache \
  114. cmOrderLinkDirectories \
  115. cmSourceGroup"
  116. if ${cmake_system_mingw}; then
  117. CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
  118. cmGlobalMSYSMakefileGenerator \
  119. cmGlobalMinGWMakefileGenerator \
  120. cmWin32ProcessExecution"
  121. fi
  122. CMAKE_C_SOURCES="\
  123. cmListFileLexer \
  124. "
  125. if ${cmake_system_mingw}; then
  126. KWSYS_C_SOURCES="\
  127. ProcessWin32"
  128. KWSYS_C_MINGW_SOURCES="\
  129. ProcessFwd9x \
  130. EncodeExecutable"
  131. KWSYS_C_GENERATED_SOURCES="\
  132. cmsysProcessFwd9xEnc"
  133. else
  134. KWSYS_C_SOURCES="\
  135. ProcessUNIX"
  136. KWSYS_C_MINGW_SOURCES=""
  137. KWSYS_C_GENERATED_SOURCES=""
  138. fi
  139. KWSYS_CXX_SOURCES="\
  140. Directory \
  141. Glob \
  142. RegularExpression \
  143. SystemTools"
  144. KWSYS_FILES="\
  145. Directory.hxx \
  146. Glob.hxx \
  147. Process.h \
  148. RegularExpression.hxx \
  149. String.hxx \
  150. SystemTools.hxx"
  151. KWSYS_IOS_FILES="
  152. fstream \
  153. iosfwd \
  154. iostream \
  155. sstream"
  156. # Display CMake bootstrap usage
  157. cmake_usage()
  158. {
  159. cat <<EOF
  160. Usage: $0 [options]
  161. Options: [defaults in brackets after descriptions]
  162. Configuration:
  163. --help print this message
  164. --version only print version information
  165. --verbose display more information
  166. --parallel=n bootstrap cmake in parallel, where n is
  167. number of nodes [1]
  168. --init=FILE use FILE for cmake initialization
  169. Directory and file names:
  170. --prefix=PREFIX install files in tree rooted at PREFIX
  171. [${cmake_default_prefix}]
  172. --datadir=DIR install data files in PREFIX/DIR
  173. [/share/CMake]
  174. --docdir=DIR install documentation files in PREFIX/DIR
  175. [/doc/CMake]
  176. --mandir=DIR install man pages files in PREFIX/DIR/manN
  177. [/man]
  178. EOF
  179. exit 10
  180. }
  181. # Display CMake bootstrap usage
  182. cmake_version()
  183. {
  184. # Get CMake version
  185. CMAKE_VERSION=""
  186. for a in MAJOR MINOR PATCH; do
  187. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \
  188. grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  189. CMAKE_VERSION="${CMAKE_VERSION}.${CMake_VERSION}"
  190. done
  191. if echo "$CMAKE_VERSION" | grep "\.[0-9][0-9]*\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
  192. CMake_DATE=`cat "${cmake_source_dir}/Source/cmVersion.cxx" | grep "\".Date: [0-9][0-9]*/[0-9][0-9]*/[0-9][0-9]* [0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]* .\";"`
  193. CMake_DATE=`echo "${CMake_DATE}" | sed "s/.*Date: \([0-9][0-9]*\)\/\([0-9][0-9]*\)\/\([0-9][0-9]*\) .*/\1\2\3/" `
  194. CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-${CMake_DATE}/"`
  195. else
  196. CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-\3/"`
  197. fi
  198. echo "CMake ${CMAKE_VERSION}, Copyright (c) 2002 Kitware, Inc., Insight Consortium"
  199. }
  200. # Display CMake bootstrap error, display the log file and exit
  201. cmake_error()
  202. {
  203. res=$1
  204. shift 1
  205. echo "---------------------------------------------"
  206. echo "Error when bootstrapping CMake:"
  207. echo "$*"
  208. echo "---------------------------------------------"
  209. if [ -f cmake_bootstrap.log ]; then
  210. echo "Log of errors: `pwd`/cmake_bootstrap.log"
  211. #cat cmake_bootstrap.log
  212. echo "---------------------------------------------"
  213. fi
  214. exit ${res}
  215. }
  216. # Replace KWSYS_NAMESPACE with cmsys
  217. cmake_replace_string ()
  218. {
  219. INFILE="$1"
  220. OUTFILE="$2"
  221. SEARCHFOR="$3"
  222. REPLACEWITH="$4"
  223. if [ -f "${INFILE}" ]; then
  224. cat "${INFILE}" |
  225. sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
  226. if [ -f "${OUTFILE}.tmp" ]; then
  227. if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
  228. #echo "Files are the same"
  229. rm -f "${OUTFILE}.tmp"
  230. else
  231. mv -f "${OUTFILE}.tmp" "${OUTFILE}"
  232. fi
  233. fi
  234. else
  235. cmake_error 1 "Cannot find file ${INFILE}"
  236. fi
  237. }
  238. cmake_kwsys_config_replace_string ()
  239. {
  240. INFILE="$1"
  241. OUTFILE="$2"
  242. shift 2
  243. APPEND="$*"
  244. if [ -f "${INFILE}" ]; then
  245. echo "${APPEND}" > "${OUTFILE}.tmp"
  246. cat "${INFILE}" |
  247. sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
  248. s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
  249. s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
  250. s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
  251. s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
  252. s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
  253. s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
  254. s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
  255. s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
  256. s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
  257. s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
  258. s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
  259. s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
  260. s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
  261. s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
  262. s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
  263. s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
  264. s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
  265. s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
  266. s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
  267. s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
  268. s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
  269. s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
  270. s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
  271. s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
  272. s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
  273. if [ -f "${OUTFILE}.tmp" ]; then
  274. if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
  275. #echo "Files are the same"
  276. rm -f "${OUTFILE}.tmp"
  277. else
  278. mv -f "${OUTFILE}.tmp" "${OUTFILE}"
  279. fi
  280. fi
  281. else
  282. cmake_error 2 "Cannot find file ${INFILE}"
  283. fi
  284. }
  285. # Write string into a file
  286. cmake_report ()
  287. {
  288. FILE=$1
  289. shift
  290. echo "$*" >> ${FILE}
  291. }
  292. # Escape spaces in strings
  293. cmake_escape ()
  294. {
  295. echo $1 | sed "s/ /\\\\ /g"
  296. }
  297. # Write message to the log
  298. cmake_log ()
  299. {
  300. echo "$*" >> cmake_bootstrap.log
  301. }
  302. # Return temp file
  303. cmake_tmp_file ()
  304. {
  305. echo "cmake_bootstrap_$$.test"
  306. }
  307. # Run a compiler test. First argument is compiler, second one are compiler
  308. # flags, third one is test source file to be compiled
  309. cmake_try_run ()
  310. {
  311. COMPILER=$1
  312. FLAGS=$2
  313. TESTFILE=$3
  314. if [ ! -f "${TESTFILE}" ]; then
  315. echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
  316. exit 4
  317. fi
  318. TMPFILE=`cmake_tmp_file`
  319. echo "Try: ${COMPILER}"
  320. echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  321. echo "---------- file -----------------------"
  322. cat "${TESTFILE}"
  323. echo "------------------------------------------"
  324. "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  325. RES=$?
  326. if [ "${RES}" -ne "0" ]; then
  327. echo "Test failed to compile"
  328. return 1
  329. fi
  330. if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
  331. echo "Test failed to produce executable"
  332. return 2
  333. fi
  334. ./${TMPFILE}
  335. RES=$?
  336. rm -f "${TMPFILE}"
  337. if [ "${RES}" -ne "0" ]; then
  338. echo "Test produced non-zero return code"
  339. return 3
  340. fi
  341. echo "Test succeded"
  342. return 0
  343. }
  344. # Run a make test. First argument is the make interpreter.
  345. cmake_try_make ()
  346. {
  347. MAKE_PROC="$1"
  348. MAKE_FLAGS="$2"
  349. echo "Try: ${MAKE_PROC}"
  350. "${MAKE_PROC}" ${MAKE_FLAGS}
  351. RES=$?
  352. if [ "${RES}" -ne "0" ]; then
  353. echo "${MAKE_PROC} does not work"
  354. return 1
  355. fi
  356. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  357. echo "${COMPILER} does not produce output"
  358. return 2
  359. fi
  360. ./test
  361. RES=$?
  362. rm -f "test"
  363. if [ "${RES}" -ne "0" ]; then
  364. echo "${MAKE_PROC} produces strange executable"
  365. return 3
  366. fi
  367. echo "${MAKE_PROC} works"
  368. return 0
  369. }
  370. # Parse arguments
  371. cmake_verbose=
  372. cmake_parallel_make=
  373. cmake_prefix_dir="${cmake_default_prefix}"
  374. for a in "$@"; do
  375. if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
  376. cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
  377. cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
  378. fi
  379. if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
  380. cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
  381. fi
  382. if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
  383. cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
  384. fi
  385. if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
  386. cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
  387. fi
  388. if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
  389. cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
  390. fi
  391. if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
  392. cmake_init_file=`echo $a | sed "s/^--init=//"`
  393. fi
  394. if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
  395. cmake_usage
  396. fi
  397. if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
  398. cmake_version
  399. exit 2
  400. fi
  401. if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
  402. cmake_verbose=TRUE
  403. fi
  404. done
  405. # If verbose, display some information about bootstrap
  406. if [ -n "${cmake_verbose}" ]; then
  407. echo "---------------------------------------------"
  408. echo "Source directory: ${cmake_source_dir}"
  409. echo "Binary directory: ${cmake_binary_dir}"
  410. echo "Prefix directory: ${cmake_prefix_dir}"
  411. echo "System: ${cmake_system}"
  412. if [ "x${cmake_parallel_make}" != "x" ]; then
  413. echo "Doing parallel make: ${cmake_parallel_make}"
  414. fi
  415. echo ""
  416. fi
  417. echo "---------------------------------------------"
  418. # Get CMake version
  419. echo "`cmake_version`"
  420. # Check for in-source build
  421. cmake_in_source_build=
  422. if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
  423. -f "${cmake_binary_dir}/Source/cmake.h" ]; then
  424. if [ -n "${cmake_verbose}" ]; then
  425. echo "Warning: This is an in-source build"
  426. fi
  427. cmake_in_source_build=TRUE
  428. fi
  429. # If this is not an in-source build, then Bootstrap stuff should not exist.
  430. if [ -z "${cmake_in_source_build}" ]; then
  431. # Did somebody bootstrap in the source tree?
  432. if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
  433. cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
  434. Looks like somebody did bootstrap CMake in the source tree, but now you are
  435. trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
  436. directory from the source tree."
  437. fi
  438. # Is there a cache in the source tree?
  439. for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
  440. if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
  441. cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
  442. Looks like somebody tried to build CMake in the source tree, but now you are
  443. trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
  444. from the source tree."
  445. fi
  446. done
  447. fi
  448. # Make bootstrap directory
  449. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  450. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  451. cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  452. fi
  453. cd "${cmake_bootstrap_dir}"
  454. [ -d "cmsys" ] || mkdir "cmsys"
  455. if [ ! -d "cmsys" ]; then
  456. cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  457. fi
  458. for a in stl ios; do
  459. [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
  460. if [ ! -d "cmsys/${a}" ]; then
  461. cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
  462. fi
  463. done
  464. # Delete all the bootstrap files
  465. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  466. rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
  467. # If exist compiler flags, set them
  468. cmake_c_flags=${CFLAGS}
  469. cmake_cxx_flags=${CXXFLAGS}
  470. # Test C compiler
  471. cmake_c_compiler=
  472. # If CC is set, use that for compiler, otherwise use list of known compilers
  473. if [ -n "${CC}" ]; then
  474. cmake_c_compilers="${CC}"
  475. else
  476. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  477. fi
  478. # Check if C compiler works
  479. TMPFILE=`cmake_tmp_file`
  480. cat > "${TMPFILE}.c" <<EOF
  481. #include<stdio.h>
  482. int main()
  483. {
  484. printf("1\n");
  485. return 0;
  486. }
  487. EOF
  488. for a in ${cmake_c_compilers}; do
  489. if [ -z "${cmake_c_compiler}" ] && \
  490. cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  491. cmake_c_compiler="${a}"
  492. fi
  493. done
  494. rm -f "${TMPFILE}.c"
  495. if [ -z "${cmake_c_compiler}" ]; then
  496. cmake_error 6 "Cannot find appropriate C compiler on this system.
  497. Please specify one using environment variable CC.
  498. See cmake_bootstrap.log for compilers attempted.
  499. "
  500. fi
  501. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  502. # Test CXX compiler
  503. cmake_cxx_compiler=
  504. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  505. # If CC is set, use that for compiler, otherwise use list of known compilers
  506. if [ -n "${CXX}" ]; then
  507. cmake_cxx_compilers="${CXX}"
  508. else
  509. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  510. fi
  511. # Check if C++ compiler works
  512. TMPFILE=`cmake_tmp_file`
  513. cat > "${TMPFILE}.cxx" <<EOF
  514. #if defined(TEST1)
  515. # include <iostream>
  516. #else
  517. # include <iostream.h>
  518. #endif
  519. class NeedCXX
  520. {
  521. public:
  522. NeedCXX() { this->Foo = 1; }
  523. int GetFoo() { return this->Foo; }
  524. private:
  525. int Foo;
  526. };
  527. int main()
  528. {
  529. NeedCXX c;
  530. #ifdef TEST3
  531. cout << c.GetFoo() << endl;
  532. #else
  533. std::cout << c.GetFoo() << std::endl;
  534. #endif
  535. return 0;
  536. }
  537. EOF
  538. for a in ${cmake_cxx_compilers}; do
  539. for b in 1 2 3; do
  540. if [ -z "${cmake_cxx_compiler}" ] && \
  541. cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  542. cmake_cxx_compiler="${a}"
  543. fi
  544. done
  545. done
  546. rm -f "${TMPFILE}.cxx"
  547. if [ -z "${cmake_cxx_compiler}" ]; then
  548. cmake_error 7 "Cannot find appropriate C++ compiler on this system.
  549. Please specify one using environment variable CXX.
  550. See cmake_bootstrap.log for compilers attempted."
  551. fi
  552. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  553. # Test Make
  554. cmake_make_processor=
  555. cmake_make_flags=
  556. # If MAKE is set, use that for make processor, otherwise use list of known make
  557. if [ -n "${MAKE}" ]; then
  558. cmake_make_processors="${MAKE}"
  559. else
  560. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  561. fi
  562. TMPFILE="`cmake_tmp_file`_dir"
  563. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  564. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  565. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  566. cat>"Makefile"<<EOF
  567. test: test.c
  568. "${cmake_c_compiler}" -o test test.c
  569. EOF
  570. cat>"test.c"<<EOF
  571. #include <stdio.h>
  572. int main(){ printf("1\n"); return 0; }
  573. EOF
  574. cmake_original_make_flags="${cmake_make_flags}"
  575. if [ "x${cmake_parallel_make}" != "x" ]; then
  576. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  577. fi
  578. for a in ${cmake_make_processors}; do
  579. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
  580. cmake_make_processor="${a}"
  581. fi
  582. done
  583. cmake_full_make_flags="${cmake_make_flags}"
  584. if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
  585. if [ -z "${cmake_make_processor}" ]; then
  586. cmake_make_flags="${cmake_original_make_flags}"
  587. for a in ${cmake_make_processors}; do
  588. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
  589. cmake_make_processor="${a}"
  590. fi
  591. done
  592. fi
  593. fi
  594. cd "${cmake_bootstrap_dir}"
  595. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  596. if [ -z "${cmake_make_processor}" ]; then
  597. cmake_error 8 "Cannot find appropriate Makefile processor on this system.
  598. Please specify one using environment variable MAKE."
  599. fi
  600. echo "Makefile processor on this system is: ${cmake_make_processor}"
  601. if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
  602. echo "---------------------------------------------"
  603. echo "Makefile processor ${cmake_make_processor} does not support parallel build"
  604. echo "---------------------------------------------"
  605. fi
  606. # Ok, we have CC, CXX, and MAKE.
  607. # Test C++ compiler features
  608. # Are we GCC?
  609. TMPFILE=`cmake_tmp_file`
  610. cat > ${TMPFILE}.cxx <<EOF
  611. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  612. #include <iostream>
  613. int main() { std::cout << "This is GNU" << std::endl; return 0;}
  614. #endif
  615. EOF
  616. cmake_cxx_compiler_is_gnu=0
  617. if cmake_try_run "${cmake_cxx_compiler}" \
  618. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  619. cmake_cxx_compiler_is_gnu=1
  620. fi
  621. if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
  622. echo "${cmake_cxx_compiler} is GNU compiler"
  623. else
  624. echo "${cmake_cxx_compiler} is not GNU compiler"
  625. fi
  626. rm -f "${TMPFILE}.cxx"
  627. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  628. # Check for non-GNU compiler flags
  629. # If we are on IRIX, check for -LANG:std
  630. cmake_test_flags="-LANG:std"
  631. if [ "x${cmake_system}" = "xIRIX64" ]; then
  632. TMPFILE=`cmake_tmp_file`
  633. cat > ${TMPFILE}.cxx <<EOF
  634. #include <iostream>
  635. int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
  636. EOF
  637. cmake_need_lang_std=0
  638. if cmake_try_run "${cmake_cxx_compiler}" \
  639. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  640. :
  641. else
  642. if cmake_try_run "${cmake_cxx_compiler}" \
  643. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  644. cmake_need_lang_std=1
  645. fi
  646. fi
  647. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  648. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  649. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  650. else
  651. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  652. fi
  653. rm -f "${TMPFILE}.cxx"
  654. fi
  655. cmake_test_flags=
  656. # If we are on OSF, check for -timplicit_local -no_implicit_include
  657. cmake_test_flags="-timplicit_local -no_implicit_include"
  658. if [ "x${cmake_system}" = "xOSF1" ]; then
  659. TMPFILE=`cmake_tmp_file`
  660. cat > ${TMPFILE}.cxx <<EOF
  661. #include <iostream>
  662. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  663. EOF
  664. cmake_need_flags=1
  665. if cmake_try_run "${cmake_cxx_compiler}" \
  666. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  667. :
  668. else
  669. cmake_need_flags=0
  670. fi
  671. if [ "x${cmake_need_flags}" = "x1" ]; then
  672. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  673. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  674. else
  675. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  676. fi
  677. rm -f "${TMPFILE}.cxx"
  678. fi
  679. cmake_test_flags=
  680. # If we are on OSF, check for -std strict_ansi -nopure_cname
  681. cmake_test_flags="-std strict_ansi -nopure_cname"
  682. if [ "x${cmake_system}" = "xOSF1" ]; then
  683. TMPFILE=`cmake_tmp_file`
  684. cat > ${TMPFILE}.cxx <<EOF
  685. #include <iostream>
  686. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  687. EOF
  688. cmake_need_flags=1
  689. if cmake_try_run "${cmake_cxx_compiler}" \
  690. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  691. :
  692. else
  693. cmake_need_flags=0
  694. fi
  695. if [ "x${cmake_need_flags}" = "x1" ]; then
  696. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  697. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  698. else
  699. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  700. fi
  701. rm -f "${TMPFILE}.cxx"
  702. fi
  703. cmake_test_flags=
  704. # If we are on HP-UX, check for -Ae for the C compiler.
  705. cmake_test_flags="-Ae"
  706. if [ "x${cmake_system}" = "xHP-UX" ]; then
  707. TMPFILE=`cmake_tmp_file`
  708. cat > ${TMPFILE}.c <<EOF
  709. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  710. EOF
  711. cmake_need_Ae=0
  712. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  713. :
  714. else
  715. if cmake_try_run "${cmake_c_compiler}" \
  716. "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  717. cmake_need_Ae=1
  718. fi
  719. fi
  720. if [ "x${cmake_need_Ae}" = "x1" ]; then
  721. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  722. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  723. else
  724. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  725. fi
  726. rm -f "${TMPFILE}.c"
  727. fi
  728. cmake_test_flags=
  729. fi
  730. # Test for kwsys features
  731. KWSYS_NAME_IS_KWSYS=0
  732. KWSYS_BUILD_SHARED=0
  733. KWSYS_IOS_USE_STRSTREAM_H=0
  734. KWSYS_IOS_USE_STRSTREA_H=0
  735. KWSYS_IOS_HAVE_STD=0
  736. KWSYS_IOS_USE_SSTREAM=0
  737. KWSYS_IOS_USE_ANSI=0
  738. KWSYS_STL_HAVE_STD=0
  739. KWSYS_STAT_HAS_ST_MTIM=0
  740. KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
  741. KWSYS_STL_HAS_ITERATOR_TRAITS=0
  742. KWSYS_STL_HAS_ITERATOR_CATEGORY=0
  743. KWSYS_STL_HAS___ITERATOR_CATEGORY=0
  744. KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
  745. KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
  746. KWSYS_STL_HAS_ALLOCATOR_REBIND=0
  747. KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
  748. KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
  749. KWSYS_CXX_HAS_CSTDDEF=0
  750. KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
  751. KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
  752. KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
  753. KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
  754. # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
  755. KWSYS_STL_STRING_HAVE_ISTREAM=1
  756. KWSYS_STL_STRING_HAVE_OSTREAM=1
  757. if cmake_try_run "${cmake_cxx_compiler}" \
  758. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
  759. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  760. KWSYS_STL_HAVE_STD=1
  761. echo "${cmake_cxx_compiler} has STL in std:: namespace"
  762. else
  763. echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
  764. fi
  765. if cmake_try_run "${cmake_cxx_compiler}" \
  766. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
  767. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  768. KWSYS_IOS_USE_ANSI=1
  769. echo "${cmake_cxx_compiler} has ANSI streams"
  770. else
  771. echo "${cmake_cxx_compiler} does not have ANSI streams"
  772. fi
  773. if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
  774. if cmake_try_run "${cmake_cxx_compiler}" \
  775. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
  776. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  777. KWSYS_IOS_HAVE_STD=1
  778. echo "${cmake_cxx_compiler} has streams in std:: namespace"
  779. else
  780. echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
  781. fi
  782. if cmake_try_run "${cmake_cxx_compiler}" \
  783. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
  784. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  785. KWSYS_IOS_USE_SSTREAM=1
  786. echo "${cmake_cxx_compiler} has sstream"
  787. else
  788. echo "${cmake_cxx_compiler} does not have sstream"
  789. fi
  790. fi
  791. if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
  792. if cmake_try_run "${cmake_cxx_compiler}" \
  793. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
  794. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  795. KWSYS_IOS_USE_STRSTREAM_H=1
  796. echo "${cmake_cxx_compiler} has strstream.h"
  797. else
  798. echo "${cmake_cxx_compiler} does not have strstream.h"
  799. fi
  800. if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
  801. if cmake_try_run "${cmake_cxx_compiler}" \
  802. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
  803. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  804. KWSYS_IOS_USE_STRSTREA_H=1
  805. echo "${cmake_cxx_compiler} has strstrea.h"
  806. else
  807. echo "${cmake_cxx_compiler} does not have strstrea.h"
  808. fi
  809. fi
  810. fi
  811. if cmake_try_run "${cmake_cxx_compiler}" \
  812. "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  813. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  814. KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
  815. echo "${cmake_cxx_compiler} has operator!=(string, char*)"
  816. else
  817. echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
  818. fi
  819. if cmake_try_run "${cmake_cxx_compiler}" \
  820. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  821. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  822. KWSYS_STL_HAS_ITERATOR_TRAITS=1
  823. echo "${cmake_cxx_compiler} has stl iterator_traits"
  824. else
  825. echo "${cmake_cxx_compiler} does not have stl iterator_traits"
  826. fi
  827. if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
  828. if cmake_try_run "${cmake_cxx_compiler}" \
  829. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  830. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  831. KWSYS_STL_HAS_ITERATOR_CATEGORY=1
  832. echo "${cmake_cxx_compiler} has old iterator_category"
  833. else
  834. echo "${cmake_cxx_compiler} does not have old iterator_category"
  835. fi
  836. if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
  837. if cmake_try_run "${cmake_cxx_compiler}" \
  838. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  839. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  840. KWSYS_STL_HAS___ITERATOR_CATEGORY=1
  841. echo "${cmake_cxx_compiler} has old __iterator_category"
  842. else
  843. echo "${cmake_cxx_compiler} does not have old __iterator_category"
  844. fi
  845. fi
  846. fi
  847. if cmake_try_run "${cmake_cxx_compiler}" \
  848. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  849. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  850. KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
  851. echo "${cmake_cxx_compiler} has standard template allocator"
  852. else
  853. echo "${cmake_cxx_compiler} does not have standard template allocator"
  854. fi
  855. if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
  856. if cmake_try_run "${cmake_cxx_compiler}" \
  857. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  858. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  859. KWSYS_STL_HAS_ALLOCATOR_REBIND=1
  860. echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
  861. else
  862. echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
  863. fi
  864. if cmake_try_run "${cmake_cxx_compiler}" \
  865. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  866. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  867. KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
  868. echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
  869. else
  870. echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
  871. fi
  872. else
  873. if cmake_try_run "${cmake_cxx_compiler}" \
  874. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  875. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  876. KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
  877. echo "${cmake_cxx_compiler} has old non-template allocator"
  878. else
  879. echo "${cmake_cxx_compiler} does not have old non-template allocator"
  880. fi
  881. fi
  882. if cmake_try_run "${cmake_cxx_compiler}" \
  883. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
  884. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  885. KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
  886. echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
  887. else
  888. echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
  889. fi
  890. if cmake_try_run "${cmake_cxx_compiler}" \
  891. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
  892. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  893. KWSYS_CXX_HAS_CSTDDEF=1
  894. echo "${cmake_cxx_compiler} has header cstddef"
  895. else
  896. echo "${cmake_cxx_compiler} does not have header cstddef"
  897. fi
  898. if cmake_try_run "${cmake_cxx_compiler}" \
  899. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
  900. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  901. echo "${cmake_cxx_compiler} does not require template friends to use <>"
  902. else
  903. KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
  904. echo "${cmake_cxx_compiler} requires template friends to use <>"
  905. fi
  906. if cmake_try_run "${cmake_cxx_compiler}" \
  907. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
  908. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  909. KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
  910. echo "${cmake_cxx_compiler} supports member templates"
  911. else
  912. echo "${cmake_cxx_compiler} does not support member templates"
  913. fi
  914. if cmake_try_run "${cmake_cxx_compiler}" \
  915. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
  916. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  917. KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
  918. echo "${cmake_cxx_compiler} has standard template specialization syntax"
  919. else
  920. echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
  921. fi
  922. if cmake_try_run "${cmake_cxx_compiler}" \
  923. "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
  924. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  925. KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
  926. echo "${cmake_cxx_compiler} has argument dependent lookup"
  927. else
  928. echo "${cmake_cxx_compiler} does not have argument dependent lookup"
  929. fi
  930. if cmake_try_run "${cmake_cxx_compiler}" \
  931. "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
  932. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  933. KWSYS_STAT_HAS_ST_MTIM=1
  934. echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
  935. else
  936. echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
  937. fi
  938. # Just to be safe, let us store compiler and flags to the header file
  939. cmake_bootstrap_version='$Revision$'
  940. cmake_compiler_settings_comment="/*
  941. * Generated by ${cmake_source_dir}/bootstrap
  942. * Version: ${cmake_bootstrap_version}
  943. *
  944. * Source directory: ${cmake_source_dir}
  945. * Binary directory: ${cmake_bootstrap_dir}
  946. *
  947. * C compiler: ${cmake_c_compiler}
  948. * C flags: ${cmake_c_flags}
  949. *
  950. * C++ compiler: ${cmake_cxx_compiler}
  951. * C++ flags: ${cmake_cxx_flags}
  952. *
  953. * Make: ${cmake_make_processor}
  954. *
  955. * Sources:
  956. * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
  957. * kwSys Sources:
  958. * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
  959. */
  960. "
  961. cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
  962. if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
  963. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
  964. else
  965. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
  966. fi
  967. if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
  968. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
  969. else
  970. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
  971. fi
  972. if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
  973. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
  974. else
  975. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
  976. fi
  977. # Test for ansi FOR scope
  978. if cmake_try_run "${cmake_cxx_compiler}" \
  979. "${cmake_cxx_flags}" \
  980. "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
  981. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
  982. echo "${cmake_cxx_compiler} has ANSI for scoping"
  983. else
  984. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
  985. echo "${cmake_cxx_compiler} does not have ANSI for scoping"
  986. fi
  987. # When bootstrapping on MinGW with MSYS we must convert the source
  988. # directory to a windows path.
  989. if ${cmake_system_mingw}; then
  990. cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
  991. else
  992. cmake_root_dir="${cmake_source_dir}"
  993. fi
  994. # Write CMake version
  995. for a in MAJOR MINOR PATCH; do
  996. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \
  997. grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  998. cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
  999. done
  1000. cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
  1001. cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
  1002. cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
  1003. # Regenerate real cmConfigure.h
  1004. if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
  1005. rm -f cmConfigure.h.tmp
  1006. else
  1007. mv -f cmConfigure.h.tmp cmConfigure.h
  1008. fi
  1009. # Prepare KWSYS
  1010. cmake_kwsys_config_replace_string \
  1011. "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
  1012. "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
  1013. "${cmake_compiler_settings_comment}"
  1014. cmake_kwsys_config_replace_string \
  1015. "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  1016. "${cmake_bootstrap_dir}/cmsys/Configure.h" \
  1017. "${cmake_compiler_settings_comment}"
  1018. for a in ${KWSYS_FILES}; do
  1019. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  1020. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  1021. done
  1022. for a in ${KWSYS_IOS_FILES}; do
  1023. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
  1024. "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
  1025. done
  1026. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
  1027. "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
  1028. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
  1029. "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
  1030. for a in string vector map; do
  1031. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
  1032. "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
  1033. done
  1034. # Generate Makefile
  1035. dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  1036. objs=""
  1037. for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
  1038. objs="${objs} ${a}.o"
  1039. done
  1040. # Generate dependencies for cmBootstrapCommands.cxx
  1041. for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
  1042. cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
  1043. done
  1044. cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
  1045. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  1046. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  1047. fi
  1048. if [ "x${cmake_c_flags}" != "x" ]; then
  1049. cmake_c_flags="${cmake_c_flags} "
  1050. fi
  1051. if [ "x${cmake_cxx_flags}" != "x" ]; then
  1052. cmake_cxx_flags="${cmake_cxx_flags} "
  1053. fi
  1054. cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1055. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1056. cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
  1057. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  1058. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  1059. echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  1060. for a in ${CMAKE_CXX_SOURCES}; do
  1061. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  1062. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1063. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1064. done
  1065. echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
  1066. for a in ${CMAKE_C_SOURCES}; do
  1067. src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
  1068. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1069. echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1070. done
  1071. for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
  1072. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  1073. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1074. echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1075. done
  1076. for a in ${KWSYS_CXX_SOURCES}; do
  1077. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  1078. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1079. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  1080. done
  1081. if ${cmake_system_mingw}; then
  1082. src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
  1083. in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
  1084. cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
  1085. a="cmsysProcessFwd9xEnc"
  1086. echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
  1087. echo " ${cmake_c_compiler} ${LDFLAGS} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
  1088. echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
  1089. echo " ${cmake_c_compiler} ${LDFLAGS} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
  1090. echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
  1091. echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
  1092. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  1093. 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"
  1094. fi
  1095. cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
  1096. rebuild_cache:
  1097. cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
  1098. EOF
  1099. # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
  1100. cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
  1101. # Generated by ${cmake_source_dir}/bootstrap
  1102. # Default cmake settings. These may be overridden any settings below.
  1103. SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  1104. SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  1105. SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  1106. SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  1107. EOF
  1108. # Add user-specified settings. Handle relative-path case for
  1109. # specification of cmake_init_file.
  1110. (
  1111. cd "${cmake_binary_dir}"
  1112. if [ -f "${cmake_init_file}" ]; then
  1113. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  1114. fi
  1115. )
  1116. echo "---------------------------------------------"
  1117. # Run make to build bootstrap cmake
  1118. if [ "x${cmake_parallel_make}" != "x" ]; then
  1119. ${cmake_make_processor} ${cmake_make_flags}
  1120. else
  1121. ${cmake_make_processor}
  1122. fi
  1123. RES=$?
  1124. if [ "${RES}" -ne "0" ]; then
  1125. cmake_error 9 "Problem while running ${cmake_make_processor}"
  1126. fi
  1127. cd "${cmake_binary_dir}"
  1128. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  1129. # build with same compiler and make
  1130. CC="${cmake_c_compiler}"
  1131. CXX="${cmake_cxx_compiler}"
  1132. MAKE="${cmake_make_processor}"
  1133. export CC
  1134. export CXX
  1135. export MAKE
  1136. # Run bootstrap CMake to configure real CMake
  1137. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}"
  1138. RES=$?
  1139. if [ "${RES}" -ne "0" ]; then
  1140. cmake_error 11 "Problem while running initial CMake"
  1141. fi
  1142. echo "---------------------------------------------"
  1143. # And we are done. Now just run make
  1144. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."