bootstrap 39 KB

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