bootstrap 43 KB

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