bootstrap 41 KB

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