bootstrap 24 KB

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