bootstrap 41 KB

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