bootstrap 39 KB

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