bootstrap 44 KB

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