bootstrap 39 KB

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