bootstrap 20 KB

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