bootstrap 29 KB

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