bootstrap 39 KB

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