bootstrap 29 KB

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