bootstrap 43 KB

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