bootstrap 30 KB

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