1
0

bootstrap 43 KB

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