bootstrap 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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="aCC xlC CC g++ c++ icc como "
  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_IOS_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" | \
  102. grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  103. CMAKE_VERSION="${CMAKE_VERSION}.${CMake_VERSION}"
  104. done
  105. CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-\3/"`
  106. echo "CMake ${CMAKE_VERSION}, Copyright (c) 2002 Kitware, Inc., Insight Consortium"
  107. }
  108. # Display CMake bootstrap error, display the log file and exit
  109. cmake_error()
  110. {
  111. res=$1
  112. shift 1
  113. echo "---------------------------------------------"
  114. echo "Error when bootstrapping CMake:"
  115. echo "$*"
  116. echo "---------------------------------------------"
  117. if [ -f cmake_bootstrap.log ]; then
  118. echo "Log of errors: `pwd`/cmake_bootstrap.log"
  119. #cat cmake_bootstrap.log
  120. echo "---------------------------------------------"
  121. fi
  122. exit ${res}
  123. }
  124. # Replace KWSYS_NAMESPACE with cmsys
  125. cmake_replace_string ()
  126. {
  127. INFILE="$1"
  128. OUTFILE="$2"
  129. SEARCHFOR="$3"
  130. REPLACEWITH="$4"
  131. if [ -f "${INFILE}" ]; then
  132. cat "${INFILE}" |
  133. sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
  134. if [ -f "${OUTFILE}.tmp" ]; then
  135. if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
  136. #echo "Files are the same"
  137. rm -f "${OUTFILE}.tmp"
  138. else
  139. mv -f "${OUTFILE}.tmp" "${OUTFILE}"
  140. fi
  141. fi
  142. else
  143. cmake_error 1 "Cannot find file ${INFILE}"
  144. fi
  145. }
  146. cmake_kwsys_config_replace_string ()
  147. {
  148. INFILE="$1"
  149. OUTFILE="$2"
  150. shift 2
  151. APPEND="$*"
  152. if [ -f "${INFILE}" ]; then
  153. echo "${APPEND}" > "${OUTFILE}.tmp"
  154. cat "${INFILE}" |
  155. sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
  156. s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
  157. s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
  158. s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
  159. s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
  160. s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
  161. s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
  162. s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
  163. s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;}" >> "${OUTFILE}.tmp"
  164. if [ -f "${OUTFILE}.tmp" ]; then
  165. if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
  166. #echo "Files are the same"
  167. rm -f "${OUTFILE}.tmp"
  168. else
  169. mv -f "${OUTFILE}.tmp" "${OUTFILE}"
  170. fi
  171. fi
  172. else
  173. cmake_error 2 "Cannot find file ${INFILE}"
  174. fi
  175. }
  176. # Write string into a file
  177. cmake_report ()
  178. {
  179. FILE=$1
  180. shift
  181. echo "$*" >> ${FILE}
  182. }
  183. # Escape spaces in strings
  184. cmake_escape ()
  185. {
  186. echo $1 | sed "s/ /\\\\ /g"
  187. }
  188. # Write message to the log
  189. cmake_log ()
  190. {
  191. echo "$*" >> cmake_bootstrap.log
  192. }
  193. # Return temp file
  194. cmake_tmp_file ()
  195. {
  196. echo "cmake_bootstrap_$$.test"
  197. }
  198. # Run a compiler test. First argument is compiler, second one are compiler
  199. # flags, third one is test source file to be compiled
  200. cmake_try_run ()
  201. {
  202. COMPILER=$1
  203. FLAGS=$2
  204. TESTFILE=$3
  205. if [ ! -f "${TESTFILE}" ]; then
  206. echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
  207. exit 4
  208. fi
  209. TMPFILE=`cmake_tmp_file`
  210. echo "Try: ${COMPILER}"
  211. echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  212. echo "---------- file -----------------------"
  213. cat ${TESTFILE}
  214. echo "------------------------------------------"
  215. "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  216. RES=$?
  217. if [ "${RES}" -ne "0" ]; then
  218. echo "Test failed to compile"
  219. return 1
  220. fi
  221. if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
  222. echo "Test failed to produce executable"
  223. return 2
  224. fi
  225. ./${TMPFILE}
  226. RES=$?
  227. rm -f "${TMPFILE}"
  228. if [ "${RES}" -ne "0" ]; then
  229. echo "Test produced non-zero return code"
  230. return 3
  231. fi
  232. echo "Test succeded"
  233. return 0
  234. }
  235. # Run a make test. First argument is the make interpreter.
  236. cmake_try_make ()
  237. {
  238. MAKE_PROC="$1"
  239. MAKE_FLAGS="$2"
  240. echo "Try: ${MAKE_PROC}"
  241. "${MAKE_PROC}" ${MAKE_FLAGS}
  242. RES=$?
  243. if [ "${RES}" -ne "0" ]; then
  244. echo "${MAKE_PROC} does not work"
  245. return 1
  246. fi
  247. if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
  248. echo "${COMPILER} does not produce output"
  249. return 2
  250. fi
  251. ./test
  252. RES=$?
  253. rm -f "test"
  254. if [ "${RES}" -ne "0" ]; then
  255. echo "${MAKE_PROC} produces strange executable"
  256. return 3
  257. fi
  258. echo "${MAKE_PROC} works"
  259. return 0
  260. }
  261. # Parse arguments
  262. cmake_verbose=
  263. cmake_parallel_make=
  264. cmake_prefix_dir="/usr/local"
  265. for a in "$@"; do
  266. if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
  267. cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
  268. fi
  269. if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
  270. cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
  271. fi
  272. if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
  273. cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
  274. fi
  275. if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
  276. cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
  277. fi
  278. if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
  279. cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
  280. fi
  281. if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
  282. cmake_init_file=`echo $a | sed "s/^--init=//"`
  283. fi
  284. if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
  285. cmake_usage
  286. fi
  287. if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
  288. cmake_version
  289. exit 2
  290. fi
  291. if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
  292. cmake_verbose=TRUE
  293. fi
  294. done
  295. # If verbose, display some information about bootstrap
  296. if [ -n "${cmake_verbose}" ]; then
  297. echo "---------------------------------------------"
  298. echo "Source directory: ${cmake_source_dir}"
  299. echo "Binary directory: ${cmake_binary_dir}"
  300. echo "Prefix directory: ${cmake_prefix_dir}"
  301. echo "System: ${cmake_system}"
  302. if [ "x${cmake_parallel_make}" != "x" ]; then
  303. echo "Doing parallel make: ${cmake_parallel_make}"
  304. fi
  305. echo ""
  306. fi
  307. echo "---------------------------------------------"
  308. # Get CMake version
  309. echo "`cmake_version`"
  310. # Make bootstrap directory
  311. [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
  312. if [ ! -d "${cmake_bootstrap_dir}" ]; then
  313. cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
  314. fi
  315. cd "${cmake_bootstrap_dir}"
  316. [ -d "cmsys" ] || mkdir "cmsys"
  317. if [ ! -d "cmsys" ]; then
  318. cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
  319. fi
  320. for a in stl ios; do
  321. [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
  322. if [ ! -d "cmsys/${a}" ]; then
  323. cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
  324. fi
  325. done
  326. # Delete all the bootstrap files
  327. rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
  328. rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
  329. # If exist compiler flags, set them
  330. cmake_c_flags=${CFLAGS}
  331. cmake_cxx_flags=${CXXFLAGS}
  332. # Test C compiler
  333. cmake_c_compiler=
  334. # If CC is set, use that for compiler, otherwise use list of known compilers
  335. if [ -n "${CC}" ]; then
  336. cmake_c_compilers="${CC}"
  337. else
  338. cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
  339. fi
  340. # Check if C compiler works
  341. TMPFILE=`cmake_tmp_file`
  342. cat > "${TMPFILE}.c" <<EOF
  343. #include<stdio.h>
  344. int main()
  345. {
  346. printf("1\n");
  347. return 0;
  348. }
  349. EOF
  350. for a in ${cmake_c_compilers}; do
  351. if [ -z "${cmake_c_compiler}" ] && \
  352. cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  353. cmake_c_compiler="${a}"
  354. fi
  355. done
  356. rm -f "${TMPFILE}.c"
  357. if [ -z "${cmake_c_compiler}" ]; then
  358. cmake_error 6 "Cannot find appropriate C compiler on this system.
  359. Please specify one using environment variable CC.
  360. See cmake_bootstrap.log for compilers attempted.
  361. "
  362. fi
  363. echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
  364. # Test CXX compiler
  365. cmake_cxx_compiler=
  366. # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
  367. # If CC is set, use that for compiler, otherwise use list of known compilers
  368. if [ -n "${CXX}" ]; then
  369. cmake_cxx_compilers="${CXX}"
  370. else
  371. cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
  372. fi
  373. # Check if C++ compiler works
  374. TMPFILE=`cmake_tmp_file`
  375. cat > "${TMPFILE}.cxx" <<EOF
  376. #if defined(TEST1)
  377. # include <iostream>
  378. #else
  379. # include <iostream.h>
  380. #endif
  381. class NeedCXX
  382. {
  383. public:
  384. NeedCXX() { this->Foo = 1; }
  385. int GetFoo() { return this->Foo; }
  386. private:
  387. int Foo;
  388. };
  389. int main()
  390. {
  391. NeedCXX c;
  392. #ifdef TEST3
  393. cout << c.GetFoo() << endl;
  394. #else
  395. std::cout << c.GetFoo() << std::endl;
  396. #endif
  397. return 0;
  398. }
  399. EOF
  400. for a in ${cmake_cxx_compilers}; do
  401. for b in 1 2 3; do
  402. if [ -z "${cmake_cxx_compiler}" ] && \
  403. cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  404. cmake_cxx_compiler="${a}"
  405. fi
  406. done
  407. done
  408. rm -f "${TMPFILE}.cxx"
  409. if [ -z "${cmake_cxx_compiler}" ]; then
  410. cmake_error 7 "Cannot find appropriate C++ compiler on this system.
  411. Please specify one using environment variable CXX.
  412. See cmake_bootstrap.log for compilers attempted."
  413. fi
  414. echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
  415. # Test Make
  416. cmake_make_processor=
  417. cmake_make_flags=
  418. # If MAKE is set, use that for make processor, otherwise use list of known make
  419. if [ -n "${MAKE}" ]; then
  420. cmake_make_processors="${MAKE}"
  421. else
  422. cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
  423. fi
  424. TMPFILE="`cmake_tmp_file`_dir"
  425. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  426. mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
  427. cd "${cmake_bootstrap_dir}/${TMPFILE}"
  428. cat>"Makefile"<<EOF
  429. test: test.c
  430. "${cmake_c_compiler}" -o test test.c
  431. EOF
  432. cat>"test.c"<<EOF
  433. #include <stdio.h>
  434. int main(){ printf("1\n"); return 0; }
  435. EOF
  436. cmake_original_make_flags="${cmake_make_flags}"
  437. if [ "x${cmake_parallel_make}" != "x" ]; then
  438. cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  439. fi
  440. for a in ${cmake_make_processors}; do
  441. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
  442. cmake_make_processor="${a}"
  443. fi
  444. done
  445. cmake_full_make_flags="${cmake_make_flags}"
  446. if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
  447. if [ -z "${cmake_make_processor}" ]; then
  448. cmake_make_flags="${cmake_original_make_flags}"
  449. for a in ${cmake_make_processors}; do
  450. if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
  451. cmake_make_processor="${a}"
  452. fi
  453. done
  454. fi
  455. fi
  456. cd "${cmake_bootstrap_dir}"
  457. rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
  458. if [ -z "${cmake_make_processor}" ]; then
  459. cmake_error 8 "Cannot find appropriate Makefile processor on this system.
  460. Please specify one using environment variable MAKE."
  461. fi
  462. echo "Makefile processor on this system is: ${cmake_make_processor}"
  463. if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
  464. echo "---------------------------------------------"
  465. echo "Makefile processor ${cmake_make_processor} does not support parallel build"
  466. echo "---------------------------------------------"
  467. fi
  468. # Ok, we have CC, CXX, and MAKE.
  469. # Test C++ compiler features
  470. # Are we GCC?
  471. TMPFILE=`cmake_tmp_file`
  472. cat > ${TMPFILE}.cxx <<EOF
  473. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  474. #include <iostream>
  475. int main() { std::cout << "This is GNU" << std::endl; return 0;}
  476. #endif
  477. EOF
  478. cmake_cxx_compiler_is_gnu=0
  479. if cmake_try_run "${cmake_cxx_compiler}" \
  480. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  481. cmake_cxx_compiler_is_gnu=1
  482. fi
  483. if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
  484. echo "${cmake_cxx_compiler} is GNU compiler"
  485. else
  486. echo "${cmake_cxx_compiler} is not GNU compiler"
  487. fi
  488. rm -f "${TMPFILE}.cxx"
  489. if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
  490. # Check for non-GNU compiler flags
  491. # If we are on IRIX, check for -LANG:std
  492. cmake_test_flags="-LANG:std"
  493. if [ "x${cmake_system}" = "xIRIX64" ]; then
  494. TMPFILE=`cmake_tmp_file`
  495. cat > ${TMPFILE}.cxx <<EOF
  496. #include <iostream>
  497. int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
  498. EOF
  499. cmake_need_lang_std=0
  500. if cmake_try_run "${cmake_cxx_compiler}" \
  501. "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  502. :
  503. else
  504. if cmake_try_run "${cmake_cxx_compiler}" \
  505. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  506. cmake_need_lang_std=1
  507. fi
  508. fi
  509. if [ "x${cmake_need_lang_std}" = "x1" ]; then
  510. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  511. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  512. else
  513. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  514. fi
  515. rm -f "${TMPFILE}.cxx"
  516. fi
  517. cmake_test_flags=
  518. # If we are on OSF, check for -timplicit_local -no_implicit_include
  519. cmake_test_flags="-timplicit_local -no_implicit_include"
  520. if [ "x${cmake_system}" = "xOSF1" ]; then
  521. TMPFILE=`cmake_tmp_file`
  522. cat > ${TMPFILE}.cxx <<EOF
  523. #include <iostream>
  524. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  525. EOF
  526. cmake_need_flags=1
  527. if cmake_try_run "${cmake_cxx_compiler}" \
  528. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  529. :
  530. else
  531. cmake_need_flags=0
  532. fi
  533. if [ "x${cmake_need_flags}" = "x1" ]; then
  534. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  535. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  536. else
  537. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  538. fi
  539. rm -f "${TMPFILE}.cxx"
  540. fi
  541. cmake_test_flags=
  542. # If we are on OSF, check for -std strict_ansi -nopure_cname
  543. cmake_test_flags="-std strict_ansi -nopure_cname"
  544. if [ "x${cmake_system}" = "xOSF1" ]; then
  545. TMPFILE=`cmake_tmp_file`
  546. cat > ${TMPFILE}.cxx <<EOF
  547. #include <iostream>
  548. int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
  549. EOF
  550. cmake_need_flags=1
  551. if cmake_try_run "${cmake_cxx_compiler}" \
  552. "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
  553. :
  554. else
  555. cmake_need_flags=0
  556. fi
  557. if [ "x${cmake_need_flags}" = "x1" ]; then
  558. cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
  559. echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
  560. else
  561. echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
  562. fi
  563. rm -f "${TMPFILE}.cxx"
  564. fi
  565. cmake_test_flags=
  566. # If we are on HP-UX, check for -Ae for the C compiler.
  567. cmake_test_flags="-Ae"
  568. if [ "x${cmake_system}" = "xHP-UX" ]; then
  569. TMPFILE=`cmake_tmp_file`
  570. cat > ${TMPFILE}.c <<EOF
  571. int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
  572. EOF
  573. cmake_need_Ae=0
  574. if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  575. :
  576. else
  577. if cmake_try_run "${cmake_c_compiler}" \
  578. "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
  579. cmake_need_Ae=1
  580. fi
  581. fi
  582. if [ "x${cmake_need_Ae}" = "x1" ]; then
  583. cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
  584. echo "${cmake_c_compiler} needs ${cmake_test_flags}"
  585. else
  586. echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
  587. fi
  588. rm -f "${TMPFILE}.c"
  589. fi
  590. cmake_test_flags=
  591. fi
  592. # Test for kwsys features
  593. KWSYS_NAME_IS_KWSYS=0
  594. KWSYS_BUILD_SHARED=0
  595. KWSYS_IOS_USE_STRSTREAM_H=0
  596. KWSYS_IOS_USE_STRSTREA_H=0
  597. KWSYS_IOS_HAVE_STD=0
  598. KWSYS_IOS_USE_SSTREAM=0
  599. KWSYS_IOS_USE_ANSI=0
  600. KWSYS_STL_HAVE_STD=0
  601. if cmake_try_run "${cmake_cxx_compiler}" \
  602. "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
  603. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  604. KWSYS_STL_HAVE_STD=1
  605. echo "${cmake_cxx_compiler} has STL in std:: namespace"
  606. else
  607. echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
  608. fi
  609. if cmake_try_run "${cmake_cxx_compiler}" \
  610. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
  611. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  612. KWSYS_IOS_USE_ANSI=1
  613. echo "${cmake_cxx_compiler} has ANSI streams"
  614. else
  615. echo "${cmake_cxx_compiler} does not have ANSI streams"
  616. fi
  617. if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
  618. if cmake_try_run "${cmake_cxx_compiler}" \
  619. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
  620. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  621. KWSYS_IOS_HAVE_STD=1
  622. echo "${cmake_cxx_compiler} has streams in std:: namespace"
  623. else
  624. echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
  625. fi
  626. if cmake_try_run "${cmake_cxx_compiler}" \
  627. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
  628. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  629. KWSYS_IOS_USE_SSTREAM=1
  630. echo "${cmake_cxx_compiler} has sstream"
  631. else
  632. echo "${cmake_cxx_compiler} does not have sstream"
  633. fi
  634. fi
  635. if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
  636. if cmake_try_run "${cmake_cxx_compiler}" \
  637. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
  638. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  639. KWSYS_IOS_USE_STRSTREAM_H=1
  640. echo "${cmake_cxx_compiler} has strstream.h"
  641. else
  642. echo "${cmake_cxx_compiler} does not have strstream.h"
  643. fi
  644. if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
  645. if cmake_try_run "${cmake_cxx_compiler}" \
  646. "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
  647. "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
  648. KWSYS_IOS_USE_STRSTREA_H=1
  649. echo "${cmake_cxx_compiler} has strstrea.h"
  650. else
  651. echo "${cmake_cxx_compiler} does not have strstrea.h"
  652. fi
  653. fi
  654. fi
  655. # Just to be safe, let us store compiler and flags to the header file
  656. cmake_bootstrap_version='$Revision$'
  657. cmake_compiler_settings_comment="/*
  658. * Generated by ${cmake_source_dir}/bootstrap
  659. * Version: ${cmake_bootstrap_version}
  660. *
  661. * Source directory: ${cmake_source_dir}
  662. * Binary directory: ${cmake_bootstrap_dir}
  663. *
  664. * C compiler: ${cmake_c_compiler}
  665. * C flags: ${cmake_c_flags}
  666. *
  667. * C++ compiler: ${cmake_cxx_compiler}
  668. * C++ flags: ${cmake_cxx_flags}
  669. *
  670. * Make: ${cmake_make_processor}
  671. *
  672. * Sources:
  673. * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
  674. * kwSys Sources:
  675. * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
  676. */
  677. "
  678. cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
  679. if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
  680. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
  681. else
  682. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
  683. fi
  684. if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
  685. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
  686. else
  687. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
  688. fi
  689. if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
  690. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
  691. else
  692. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
  693. fi
  694. # Test for ansi FOR scope
  695. if cmake_try_run "${cmake_cxx_compiler}" \
  696. "${cmake_cxx_flags}" \
  697. "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
  698. cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
  699. echo "${cmake_cxx_compiler} has ANSI for scoping"
  700. else
  701. cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
  702. echo "${cmake_cxx_compiler} does not have ANSI for scoping"
  703. fi
  704. # Write CMake version
  705. for a in MAJOR MINOR PATCH; do
  706. CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \
  707. grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
  708. cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
  709. done
  710. cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
  711. cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
  712. cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
  713. # Regenerate real cmConfigure.h
  714. if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
  715. rm -f cmConfigure.h.tmp
  716. else
  717. mv -f cmConfigure.h.tmp cmConfigure.h
  718. fi
  719. # Prepare KWSYS
  720. cmake_kwsys_config_replace_string \
  721. "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
  722. "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
  723. "${cmake_compiler_settings_comment}"
  724. cmake_kwsys_config_replace_string \
  725. "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
  726. "${cmake_bootstrap_dir}/cmsys/Configure.h" \
  727. "${cmake_compiler_settings_comment}"
  728. for a in ${KWSYS_FILES}; do
  729. cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
  730. "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
  731. done
  732. for a in ${KWSYS_IOS_FILES}; do
  733. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
  734. "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
  735. done
  736. cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.h.in" \
  737. "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
  738. for a in string vector map; do
  739. cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
  740. "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
  741. done
  742. # Generate Makefile
  743. dep="cmConfigure.h cmsys/Configure.hxx cmsys/Configure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
  744. objs=""
  745. for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
  746. objs="${objs} ${a}.o"
  747. done
  748. if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
  749. cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
  750. fi
  751. if [ "x${cmake_c_flags}" != "x" ]; then
  752. cmake_c_flags="${cmake_c_flags} "
  753. fi
  754. if [ "x${cmake_cxx_flags}" != "x" ]; then
  755. cmake_cxx_flags="${cmake_cxx_flags} "
  756. fi
  757. cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
  758. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  759. cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
  760. -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
  761. echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
  762. echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
  763. for a in ${CMAKE_CXX_SOURCES}; do
  764. src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
  765. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  766. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  767. done
  768. for a in ${CMAKE_C_SOURCES}; do
  769. src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
  770. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  771. echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  772. done
  773. for a in ${KWSYS_C_SOURCES}; do
  774. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
  775. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  776. echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  777. done
  778. for a in ${KWSYS_CXX_SOURCES}; do
  779. src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
  780. echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
  781. echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
  782. done
  783. cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
  784. rebuild_cache:
  785. cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
  786. EOF
  787. # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
  788. cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
  789. # Generated by ${cmake_source_dir}/bootstrap
  790. # Default cmake settings. These may be overridden any settings below.
  791. SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
  792. SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
  793. SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
  794. SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
  795. EOF
  796. # Add user-specified settings. Handle relative-path case for
  797. # specification of cmake_init_file.
  798. (
  799. cd "${cmake_binary_dir}"
  800. if [ -f "${cmake_init_file}" ]; then
  801. cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  802. fi
  803. )
  804. echo "---------------------------------------------"
  805. # Run make to build bootstrap cmake
  806. if [ "x${cmake_parallel_make}" != "x" ]; then
  807. ${cmake_make_processor} ${cmake_make_flags}
  808. else
  809. ${cmake_make_processor}
  810. fi
  811. RES=$?
  812. if [ "${RES}" -ne "0" ]; then
  813. cmake_error 9 "Problem while running ${cmake_make_processor}"
  814. fi
  815. cd "${cmake_binary_dir}"
  816. # Set C, CXX, and MAKE environment variables, so that real real cmake will be
  817. # build with same compiler and make
  818. CC="${cmake_c_compiler}"
  819. CXX="${cmake_cxx_compiler}"
  820. MAKE="${cmake_make_processor}"
  821. export CC
  822. export CXX
  823. export MAKE
  824. # Run bootstrap CMake to configure real CMake
  825. "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
  826. echo "---------------------------------------------"
  827. # And we are done. Now just run make
  828. echo "CMake has bootstrapped. Now run ${cmake_make_processor}."