bootstrap 41 KB

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