bootstrap 42 KB

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