bootstrap 38 KB

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