bootstrap 43 KB

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