bootstrap 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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. MAKE_FLAGS="$2"
  203. echo "Try: ${MAKE_PROC}"
  204. "${MAKE_PROC}" ${MAKE_FLAGS}
  205. RES=$?
  206. if [ "${RES}" -ne "0" ]; then
  207. echo "${MAKE_PROC} does not work"
  208. return 1
  209. fi
  210. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  211. echo "${COMPILER} does not produce output"
  212. return 2
  213. fi
  214. ./test
  215. RES=$?
  216. rm -f "test"
  217. if [ "${RES}" -ne "0" ]; then
  218. echo "${MAKE_PROC} produces strange executable"
  219. return 3
  220. fi
  221. echo "${MAKE_PROC} works"
  222. return 0
  223. }
  224. # Parse arguments
  225. cmake_verbose=
  226. cmake_parallel_make=
  227. cmake_prefix_dir="/usr/local"
  228. for a in "$@"; do
  229. if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
  230. cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
  231. fi
  232. if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
  233. cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
  234. fi
  235. if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
  236. cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
  237. fi
  238. if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
  239. cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
  240. fi
  241. if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
  242. cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
  243. fi
  244. if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
  245. cmake_init_file=`echo $a | sed "s/^--init=//"`
  246. fi
  247. if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
  248. cmake_usage
  249. fi
  250. if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
  251. cmake_version
  252. exit 2
  253. fi
  254. if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
  255. cmake_verbose=TRUE
  256. fi
  257. done
  258. # If verbose, display some information about bootstrap
  259. if [ -n "${cmake_verbose}" ]; then
  260. echo "---------------------------------------------"
  261. echo "Source directory: ${cmake_source_dir}"
  262. echo "Binary directory: ${cmake_binary_dir}"
  263. echo "Prefix directory: ${cmake_prefix_dir}"
  264. echo "System: ${cmake_system}"
  265. if [ "x${cmake_parallel_make}" != "x" ]; then
  266. echo "Doing parallel make: ${cmake_parallel_make}"
  267. fi
  268. echo ""
  269. fi
  270. echo "---------------------------------------------"
  271. # Get CMake version
  272. echo "`cmake_version`"
  273. # Make bootstrap directory
  274. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  275. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  276. cmake_error "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  277. fi
  278. cd "${cmake_bootstrap_dir}"
  279. [ -d "cmsys" ] || mkdir "cmsys"
  280. if [ ! -d "cmsys" ]; then
  281. cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  282. fi
  283. [ -d "cmsys/std" ] || mkdir "cmsys/std"
  284. if [ ! -d "cmsys/std" ]; then
  285. cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys/std"
  286. fi
  287. # Delete all the bootstrap files
  288. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  289. rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
  290. # If exist compiler flags, set them
  291. cmake_c_flags=${CFLAGS}
  292. cmake_cxx_flags=${CXXFLAGS}
  293. # Test C compiler
  294. cmake_c_compiler=
  295. # If CC is set, use that for compiler, otherwise use list of known compilers
  296. if [ -n "${CC}" ]; then
  297. cmake_c_compilers="${CC}"
  298. else
  299. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  300. fi
  301. # Check if C compiler works
  302. TMPFILE=`cmake_tmp_file`
  303. cat > "${TMPFILE}.c" <<EOF
  304. #include<stdio.h>
  305. int main()
  306. {
  307. printf("1\n");
  308. return 0;
  309. }
  310. EOF
  311. for a in ${cmake_c_compilers}; do
  312. if [ -z "${cmake_c_compiler}" ] && cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  313. cmake_c_compiler="${a}"
  314. fi
  315. done
  316. rm -f "${TMPFILE}.c"
  317. if [ -z "${cmake_c_compiler}" ]; then
  318. cmake_error "Cannot find apropriate C compiler on this system.
  319. Please specify one using environment variable CC."
  320. fi
  321. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  322. # Test CXX compiler
  323. cmake_cxx_compiler=
  324. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  325. # If CC is set, use that for compiler, otherwise use list of known compilers
  326. if [ -n "${CXX}" ]; then
  327. cmake_cxx_compilers="${CXX}"
  328. else
  329. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  330. fi
  331. # Check if C++ compiler works
  332. TMPFILE=`cmake_tmp_file`
  333. cat > "${TMPFILE}.cxx" <<EOF
  334. #include <stdio.h>
  335. class NeedCXX
  336. {
  337. public:
  338. NeedCXX() { this->Foo = 1; }
  339. int GetFoo() { return this->Foo; }
  340. private:
  341. int Foo;
  342. };
  343. int main()
  344. {
  345. NeedCXX c;
  346. printf("%d\n", c.GetFoo());
  347. return 0;
  348. }
  349. EOF
  350. for a in ${cmake_cxx_compilers}; do
  351. if [ -z "${cmake_cxx_compiler}" ] && cmake_try_run "${a}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  352. cmake_cxx_compiler="${a}"
  353. fi
  354. done
  355. rm -f "${TMPFILE}.cxx"
  356. if [ -z "${cmake_cxx_compiler}" ]; then
  357. cmake_error "Cannot find apropriate C++ compiler on this system.
  358. Please specify one using environment variable CXX."
  359. fi
  360. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  361. # Test Make
  362. cmake_make_processor=
  363. cmake_make_flags=
  364. # If MAKE is set, use that for make processor, otherwise use list of known make
  365. if [ -n "${MAKE}" ]; then
  366. cmake_make_processors="${MAKE}"
  367. else
  368. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  369. fi
  370. TMPFILE="`cmake_tmp_file`_dir"
  371. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  372. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  373. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  374. cat>"Makefile"<<EOF
  375. test: test.c
  376. "${cmake_c_compiler}" -o test test.c
  377. EOF
  378. cat>"test.c"<<EOF
  379. #include <stdio.h>
  380. int main(){ printf("1\n"); return 0; }
  381. EOF
  382. if [ "x${cmake_parallel_make}" != "x" ]; then
  383. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  384. fi
  385. for a in ${cmake_make_processors}; do
  386. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
  387. cmake_make_processor="${a}"
  388. fi
  389. done
  390. cd "${cmake_bootstrap_dir}"
  391. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  392. if [ -z "${cmake_make_processor}" ]; then
  393. cmake_error "Cannot find apropriate Makefile processor on this system.
  394. Please specify one using environment variable MAKE."
  395. fi
  396. echo "Make processor on this system is: ${cmake_make_processor}"
  397. # Ok, we have CC, CXX, and MAKE.
  398. # Test C++ compiler features
  399. # If we are on IRIX, check for -LANG:std
  400. cmake_test_flags="-LANG:std"
  401. if [ "x${cmake_system}" = "xIRIX64" ]; then
  402. TMPFILE=`cmake_tmp_file`
  403. cat > ${TMPFILE}.cxx <<EOF
  404. #include <iostream>
  405. int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
  406. EOF
  407. cmake_need_lang_std=0
  408. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  409. :
  410. else
  411. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  412. cmake_need_lang_std=1
  413. fi
  414. fi
  415. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  416. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  417. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  418. else
  419. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  420. fi
  421. rm -f "${TMPFILE}.cxx"
  422. fi
  423. cmake_test_flags=
  424. # If we are on OSF, check for -timplicit_local -no_implicit_include
  425. cmake_test_flags="-timplicit_local -no_implicit_include"
  426. if [ "x${cmake_system}" = "xOSF1" ]; then
  427. TMPFILE=`cmake_tmp_file`
  428. cat > ${TMPFILE}.cxx <<EOF
  429. #include <iostream>
  430. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  431. EOF
  432. cmake_need_flags=1
  433. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  434. :
  435. else
  436. cmake_need_flags=0
  437. fi
  438. if [ "x${cmake_need_flags}" = "x1" ]; then
  439. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  440. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  441. else
  442. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  443. fi
  444. rm -f "${TMPFILE}.cxx"
  445. fi
  446. cmake_test_flags=
  447. # If we are on OSF, check for -std strict_ansi -nopure_cname
  448. cmake_test_flags="-std strict_ansi -nopure_cname"
  449. if [ "x${cmake_system}" = "xOSF1" ]; then
  450. TMPFILE=`cmake_tmp_file`
  451. cat > ${TMPFILE}.cxx <<EOF
  452. #include <iostream>
  453. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  454. EOF
  455. cmake_need_flags=1
  456. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  457. :
  458. else
  459. cmake_need_flags=0
  460. fi
  461. if [ "x${cmake_need_flags}" = "x1" ]; then
  462. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  463. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  464. else
  465. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  466. fi
  467. rm -f "${TMPFILE}.cxx"
  468. fi
  469. cmake_test_flags=
  470. # If we are on HP-UX, check for -Ae for the C compiler.
  471. cmake_test_flags="-Ae"
  472. if [ "x${cmake_system}" = "xHP-UX" ]; then
  473. TMPFILE=`cmake_tmp_file`
  474. cat > ${TMPFILE}.c <<EOF
  475. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  476. EOF
  477. cmake_need_Ae=0
  478. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  479. :
  480. else
  481. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  482. cmake_need_Ae=1
  483. fi
  484. fi
  485. if [ "x${cmake_need_Ae}" = "x1" ]; then
  486. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  487. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  488. else
  489. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  490. fi
  491. rm -f "${TMPFILE}.c"
  492. fi
  493. cmake_test_flags=
  494. # Just to be safe, let us store compiler and flags to the header file
  495. cmake_report cmConfigure.h.tmp "/*"
  496. cmake_report cmConfigure.h.tmp " * Generated by ${cmake_source_dir}/bootstrap"
  497. cmake_report cmConfigure.h.tmp " * Binary directory: ${cmake_bootstrap_dir}"
  498. cmake_report cmConfigure.h.tmp " * C compiler: ${cmake_c_compiler}"
  499. cmake_report cmConfigure.h.tmp " * C flags: ${cmake_c_flags}"
  500. cmake_report cmConfigure.h.tmp " *"
  501. cmake_report cmConfigure.h.tmp " * C++ compiler: ${cmake_cxx_compiler}"
  502. cmake_report cmConfigure.h.tmp " * C++ flags: ${cmake_cxx_flags}"
  503. cmake_report cmConfigure.h.tmp " *"
  504. cmake_report cmConfigure.h.tmp " * Make: ${cmake_make_processor}"
  505. cmake_report cmConfigure.h.tmp " *"
  506. cmake_report cmConfigure.h.tmp " * Sources:"
  507. cmake_report cmConfigure.h.tmp " * ${CMAKE_SOURCES}"
  508. cmake_report cmConfigure.h.tmp " * kwSys Sources:"
  509. cmake_report cmConfigure.h.tmp " * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}"
  510. cmake_report cmConfigure.h.tmp " */"
  511. # Test for STD namespace
  512. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForSTDNamespace.cxx" >> cmake_bootstrap.log 2>&1; then
  513. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
  514. cmake_report cmConfigure.h.tmp "#define cmsys_std std"
  515. echo "${cmake_cxx_compiler} has STD namespace"
  516. else
  517. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
  518. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_STD_NAMESPACE"
  519. cmake_report cmConfigure.h.tmp "#define cmsys_std"
  520. echo "${cmake_cxx_compiler} does not have STD namespace"
  521. fi
  522. # Test for ANSI stream headers
  523. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForANSIStreamHeaders.cxx" >> cmake_bootstrap.log 2>&1; then
  524. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
  525. echo "${cmake_cxx_compiler} has ANSI stream headers"
  526. else
  527. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
  528. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STREAM_HEADERS 1"
  529. cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STREAM_HEADERS"
  530. echo "${cmake_cxx_compiler} does not have ANSI stream headers"
  531. fi
  532. # Test for ansi string streams
  533. TMPFILE=`cmake_tmp_file`
  534. cat>${TMPFILE}.cxx<<EOF
  535. #include <sstream>
  536. int main() { return 0;}
  537. EOF
  538. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  539. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
  540. echo "${cmake_cxx_compiler} has ANSI string streams"
  541. else
  542. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
  543. cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STRING_STREAM 1"
  544. cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STRING_STREAM 1"
  545. echo "${cmake_cxx_compiler} does not have ANSI string streams"
  546. fi
  547. rm -f "${TMPFILE}.cxx"
  548. # Test for ansi FOR scope
  549. if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
  550. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
  551. echo "${cmake_cxx_compiler} has ANSI for scoping"
  552. else
  553. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
  554. echo "${cmake_cxx_compiler} does not have ANSI for scoping"
  555. fi
  556. cmake_report cmConfigure.h.tmp "/* Defined if std namespace is the GCC hack. */"
  557. cmake_report cmConfigure.h.tmp "#if defined(__GNUC__) && (__GNUC__ < 3)"
  558. cmake_report cmConfigure.h.tmp "# define cmsys_FAKE_STD_NAMESPACE"
  559. cmake_report cmConfigure.h.tmp "#endif"
  560. cmake_report cmConfigure.h.tmp "#define kwsys_std cmsys_std"
  561. # Write CMake version
  562. for a in MAJOR MINOR PATCH; do
  563. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  564. cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
  565. done
  566. cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
  567. cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
  568. cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
  569. # Regenerate real cmConfigure.h
  570. if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
  571. rm -f cmConfigure.h.tmp
  572. else
  573. mv -f cmConfigure.h.tmp cmConfigure.h
  574. cp cmConfigure.h cmsys/Configure.hxx
  575. fi
  576. # Prepare KWSYS
  577. for a in ${KWSYS_FILES}; do
  578. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  579. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  580. done
  581. for a in ${KWSYS_STD_FILES}; do
  582. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std_${a}.h.in" \
  583. "${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_NAMESPACE cmsys
  584. done
  585. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std.h.in" \
  586. "${cmake_bootstrap_dir}/cmsys/std/stl.h.in" KWSYS_NAMESPACE cmsys
  587. cmake_replace_string "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  588. "${cmake_bootstrap_dir}/cmsys/Configure.h.in" KWSYS_NAMESPACE cmsys
  589. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/Configure.h.in" \
  590. "${cmake_bootstrap_dir}/cmsys/Configure.h" KWSYS_BUILD_SHARED 0
  591. for a in string vector; do
  592. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/std/stl.h.in" \
  593. "${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_STL_HEADER ${a}
  594. done
  595. # Generate Makefile
  596. dep="cmConfigure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  597. objs=""
  598. for a in ${CMAKE_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
  599. objs="${objs} ${a}.o"
  600. done
  601. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  602. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  603. fi
  604. if [ "x${cmake_c_flags}" != "x" ]; then
  605. cmake_c_flags="${cmake_c_flags} "
  606. fi
  607. if [ "x${cmake_cxx_flags}" != "x" ]; then
  608. cmake_cxx_flags="${cmake_cxx_flags} "
  609. fi
  610. cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  611. cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  612. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  613. echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  614. for a in ${CMAKE_SOURCES}; do
  615. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  616. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  617. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  618. done
  619. for a in ${KWSYS_C_SOURCES}; do
  620. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  621. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  622. echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  623. done
  624. for a in ${KWSYS_CXX_SOURCES}; do
  625. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  626. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  627. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  628. done
  629. cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
  630. rebuild_cache:
  631. cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
  632. EOF
  633. # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
  634. cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
  635. # Generated by ${cmake_source_dir}/bootstrap
  636. # Default cmake settings. These may be overridden any settings below.
  637. SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  638. SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  639. SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  640. SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  641. EOF
  642. # Add user-specified settings. Handle relative-path case for
  643. # specification of cmake_init_file.
  644. (
  645. cd "${cmake_binary_dir}"
  646. if [ -f "${cmake_init_file}" ]; then
  647. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  648. fi
  649. )
  650. echo "---------------------------------------------"
  651. # Run make to build bootstrap cmake
  652. if [ "x${cmake_parallel_make}" != "x" ]; then
  653. ${cmake_make_processor} ${cmake_make_flags}
  654. else
  655. ${cmake_make_processor}
  656. fi
  657. RES=$?
  658. if [ "${RES}" -ne "0" ]; then
  659. cmake_error "Problem while bootstrapping CMake"
  660. fi
  661. cd "${cmake_binary_dir}"
  662. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  663. # build with same compiler and make
  664. CC="${cmake_c_compiler}"
  665. CXX="${cmake_cxx_compiler}"
  666. MAKE="${cmake_make_processor}"
  667. export CC
  668. export CXX
  669. export MAKE
  670. # Run bootstrap CMake to configure real CMake
  671. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  672. echo "---------------------------------------------"
  673. # And we are done. Now just run make
  674. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."