bootstrap 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
  19. CMAKE_KNOWN_CXX_COMPILERS="CC g++ c++ xlC icc como aCC"
  20. CMAKE_KNOWN_MAKE_PROCESSORS="make gmake"
  21. CMAKE_SOURCES="\
  22. cmake \
  23. cmakewizard \
  24. cmakemain \
  25. cmMakeDepend \
  26. cmMakefile \
  27. cmDocumentation \
  28. cmGlob \
  29. cmGlobalGenerator \
  30. cmLocalGenerator \
  31. cmSourceFile \
  32. cmSystemTools \
  33. cmGlobalUnixMakefileGenerator \
  34. cmLocalUnixMakefileGenerator \
  35. cmCommands \
  36. cmTarget \
  37. cmCustomCommand \
  38. cmCacheManager \
  39. cmListFileCache \
  40. cmVariableWatch \
  41. cmSourceGroup"
  42. KWSYS_C_SOURCES="\
  43. ProcessUNIX"
  44. KWSYS_CXX_SOURCES="\
  45. Directory \
  46. RegularExpression \
  47. SystemTools"
  48. KWSYS_FILES="\
  49. Directory.hxx \
  50. Process.h \
  51. RegularExpression.hxx \
  52. SystemTools.hxx"
  53. KWSYS_STD_FILES="
  54. fstream \
  55. iosfwd \
  56. iostream \
  57. sstream"
  58. cmake_system=`uname`
  59. cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
  60. cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
  61. cmake_binary_dir=`pwd`
  62. cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
  63. cmake_data_dir="/share/CMake"
  64. cmake_doc_dir="/doc/CMake"
  65. cmake_man_dir="/man"
  66. cmake_init_file=""
  67. # Display CMake bootstrap usage
  68. cmake_usage()
  69. {
  70. cat <<EOF
  71. Usage: $0 [options]
  72. Options: [defaults in brackets after descriptions]
  73. Configuration:
  74. --help print this message
  75. --version only print version information
  76. --verbose display more information
  77. --parallel=n bootstrap cmake in parallel, where n is
  78. number of nodes [1]
  79. --init=FILE use FILE for cmake initialization
  80. Directory and file names:
  81. --prefix=PREFIX install files in tree rooted at PREFIX
  82. [/usr/local]
  83. --datadir=DIR install data files in PREFIX/DIR
  84. [/share/CMake]
  85. --docdir=DIR install documentation files in PREFIX/DIR
  86. [/doc/CMake]
  87. --mandir=DIR install man pages files in PREFIX/DIR/manN
  88. [/man]
  89. EOF
  90. exit 10
  91. }
  92. # Display CMake bootstrap usage
  93. cmake_version()
  94. {
  95. # Get CMake version
  96. CMAKE_VERSION=""
  97. for a in MAJOR MINOR PATCH; do
  98. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  99. CMAKE_VERSION="${CMAKE_VERSION}.${CMake_VERSION}"
  100. done
  101. CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-\3/"`
  102. echo "CMake ${CMAKE_VERSION}, Copyright (c) 2002 Kitware, Inc., Insight Consortium"
  103. }
  104. # Display CMake bootstrap error, display the log file and exit
  105. cmake_error()
  106. {
  107. echo "---------------------------------------------"
  108. echo "Error when bootstrapping CMake:"
  109. echo "$*"
  110. echo "---------------------------------------------"
  111. if [ -f cmake_bootstrap.log ]; then
  112. echo "Log of errors:"
  113. cat cmake_bootstrap.log
  114. echo "---------------------------------------------"
  115. fi
  116. exit 1
  117. }
  118. # Replace KWSYS_NAMESPACE with cmsys
  119. cmake_replace_string ()
  120. {
  121. INFILE="$1"
  122. OUTFILE="$2"
  123. SEARCHFOR="$3"
  124. REPLACEWITH="$4"
  125. if [ -f "${INFILE}" ]; then
  126. cat "${INFILE}" |
  127. sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
  128. if [ -f "${OUTFILE}.tmp" ]; then
  129. if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
  130. #echo "Files are the same"
  131. rm -f "${OUTFILE}.tmp"
  132. else
  133. mv -f "${OUTFILE}.tmp" "${OUTFILE}"
  134. fi
  135. fi
  136. else
  137. cmake_error "Cannot find file ${INFILE}"
  138. fi
  139. }
  140. # Write string into a file
  141. cmake_report ()
  142. {
  143. FILE=$1
  144. shift
  145. echo "$*" >> ${FILE}
  146. }
  147. # Escape spaces in strings
  148. cmake_escape ()
  149. {
  150. echo $1 | sed "s/ /\\\\ /g"
  151. }
  152. # Write message to the log
  153. cmake_log ()
  154. {
  155. echo "$*" >> cmake_bootstrap.log
  156. }
  157. # Return temp file
  158. cmake_tmp_file ()
  159. {
  160. echo "cmake_bootstrap_$$.test"
  161. }
  162. # Run a compiler test. First argument is compiler, second one are compiler
  163. # flags, third one is test source file to be compiled
  164. cmake_try_run ()
  165. {
  166. COMPILER=$1
  167. FLAGS=$2
  168. TESTFILE=$3
  169. if [ ! -f "${TESTFILE}" ]; then
  170. echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
  171. exit 4
  172. fi
  173. TMPFILE=`cmake_tmp_file`
  174. echo "Try: ${COMPILER}"
  175. echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  176. echo "---------- file -----------------------"
  177. cat ${TESTFILE}
  178. echo "------------------------------------------"
  179. "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  180. RES=$?
  181. if [ "${RES}" -ne "0" ]; then
  182. echo "${COMPILER} does not work";return 1
  183. fi
  184. if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
  185. echo "${COMPILER} does not produce output"
  186. return 2
  187. fi
  188. ./${TMPFILE}
  189. RES=$?
  190. rm -f "${TMPFILE}"
  191. if [ "${RES}" -ne "0" ]; then
  192. echo "${COMPILER} produces strange executable"
  193. return 3
  194. fi
  195. echo "${COMPILER} works"
  196. return 0
  197. }
  198. # Run a make test. First argument is the make interpreter.
  199. cmake_try_make ()
  200. {
  201. MAKE_PROC=$1
  202. echo "Try: ${MAKE_PROC}"
  203. ${MAKE_PROC}
  204. RES=$?
  205. if [ "${RES}" -ne "0" ]; then
  206. echo "${MAKE_PROC} does not work";return 1
  207. fi
  208. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  209. echo "${COMPILER} does not produce output"
  210. return 2
  211. fi
  212. ./test
  213. RES=$?
  214. rm -f "test"
  215. if [ "${RES}" -ne "0" ]; then
  216. echo "${MAKE_PROC} produces strange executable"
  217. return 3
  218. fi
  219. echo "${MAKE_PROC} works"
  220. return 0
  221. }
  222. # Parse arguments
  223. cmake_verbose=
  224. cmake_parallel_make=
  225. cmake_prefix_dir="/usr/local"
  226. for a in "$@"; do
  227. if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
  228. cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
  229. fi
  230. if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
  231. cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
  232. fi
  233. if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
  234. cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
  235. fi
  236. if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
  237. cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
  238. fi
  239. if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
  240. cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
  241. fi
  242. if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
  243. cmake_init_file=`echo $a | sed "s/^--init=//"`
  244. fi
  245. if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
  246. cmake_usage
  247. fi
  248. if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
  249. cmake_version
  250. exit 2
  251. fi
  252. if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
  253. cmake_verbose=TRUE
  254. fi
  255. done
  256. # If verbose, display some information about bootstrap
  257. if [ -n "${cmake_verbose}" ]; then
  258. echo "---------------------------------------------"
  259. echo "Source directory: ${cmake_source_dir}"
  260. echo "Binary directory: ${cmake_binary_dir}"
  261. echo "Prefix directory: ${cmake_prefix_dir}"
  262. echo "System: ${cmake_system}"
  263. if [ "x${cmake_parallel_make}" != "x" ]; then
  264. echo "Doing parallel make: ${cmake_parallel_make}"
  265. fi
  266. echo ""
  267. fi
  268. echo "---------------------------------------------"
  269. # Get CMake version
  270. echo "`cmake_version`"
  271. # Make bootstrap directory
  272. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  273. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  274. cmake_error "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  275. fi
  276. cd "${cmake_bootstrap_dir}"
  277. [ -d "cmsys" ] || mkdir "cmsys"
  278. if [ ! -d "cmsys" ]; then
  279. cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  280. fi
  281. [ -d "cmsys/std" ] || mkdir "cmsys/std"
  282. if [ ! -d "cmsys/std" ]; then
  283. cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys/std"
  284. fi
  285. # Delete all the bootstrap files
  286. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  287. rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
  288. # If exist compiler flags, set them
  289. cmake_c_flags=${CFLAGS}
  290. cmake_cxx_flags=${CXXFLAGS}
  291. # Test C compiler
  292. cmake_c_compiler=
  293. # If CC is set, use that for compiler, otherwise use list of known compilers
  294. if [ -n "${CC}" ]; then
  295. cmake_c_compilers="${CC}"
  296. else
  297. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  298. fi
  299. # Check if C compiler works
  300. TMPFILE=`cmake_tmp_file`
  301. cat > "${TMPFILE}.c" <<EOF
  302. #include<stdio.h>
  303. int main()
  304. {
  305. printf("1\n");
  306. return 0;
  307. }
  308. EOF
  309. for a in ${cmake_c_compilers}; do
  310. if [ -z "${cmake_c_compiler}" ] && cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  311. cmake_c_compiler="${a}"
  312. fi
  313. done
  314. rm -f "${TMPFILE}.c"
  315. if [ -z "${cmake_c_compiler}" ]; then
  316. cmake_error "Cannot find apropriate C compiler on this system.
  317. Please specify one using environment variable CC."
  318. fi
  319. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  320. # Test CXX compiler
  321. cmake_cxx_compiler=
  322. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  323. # If CC is set, use that for compiler, otherwise use list of known compilers
  324. if [ -n "${CXX}" ]; then
  325. cmake_cxx_compilers="${CXX}"
  326. else
  327. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  328. fi
  329. # Check if C++ compiler works
  330. TMPFILE=`cmake_tmp_file`
  331. cat > "${TMPFILE}.cxx" <<EOF
  332. #include <stdio.h>
  333. class NeedCXX
  334. {
  335. public:
  336. NeedCXX() { this->Foo = 1; }
  337. int GetFoo() { return this->Foo; }
  338. private:
  339. int Foo;
  340. };
  341. int main()
  342. {
  343. NeedCXX c;
  344. printf("%d\n", c.GetFoo());
  345. return 0;
  346. }
  347. EOF
  348. for a in ${cmake_cxx_compilers}; do
  349. if [ -z "${cmake_cxx_compiler}" ] && cmake_try_run "${a}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  350. cmake_cxx_compiler="${a}"
  351. fi
  352. done
  353. rm -f "${TMPFILE}.cxx"
  354. if [ -z "${cmake_cxx_compiler}" ]; then
  355. cmake_error "Cannot find apropriate C++ compiler on this system.
  356. Please specify one using environment variable CXX."
  357. fi
  358. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  359. # Test Make
  360. cmake_make_processor=
  361. # If MAKE is set, use that for make processor, otherwise use list of known make
  362. if [ -n "${MAKE}" ]; then
  363. cmake_make_processors="${MAKE}"
  364. else
  365. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  366. fi
  367. TMPFILE="`cmake_tmp_file`_dir"
  368. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  369. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  370. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  371. cat>"Makefile"<<EOF
  372. test: test.c
  373. ${cmake_c_compiler} -o test test.c
  374. EOF
  375. cat>"test.c"<<EOF
  376. #include <stdio.h>
  377. int main(){ printf("1\n"); return 0; }
  378. EOF
  379. for a in ${cmake_make_processors}; do
  380. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" >> cmake_bootstrap.log 2>&1; then
  381. cmake_make_processor="${a}"
  382. fi
  383. done
  384. cd "${cmake_bootstrap_dir}"
  385. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  386. echo "Make processor on this system is: ${cmake_make_processor}"
  387. # Ok, we have CC, CXX, and MAKE.
  388. # Test C++ compiler features
  389. # If we are on IRIX, check for -LANG:std
  390. cmake_test_flags="-LANG:std"
  391. if [ "x${cmake_system}" = "xIRIX64" ]; then
  392. TMPFILE=`cmake_tmp_file`
  393. cat > ${TMPFILE}.cxx <<EOF
  394. #include <iostream>
  395. int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
  396. EOF
  397. cmake_need_lang_std=0
  398. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  399. :
  400. else
  401. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  402. cmake_need_lang_std=1
  403. fi
  404. fi
  405. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  406. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  407. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  408. else
  409. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  410. fi
  411. rm -f "${TMPFILE}.cxx"
  412. fi
  413. cmake_test_flags=
  414. # If we are on OSF, check for -timplicit_local -no_implicit_include
  415. cmake_test_flags="-timplicit_local -no_implicit_include"
  416. if [ "x${cmake_system}" = "xOSF1" ]; then
  417. TMPFILE=`cmake_tmp_file`
  418. cat > ${TMPFILE}.cxx <<EOF
  419. #include <iostream>
  420. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  421. EOF
  422. cmake_need_flags=1
  423. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  424. :
  425. else
  426. cmake_need_flags=0
  427. fi
  428. if [ "x${cmake_need_flags}" = "x1" ]; then
  429. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  430. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  431. else
  432. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  433. fi
  434. rm -f "${TMPFILE}.cxx"
  435. fi
  436. cmake_test_flags=
  437. # If we are on OSF, check for -std strict_ansi -nopure_cname
  438. cmake_test_flags="-std strict_ansi -nopure_cname"
  439. if [ "x${cmake_system}" = "xOSF1" ]; then
  440. TMPFILE=`cmake_tmp_file`
  441. cat > ${TMPFILE}.cxx <<EOF
  442. #include <iostream>
  443. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  444. EOF
  445. cmake_need_flags=1
  446. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  447. :
  448. else
  449. cmake_need_flags=0
  450. fi
  451. if [ "x${cmake_need_flags}" = "x1" ]; then
  452. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  453. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  454. else
  455. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  456. fi
  457. rm -f "${TMPFILE}.cxx"
  458. fi
  459. cmake_test_flags=
  460. # Just to be safe, let us store compiler and flags to the header file
  461. cmake_report cmConfigure.h.tmp "/*"
  462. cmake_report cmConfigure.h.tmp " * Generated by ${cmake_source_dir}/bootstrap"
  463. cmake_report cmConfigure.h.tmp " * Binary directory: ${cmake_bootstrap_dir}"
  464. cmake_report cmConfigure.h.tmp " * C compiler: ${cmake_c_compiler}"
  465. cmake_report cmConfigure.h.tmp " * C flags: ${cmake_c_flags}"
  466. cmake_report cmConfigure.h.tmp " *"
  467. cmake_report cmConfigure.h.tmp " * C++ compiler: ${cmake_cxx_compiler}"
  468. cmake_report cmConfigure.h.tmp " * C++ flags: ${cmake_cxx_flags}"
  469. cmake_report cmConfigure.h.tmp " *"
  470. cmake_report cmConfigure.h.tmp " * Make: ${cmake_make_processor}"
  471. cmake_report cmConfigure.h.tmp " *"
  472. cmake_report cmConfigure.h.tmp " * Sources:"
  473. cmake_report cmConfigure.h.tmp " * ${CMAKE_SOURCES}"
  474. cmake_report cmConfigure.h.tmp " * kwSys Sources:"
  475. cmake_report cmConfigure.h.tmp " * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}"
  476. cmake_report cmConfigure.h.tmp " */"
  477. # Test for STD namespace
  478. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForSTDNamespace.cxx" >> cmake_bootstrap.log 2>&1; then
  479. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
  480. cmake_report cmConfigure.h.tmp "#define cmsys_std std"
  481. echo "${cmake_cxx_compiler} has STD namespace"
  482. else
  483. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
  484. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_STD_NAMESPACE"
  485. cmake_report cmConfigure.h.tmp "#define cmsys_std"
  486. echo "${cmake_cxx_compiler} does not have STD namespace"
  487. fi
  488. # Test for ANSI stream headers
  489. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForANSIStreamHeaders.cxx" >> cmake_bootstrap.log 2>&1; then
  490. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
  491. echo "${cmake_cxx_compiler} has ANSI stream headers"
  492. else
  493. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
  494. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STREAM_HEADERS 1"
  495. cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STREAM_HEADERS"
  496. echo "${cmake_cxx_compiler} does not have ANSI stream headers"
  497. fi
  498. # Test for ansi string streams
  499. TMPFILE=`cmake_tmp_file`
  500. cat>${TMPFILE}.cxx<<EOF
  501. #include <sstream>
  502. int main() { return 0;}
  503. EOF
  504. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  505. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
  506. echo "${cmake_cxx_compiler} has ANSI string streams"
  507. else
  508. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
  509. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STRING_STREAM 1"
  510. cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STRING_STREAM 1"
  511. echo "${cmake_cxx_compiler} does not have ANSI string streams"
  512. fi
  513. rm -f "${TMPFILE}.cxx"
  514. # Test for ansi FOR scope
  515. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
  516. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
  517. echo "${cmake_cxx_compiler} has ANSI for scoping"
  518. else
  519. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
  520. echo "${cmake_cxx_compiler} does not have ANSI for scoping"
  521. fi
  522. cmake_report cmConfigure.h.tmp "/* Defined if std namespace is the GCC hack. */"
  523. cmake_report cmConfigure.h.tmp "#if defined(__GNUC__) && (__GNUC__ < 3)"
  524. cmake_report cmConfigure.h.tmp "# define cmsys_FAKE_STD_NAMESPACE"
  525. cmake_report cmConfigure.h.tmp "#endif"
  526. cmake_report cmConfigure.h.tmp "#define kwsys_std cmsys_std"
  527. # Write CMake version
  528. for a in MAJOR MINOR PATCH; do
  529. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  530. cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
  531. done
  532. cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
  533. cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
  534. cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
  535. # Regenerate real cmConfigure.h
  536. if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
  537. rm -f cmConfigure.h.tmp
  538. else
  539. mv -f cmConfigure.h.tmp cmConfigure.h
  540. cp cmConfigure.h cmsys/Configure.hxx
  541. fi
  542. # Prepare KWSYS
  543. for a in ${KWSYS_FILES}; do
  544. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  545. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  546. done
  547. for a in ${KWSYS_STD_FILES}; do
  548. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std_${a}.h.in" \
  549. "${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_NAMESPACE cmsys
  550. done
  551. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std.h.in" \
  552. "${cmake_bootstrap_dir}/cmsys/std/stl.h.in" KWSYS_NAMESPACE cmsys
  553. cmake_replace_string "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  554. "${cmake_bootstrap_dir}/cmsys/Configure.h.in" KWSYS_NAMESPACE cmsys
  555. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/Configure.h.in" \
  556. "${cmake_bootstrap_dir}/cmsys/Configure.h" KWSYS_BUILD_SHARED 0
  557. for a in string vector; do
  558. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/std/stl.h.in" \
  559. "${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_STL_HEADER ${a}
  560. done
  561. # Generate Makefile
  562. dep="cmConfigure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  563. objs=""
  564. for a in ${CMAKE_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
  565. objs="${objs} ${a}.o"
  566. done
  567. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  568. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  569. fi
  570. if [ "x${cmake_cxx_flags}" != "x" ]; then
  571. cmake_cxx_flags="${cmake_cxx_flags} "
  572. fi
  573. cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  574. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  575. echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  576. for a in ${CMAKE_SOURCES}; do
  577. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  578. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  579. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  580. done
  581. for a in ${KWSYS_C_SOURCES}; do
  582. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  583. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  584. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  585. done
  586. for a in ${KWSYS_CXX_SOURCES}; do
  587. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  588. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  589. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  590. done
  591. # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
  592. cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
  593. # Generated by ${cmake_source_dir}/bootstrap
  594. # Default cmake settings. These may be overridden any settings below.
  595. SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  596. SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  597. SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  598. SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  599. EOF
  600. # Add user-specified settings. Handle relative-path case for
  601. # specification of cmake_init_file.
  602. (
  603. cd "${cmake_binary_dir}"
  604. if [ -f "${cmake_init_file}" ]; then
  605. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  606. fi
  607. )
  608. echo "---------------------------------------------"
  609. # Run make to build bootstrap cmake
  610. if [ "x${cmake_parallel_make}" != "x" ]; then
  611. ${cmake_make_processor} -j ${cmake_parallel_make}
  612. else
  613. ${cmake_make_processor}
  614. fi
  615. RES=$?
  616. if [ "${RES}" -ne "0" ]; then
  617. cmake_error "Problem while bootstrapping CMake"
  618. fi
  619. cd "${cmake_binary_dir}"
  620. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  621. # build with same compiler and make
  622. CC="${cmake_c_compiler}"
  623. CXX="${cmake_cxx_compiler}"
  624. MAKE="${cmake_make_processor}"
  625. export CC
  626. export CXX
  627. export MAKE
  628. # Run bootstrap CMake to configure real CMake
  629. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  630. echo "---------------------------------------------"
  631. # And we are done. Now just run make
  632. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."