bootstrap 39 KB

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