bootstrap 20 KB

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