bootstrap 39 KB

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