bootstrap 29 KB

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