bootstrap 39 KB

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