bootstrap 39 KB

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