Updated formatting of documentation plus a little reorganization.
[cmake.git] / bootstrap
blob8d77c5fe8065e1ee91d3724c9e828dde6588ecb3
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2009-09-22 20:12:40 $
9 # Version: $Revision: 1.125 $
11 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
12 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
14 # This software is distributed WITHOUT ANY WARRANTY; without even
15 # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 # PURPOSE. See the above copyright notices for more information.
18 #=========================================================================
20 # Version number extraction function.
21 cmake_version_component()
23 cat "${cmake_source_dir}/CMakeLists.txt" | sed -n "
24 /^SET(CMake_VERSION_${1}/ {s/SET(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
28 cmake_date_stamp_component()
30 cat "${cmake_source_dir}/Source/kwsys/kwsysDateStamp.cmake" | sed -n "
31 /KWSYS_DATE_STAMP_${1}/ {s/^.* \([0-9][0-9]*\))$/\1/;p;}
35 # Detect system and directory information.
36 cmake_system=`uname`
37 cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
38 cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
39 cmake_binary_dir=`pwd`
40 cmake_version_major="`cmake_version_component MAJOR`"
41 cmake_version_minor="`cmake_version_component MINOR`"
42 if echo "${cmake_version_minor}" | grep "[0-9]*[13579]" > /dev/null 2>&1; then
43 cmake_version_patch="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
44 else
45 cmake_version_patch="`cmake_version_component PATCH`"
47 cmake_version="${cmake_version_major}.${cmake_version_minor}"
48 cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
49 cmake_data_dir="/share/cmake-${cmake_version}"
50 cmake_doc_dir="/doc/cmake-${cmake_version}"
51 cmake_man_dir="/man"
52 cmake_init_file=""
53 cmake_bootstrap_system_libs=""
54 cmake_bootstrap_qt_gui=""
55 cmake_bootstrap_qt_qmake=""
57 # Determine whether this is a Cygwin environment.
58 if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
59 cmake_system_cygwin=true
60 else
61 cmake_system_cygwin=false
64 # Determine whether this is a MinGW environment.
65 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
66 cmake_system_mingw=true
67 else
68 cmake_system_mingw=false
71 # Determine whether this is OS X
72 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
73 cmake_system_darwin=true
74 else
75 cmake_system_darwin=false
78 # Determine whether this is BeOS
79 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
80 cmake_system_beos=true
81 else
82 cmake_system_beos=false
85 # Determine whether this is Haiku
86 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
87 cmake_system_haiku=true
88 else
89 cmake_system_haiku=false
92 # Determine whether this is OpenVMS
93 if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
94 cmake_system_openvms=true
95 else
96 cmake_system_openvms=false
99 # Choose the generator to use for bootstrapping.
100 if ${cmake_system_mingw}; then
101 # Bootstrapping from an MSYS prompt.
102 cmake_bootstrap_generator="MSYS Makefiles"
103 else
104 # Bootstrapping from a standard UNIX prompt.
105 cmake_bootstrap_generator="Unix Makefiles"
108 # Choose tools and extensions for this platform.
109 if ${cmake_system_openvms}; then
110 _tmp="_tmp"
111 _cmk="_cmk"
112 _diff=`which diff`
113 else
114 _tmp=".tmp"
115 _cmk=".cmk"
116 _diff="diff"
119 # Construct bootstrap directory name.
120 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
122 # Helper function to fix windows paths.
123 cmake_fix_slashes ()
125 echo "$1" | sed 's/\\/\//g'
128 # Choose the default install prefix.
129 if ${cmake_system_mingw}; then
130 if [ "x${PROGRAMFILES}" != "x" ]; then
131 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
132 elif [ "x${ProgramFiles}" != "x" ]; then
133 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
134 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
135 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
136 elif [ "x${SystemDrive}" != "x" ]; then
137 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
138 else
139 cmake_default_prefix="c:/Program Files/CMake"
141 else
142 cmake_default_prefix="/usr/local"
145 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
146 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
147 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
149 CMAKE_PROBLEMATIC_FILES="\
150 CMakeCache.txt \
151 CMakeSystem.cmake \
152 CMakeCCompiler.cmake \
153 CMakeCXXCompiler.cmake \
154 Source/cmConfigure.h \
155 Source/CTest/Curl/config.h \
156 Utilities/cmexpat/expatConfig.h \
157 Utilities/cmexpat/expatDllConfig.h \
160 CMAKE_UNUSED_SOURCES="\
161 cmGlobalXCodeGenerator \
162 cmLocalXCodeGenerator \
163 cmXCodeObject \
164 cmXCode21Object \
165 cmSourceGroup \
168 CMAKE_CXX_SOURCES="\
169 cmake \
170 cmakemain \
171 cmakewizard \
172 cmCommandArgumentLexer \
173 cmCommandArgumentParser \
174 cmCommandArgumentParserHelper \
175 cmDefinitions \
176 cmDepends \
177 cmDependsC \
178 cmDocumentationFormatter \
179 cmDocumentationFormatterText \
180 cmPolicies \
181 cmProperty \
182 cmPropertyMap \
183 cmPropertyDefinition \
184 cmPropertyDefinitionMap \
185 cmMakeDepend \
186 cmMakefile \
187 cmExportFileGenerator \
188 cmExportInstallFileGenerator \
189 cmInstallDirectoryGenerator \
190 cmGeneratedFileStream \
191 cmGeneratorExpression \
192 cmGlobalGenerator \
193 cmLocalGenerator \
194 cmInstallGenerator \
195 cmInstallExportGenerator \
196 cmInstallFilesGenerator \
197 cmInstallScriptGenerator \
198 cmInstallTargetGenerator \
199 cmScriptGenerator \
200 cmSourceFile \
201 cmSourceFileLocation \
202 cmSystemTools \
203 cmTestGenerator \
204 cmVersion \
205 cmFileTimeComparison \
206 cmGlobalUnixMakefileGenerator3 \
207 cmLocalUnixMakefileGenerator3 \
208 cmMakefileExecutableTargetGenerator \
209 cmMakefileLibraryTargetGenerator \
210 cmMakefileTargetGenerator \
211 cmMakefileUtilityTargetGenerator \
212 cmBootstrapCommands \
213 cmCommands \
214 cmTarget \
215 cmTest \
216 cmCustomCommand \
217 cmDocumentVariables \
218 cmCacheManager \
219 cmListFileCache \
220 cmComputeLinkDepends \
221 cmComputeLinkInformation \
222 cmOrderDirectories \
223 cmComputeTargetDepends \
224 cmComputeComponentGraph \
225 cmExprLexer \
226 cmExprParser \
227 cmExprParserHelper \
230 if ${cmake_system_mingw}; then
231 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
232 cmGlobalMSYSMakefileGenerator \
233 cmGlobalMinGWMakefileGenerator \
234 cmWin32ProcessExecution"
237 CMAKE_C_SOURCES="\
238 cmListFileLexer \
241 if ${cmake_system_mingw}; then
242 KWSYS_C_SOURCES="\
243 ProcessWin32 \
244 String \
245 System"
246 KWSYS_C_MINGW_SOURCES="\
247 ProcessFwd9x \
248 EncodeExecutable"
249 KWSYS_C_GENERATED_SOURCES="\
250 cmsysProcessFwd9xEnc"
251 else
252 KWSYS_C_SOURCES="\
253 ProcessUNIX \
254 String \
255 System"
256 KWSYS_C_MINGW_SOURCES=""
257 KWSYS_C_GENERATED_SOURCES=""
260 KWSYS_CXX_SOURCES="\
261 Directory \
262 Glob \
263 RegularExpression \
264 SystemTools"
266 KWSYS_FILES="\
267 auto_ptr.hxx \
268 Directory.hxx \
269 Glob.hxx \
270 Process.h \
271 RegularExpression.hxx \
272 String.h \
273 String.hxx \
274 System.h \
275 SystemTools.hxx"
277 KWSYS_IOS_FILES="
278 fstream \
279 iosfwd \
280 iostream \
281 sstream"
283 # Display CMake bootstrap usage
284 cmake_usage()
286 echo '
287 Usage: '"$0"' [options]
288 Options: [defaults in brackets after descriptions]
289 Configuration:
290 --help print this message
291 --version only print version information
292 --verbose display more information
293 --parallel=n bootstrap cmake in parallel, where n is
294 number of nodes [1]
295 --init=FILE use FILE for cmake initialization
296 --system-libs use system-installed third-party libraries
297 (for use only by package maintainers)
298 --no-system-libs use cmake-provided third-party libraries
299 (default)
300 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
301 --no-qt-gui do not build the Qt-based GUI (default)
302 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
304 Directory and file names:
305 --prefix=PREFIX install files in tree rooted at PREFIX
306 [${cmake_default_prefix}]
307 --datadir=DIR install data files in PREFIX/DIR
308 [/share/CMake]
309 --docdir=DIR install documentation files in PREFIX/DIR
310 [/doc/CMake]
311 --mandir=DIR install man pages files in PREFIX/DIR/manN
312 [/man]
314 exit 10
317 # Display CMake bootstrap usage
318 cmake_version_display()
320 echo "CMake ${cmake_version_full}, Copyright (c) 2000-2009 Kitware, Inc., Insight Consortium"
323 # Display CMake bootstrap error, display the log file and exit
324 cmake_error()
326 res=$1
327 shift 1
328 echo "---------------------------------------------"
329 echo "Error when bootstrapping CMake:"
330 echo "$*"
331 echo "---------------------------------------------"
332 if [ -f cmake_bootstrap.log ]; then
333 echo "Log of errors: `pwd`/cmake_bootstrap.log"
334 #cat cmake_bootstrap.log
335 echo "---------------------------------------------"
337 exit ${res}
340 # Replace KWSYS_NAMESPACE with cmsys
341 cmake_replace_string ()
343 INFILE="$1"
344 OUTFILE="$2"
345 SEARCHFOR="$3"
346 REPLACEWITH="$4"
347 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
348 cat "${INFILE}" |
349 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
350 if [ -f "${OUTFILE}${_tmp}" ]; then
351 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
352 #echo "Files are the same"
353 rm -f "${OUTFILE}${_tmp}"
354 else
355 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
358 else
359 cmake_error 1 "Cannot find file ${INFILE}"
363 cmake_kwsys_config_replace_string ()
365 INFILE="$1"
366 OUTFILE="$2"
367 shift 2
368 APPEND="$*"
369 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
370 echo "${APPEND}" > "${OUTFILE}${_tmp}"
371 cat "${INFILE}" |
372 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
373 s/@KWSYS_DO_NOT_CLEAN_PUTENV@/0/g;
374 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
375 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
376 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
377 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
378 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
379 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
380 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
381 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
382 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
383 s/@KWSYS_IOS_HAVE_BINARY@/${KWSYS_IOS_HAVE_BINARY}/g;
384 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
385 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
386 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
387 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
388 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
389 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
390 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
391 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
392 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
393 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
394 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
395 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
396 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
397 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
398 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
399 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
400 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
401 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}"
402 if [ -f "${OUTFILE}${_tmp}" ]; then
403 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
404 #echo "Files are the same"
405 rm -f "${OUTFILE}${_tmp}"
406 else
407 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
410 else
411 cmake_error 2 "Cannot find file ${INFILE}"
414 # Write string into a file
415 cmake_report ()
417 FILE=$1
418 shift
419 echo "$*" >> ${FILE}
422 # Escape spaces in strings
423 cmake_escape ()
425 echo $1 | sed "s/ /\\\\ /g"
428 # Write message to the log
429 cmake_log ()
431 echo "$*" >> cmake_bootstrap.log
434 # Return temp file
435 cmake_tmp_file ()
437 echo "cmake_bootstrap_$$_test"
440 # Run a compiler test. First argument is compiler, second one are compiler
441 # flags, third one is test source file to be compiled
442 cmake_try_run ()
444 COMPILER=$1
445 FLAGS=$2
446 TESTFILE=$3
447 if [ ! -f "${TESTFILE}" ]; then
448 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
449 exit 4
451 TMPFILE=`cmake_tmp_file`
452 echo "Try: ${COMPILER}"
453 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
454 echo "---------- file -----------------------"
455 cat "${TESTFILE}"
456 echo "------------------------------------------"
457 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
458 RES=$?
459 if [ "${RES}" -ne "0" ]; then
460 echo "Test failed to compile"
461 return 1
463 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
464 echo "Test failed to produce executable"
465 return 2
467 ./${TMPFILE}
468 RES=$?
469 rm -f "${TMPFILE}"
470 if [ "${RES}" -ne "0" ]; then
471 echo "Test produced non-zero return code"
472 return 3
474 echo "Test succeded"
475 return 0
478 # Run a make test. First argument is the make interpreter.
479 cmake_try_make ()
481 MAKE_PROC="$1"
482 MAKE_FLAGS="$2"
483 echo "Try: ${MAKE_PROC}"
484 "${MAKE_PROC}" ${MAKE_FLAGS}
485 RES=$?
486 if [ "${RES}" -ne "0" ]; then
487 echo "${MAKE_PROC} does not work"
488 return 1
490 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
491 echo "${COMPILER} does not produce output"
492 return 2
494 ./test
495 RES=$?
496 rm -f "test"
497 if [ "${RES}" -ne "0" ]; then
498 echo "${MAKE_PROC} produces strange executable"
499 return 3
501 echo "${MAKE_PROC} works"
502 return 0
505 # Parse arguments
506 cmake_verbose=
507 cmake_parallel_make=
508 cmake_prefix_dir="${cmake_default_prefix}"
509 for a in "$@"; do
510 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
511 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
512 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
514 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
515 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
517 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
518 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
520 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
521 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
523 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
524 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
526 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
527 cmake_init_file=`echo $a | sed "s/^--init=//"`
529 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
530 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
532 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
533 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
535 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
536 cmake_bootstrap_qt_gui="1"
538 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
539 cmake_bootstrap_qt_gui="0"
541 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
542 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
544 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
545 cmake_usage
547 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
548 cmake_version_display
549 exit 2
551 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
552 cmake_verbose=TRUE
554 done
556 # If verbose, display some information about bootstrap
557 if [ -n "${cmake_verbose}" ]; then
558 echo "---------------------------------------------"
559 echo "Source directory: ${cmake_source_dir}"
560 echo "Binary directory: ${cmake_binary_dir}"
561 echo "Prefix directory: ${cmake_prefix_dir}"
562 echo "System: ${cmake_system}"
563 if [ "x${cmake_parallel_make}" != "x" ]; then
564 echo "Doing parallel make: ${cmake_parallel_make}"
566 echo ""
569 echo "---------------------------------------------"
570 # Get CMake version
571 echo "`cmake_version_display`"
573 # Check for in-source build
574 cmake_in_source_build=
575 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
576 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
577 if [ -n "${cmake_verbose}" ]; then
578 echo "Warning: This is an in-source build"
580 cmake_in_source_build=TRUE
583 # If this is not an in-source build, then Bootstrap stuff should not exist.
584 if [ -z "${cmake_in_source_build}" ]; then
585 # Did somebody bootstrap in the source tree?
586 if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
587 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
588 Looks like somebody did bootstrap CMake in the source tree, but now you are
589 trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
590 directory from the source tree."
592 # Is there a cache in the source tree?
593 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
594 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
595 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
596 Looks like somebody tried to build CMake in the source tree, but now you are
597 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
598 from the source tree."
600 done
603 # Make bootstrap directory
604 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
605 if [ ! -d "${cmake_bootstrap_dir}" ]; then
606 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
608 cd "${cmake_bootstrap_dir}"
610 [ -d "cmsys" ] || mkdir "cmsys"
611 if [ ! -d "cmsys" ]; then
612 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
615 for a in stl ios; do
616 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
617 if [ ! -d "cmsys/${a}" ]; then
618 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
620 done
622 # Delete all the bootstrap files
623 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
624 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
625 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
627 # If exist compiler flags, set them
628 cmake_c_flags=${CFLAGS}
629 cmake_cxx_flags=${CXXFLAGS}
630 cmake_ld_flags=${LDFLAGS}
632 # Add Cygwin-specific flags
633 if ${cmake_system_cygwin}; then
634 cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
637 # Add Carbon framework on Darwin
638 if ${cmake_system_darwin}; then
639 cmake_ld_flags="${LDFLAGS} -framework Carbon"
642 # Add BeOS toolkits...
643 if ${cmake_system_beos}; then
644 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
647 # Add Haiku toolkits...
648 if ${cmake_system_haiku}; then
649 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
652 # Test C compiler
653 cmake_c_compiler=
655 # If CC is set, use that for compiler, otherwise use list of known compilers
656 if [ -n "${CC}" ]; then
657 cmake_c_compilers="${CC}"
658 else
659 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
662 # Check if C compiler works
663 TMPFILE=`cmake_tmp_file`
664 echo '
665 #ifdef __cplusplus
666 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
667 #endif
669 #include<stdio.h>
671 #if defined(__CLASSIC_C__)
672 int main(argc, argv)
673 int argc;
674 char* argv[];
675 #else
676 int main(int argc, char* argv[])
677 #endif
679 printf("%d%c", (argv != 0), (char)0x0a);
680 return argc-1;
682 ' > "${TMPFILE}.c"
683 for a in ${cmake_c_compilers}; do
684 if [ -z "${cmake_c_compiler}" ] && \
685 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
686 cmake_c_compiler="${a}"
688 done
689 rm -f "${TMPFILE}.c"
691 if [ -z "${cmake_c_compiler}" ]; then
692 cmake_error 6 "Cannot find appropriate C compiler on this system.
693 Please specify one using environment variable CC.
694 See cmake_bootstrap.log for compilers attempted.
697 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
699 # Test CXX compiler
700 cmake_cxx_compiler=
702 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
704 # If CC is set, use that for compiler, otherwise use list of known compilers
705 if [ -n "${CXX}" ]; then
706 cmake_cxx_compilers="${CXX}"
707 else
708 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
711 # Check if C++ compiler works
712 TMPFILE=`cmake_tmp_file`
713 echo '
714 #if defined(TEST1)
715 # include <iostream>
716 #else
717 # include <iostream.h>
718 #endif
720 class NeedCXX
722 public:
723 NeedCXX() { this->Foo = 1; }
724 int GetFoo() { return this->Foo; }
725 private:
726 int Foo;
728 int main()
730 NeedCXX c;
731 #ifdef TEST3
732 cout << c.GetFoo() << endl;
733 #else
734 std::cout << c.GetFoo() << std::endl;
735 #endif
736 return 0;
738 ' > "${TMPFILE}.cxx"
739 for a in ${cmake_cxx_compilers}; do
740 for b in 1 2 3; do
741 if [ -z "${cmake_cxx_compiler}" ] && \
742 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
743 cmake_cxx_compiler="${a}"
745 done
746 done
747 rm -f "${TMPFILE}.cxx"
749 if [ -z "${cmake_cxx_compiler}" ]; then
750 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
751 Please specify one using environment variable CXX.
752 See cmake_bootstrap.log for compilers attempted."
754 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
756 # Test Make
758 cmake_make_processor=
759 cmake_make_flags=
761 # If MAKE is set, use that for make processor, otherwise use list of known make
762 if [ -n "${MAKE}" ]; then
763 cmake_make_processors="${MAKE}"
764 else
765 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
768 TMPFILE="`cmake_tmp_file`_dir"
769 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
770 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
771 cd "${cmake_bootstrap_dir}/${TMPFILE}"
772 echo '
773 test: test.c
774 "'"${cmake_c_compiler}"'" -o test test.c
775 '>"Makefile"
776 echo '
777 #include <stdio.h>
778 int main(){ printf("1%c", (char)0x0a); return 0; }
779 ' > "test.c"
780 cmake_original_make_flags="${cmake_make_flags}"
781 if [ "x${cmake_parallel_make}" != "x" ]; then
782 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
784 for a in ${cmake_make_processors}; do
785 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
786 cmake_make_processor="${a}"
788 done
789 cmake_full_make_flags="${cmake_make_flags}"
790 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
791 if [ -z "${cmake_make_processor}" ]; then
792 cmake_make_flags="${cmake_original_make_flags}"
793 for a in ${cmake_make_processors}; do
794 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
795 cmake_make_processor="${a}"
797 done
800 cd "${cmake_bootstrap_dir}"
801 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
803 if [ -z "${cmake_make_processor}" ]; then
804 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
805 Please specify one using environment variable MAKE."
807 echo "Makefile processor on this system is: ${cmake_make_processor}"
808 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
809 echo "---------------------------------------------"
810 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
811 echo "---------------------------------------------"
814 # Ok, we have CC, CXX, and MAKE.
816 # Test C++ compiler features
818 # Are we GCC?
820 TMPFILE=`cmake_tmp_file`
821 echo '
822 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
823 #include <iostream>
824 int main() { std::cout << "This is GNU" << std::endl; return 0;}
825 #endif
826 ' > ${TMPFILE}.cxx
827 cmake_cxx_compiler_is_gnu=0
828 if cmake_try_run "${cmake_cxx_compiler}" \
829 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
830 cmake_cxx_compiler_is_gnu=1
832 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
833 echo "${cmake_cxx_compiler} is GNU compiler"
834 else
835 echo "${cmake_cxx_compiler} is not GNU compiler"
837 rm -f "${TMPFILE}.cxx"
839 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
840 # Check for non-GNU compiler flags
842 # If we are on IRIX, check for -LANG:std
843 cmake_test_flags="-LANG:std"
844 if [ "x${cmake_system}" = "xIRIX64" ]; then
845 TMPFILE=`cmake_tmp_file`
846 echo '
847 #include <iostream>
848 int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
849 ' > ${TMPFILE}.cxx
850 cmake_need_lang_std=0
851 if cmake_try_run "${cmake_cxx_compiler}" \
852 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
854 else
855 if cmake_try_run "${cmake_cxx_compiler}" \
856 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
857 cmake_need_lang_std=1
860 if [ "x${cmake_need_lang_std}" = "x1" ]; then
861 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
862 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
863 else
864 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
866 rm -f "${TMPFILE}.cxx"
868 cmake_test_flags=
870 # If we are on OSF, check for -timplicit_local -no_implicit_include
871 cmake_test_flags="-timplicit_local -no_implicit_include"
872 if [ "x${cmake_system}" = "xOSF1" ]; then
873 TMPFILE=`cmake_tmp_file`
874 echo '
875 #include <iostream>
876 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
877 ' > ${TMPFILE}.cxx
878 cmake_need_flags=1
879 if cmake_try_run "${cmake_cxx_compiler}" \
880 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
882 else
883 cmake_need_flags=0
885 if [ "x${cmake_need_flags}" = "x1" ]; then
886 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
887 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
888 else
889 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
891 rm -f "${TMPFILE}.cxx"
893 cmake_test_flags=
895 # If we are on OSF, check for -std strict_ansi -nopure_cname
896 cmake_test_flags="-std strict_ansi -nopure_cname"
897 if [ "x${cmake_system}" = "xOSF1" ]; then
898 TMPFILE=`cmake_tmp_file`
899 echo '
900 #include <iostream>
901 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
902 ' > ${TMPFILE}.cxx
903 cmake_need_flags=1
904 if cmake_try_run "${cmake_cxx_compiler}" \
905 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
907 else
908 cmake_need_flags=0
910 if [ "x${cmake_need_flags}" = "x1" ]; then
911 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
912 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
913 else
914 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
916 rm -f "${TMPFILE}.cxx"
918 cmake_test_flags=
920 # If we are on HP-UX, check for -Ae for the C compiler.
921 cmake_test_flags="-Ae"
922 if [ "x${cmake_system}" = "xHP-UX" ]; then
923 TMPFILE=`cmake_tmp_file`
924 echo '
925 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
926 ' > ${TMPFILE}.c
927 cmake_need_Ae=0
928 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
930 else
931 if cmake_try_run "${cmake_c_compiler}" \
932 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
933 cmake_need_Ae=1
936 if [ "x${cmake_need_Ae}" = "x1" ]; then
937 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
938 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
939 else
940 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
942 rm -f "${TMPFILE}.c"
944 cmake_test_flags=
947 # Test for kwsys features
948 KWSYS_NAME_IS_KWSYS=0
949 KWSYS_BUILD_SHARED=0
950 KWSYS_LFS_AVAILABLE=0
951 KWSYS_LFS_REQUESTED=0
952 KWSYS_IOS_USE_STRSTREAM_H=0
953 KWSYS_IOS_USE_STRSTREA_H=0
954 KWSYS_IOS_HAVE_STD=0
955 KWSYS_IOS_USE_SSTREAM=0
956 KWSYS_IOS_USE_ANSI=0
957 KWSYS_IOS_HAVE_BINARY=0
958 KWSYS_STL_HAVE_STD=0
959 KWSYS_STAT_HAS_ST_MTIM=0
960 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
961 KWSYS_STL_HAS_ITERATOR_TRAITS=0
962 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
963 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
964 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
965 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
966 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
967 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
968 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
969 KWSYS_CXX_HAS_CSTDDEF=0
970 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
971 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
972 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
973 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
975 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
976 KWSYS_STL_STRING_HAVE_ISTREAM=1
977 KWSYS_STL_STRING_HAVE_OSTREAM=1
979 if cmake_try_run "${cmake_cxx_compiler}" \
980 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
981 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
982 KWSYS_STL_HAVE_STD=1
983 echo "${cmake_cxx_compiler} has STL in std:: namespace"
984 else
985 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
988 if cmake_try_run "${cmake_cxx_compiler}" \
989 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
990 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
991 KWSYS_IOS_USE_ANSI=1
992 echo "${cmake_cxx_compiler} has ANSI streams"
993 else
994 echo "${cmake_cxx_compiler} does not have ANSI streams"
997 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
998 if cmake_try_run "${cmake_cxx_compiler}" \
999 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
1000 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1001 KWSYS_IOS_HAVE_STD=1
1002 echo "${cmake_cxx_compiler} has streams in std:: namespace"
1003 else
1004 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
1006 if cmake_try_run "${cmake_cxx_compiler}" \
1007 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
1008 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1009 KWSYS_IOS_USE_SSTREAM=1
1010 echo "${cmake_cxx_compiler} has sstream"
1011 else
1012 echo "${cmake_cxx_compiler} does not have sstream"
1016 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
1017 if cmake_try_run "${cmake_cxx_compiler}" \
1018 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
1019 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1020 KWSYS_IOS_USE_STRSTREAM_H=1
1021 echo "${cmake_cxx_compiler} has strstream.h"
1022 else
1023 echo "${cmake_cxx_compiler} does not have strstream.h"
1025 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
1026 if cmake_try_run "${cmake_cxx_compiler}" \
1027 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
1028 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1029 KWSYS_IOS_USE_STRSTREA_H=1
1030 echo "${cmake_cxx_compiler} has strstrea.h"
1031 else
1032 echo "${cmake_cxx_compiler} does not have strstrea.h"
1037 if cmake_try_run "${cmake_cxx_compiler}" \
1038 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1039 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1040 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1041 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1042 else
1043 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1046 if cmake_try_run "${cmake_cxx_compiler}" \
1047 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1048 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1049 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1050 echo "${cmake_cxx_compiler} has stl iterator_traits"
1051 else
1052 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1055 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1056 if cmake_try_run "${cmake_cxx_compiler}" \
1057 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1058 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1059 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1060 echo "${cmake_cxx_compiler} has old iterator_category"
1061 else
1062 echo "${cmake_cxx_compiler} does not have old iterator_category"
1064 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1065 if cmake_try_run "${cmake_cxx_compiler}" \
1066 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1067 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1068 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1069 echo "${cmake_cxx_compiler} has old __iterator_category"
1070 else
1071 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1076 if cmake_try_run "${cmake_cxx_compiler}" \
1077 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1078 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1079 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1080 echo "${cmake_cxx_compiler} has standard template allocator"
1081 else
1082 echo "${cmake_cxx_compiler} does not have standard template allocator"
1085 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1086 if cmake_try_run "${cmake_cxx_compiler}" \
1087 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1088 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1089 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1090 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1091 else
1092 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1095 if cmake_try_run "${cmake_cxx_compiler}" \
1096 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1097 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1098 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1099 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1100 else
1101 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1103 else
1104 if cmake_try_run "${cmake_cxx_compiler}" \
1105 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1106 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1107 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1108 echo "${cmake_cxx_compiler} has old non-template allocator"
1109 else
1110 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1114 if cmake_try_run "${cmake_cxx_compiler}" \
1115 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1116 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1117 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1118 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1119 else
1120 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1123 if cmake_try_run "${cmake_cxx_compiler}" \
1124 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1125 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1126 KWSYS_CXX_HAS_CSTDDEF=1
1127 echo "${cmake_cxx_compiler} has header cstddef"
1128 else
1129 echo "${cmake_cxx_compiler} does not have header cstddef"
1132 if cmake_try_run "${cmake_cxx_compiler}" \
1133 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1134 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1135 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1136 else
1137 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1138 echo "${cmake_cxx_compiler} requires template friends to use <>"
1141 if cmake_try_run "${cmake_cxx_compiler}" \
1142 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1143 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1144 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1145 echo "${cmake_cxx_compiler} supports member templates"
1146 else
1147 echo "${cmake_cxx_compiler} does not support member templates"
1150 if cmake_try_run "${cmake_cxx_compiler}" \
1151 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1152 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1153 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1154 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1155 else
1156 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1159 if cmake_try_run "${cmake_cxx_compiler}" \
1160 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1161 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1162 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1163 echo "${cmake_cxx_compiler} has argument dependent lookup"
1164 else
1165 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1168 if cmake_try_run "${cmake_cxx_compiler}" \
1169 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1170 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1171 KWSYS_STAT_HAS_ST_MTIM=1
1172 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1173 else
1174 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1177 if cmake_try_run "${cmake_cxx_compiler}" \
1178 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_BINARY -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}" \
1179 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1180 KWSYS_IOS_HAVE_BINARY=1
1181 echo "${cmake_cxx_compiler} has ios::binary openmode"
1182 else
1183 echo "${cmake_cxx_compiler} does not have ios::binary openmode"
1186 # Just to be safe, let us store compiler and flags to the header file
1188 cmake_bootstrap_version='$Revision: 1.125 $'
1189 cmake_compiler_settings_comment="/*
1190 * Generated by ${cmake_source_dir}/bootstrap
1191 * Version: ${cmake_bootstrap_version}
1193 * Source directory: ${cmake_source_dir}
1194 * Binary directory: ${cmake_bootstrap_dir}
1196 * C compiler: ${cmake_c_compiler}
1197 * C flags: ${cmake_c_flags}
1199 * C++ compiler: ${cmake_cxx_compiler}
1200 * C++ flags: ${cmake_cxx_flags}
1202 * Make: ${cmake_make_processor}
1204 * Sources:
1205 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1206 * kwSys Sources:
1207 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1211 cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
1213 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1214 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_STD_NAMESPACE */"
1215 else
1216 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_STD_NAMESPACE 1"
1219 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1220 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1221 else
1222 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1225 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1226 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1227 else
1228 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1231 # Test for ansi FOR scope
1232 if cmake_try_run "${cmake_cxx_compiler}" \
1233 "${cmake_cxx_flags}" \
1234 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1235 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1236 echo "${cmake_cxx_compiler} has ANSI for scoping"
1237 else
1238 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1239 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1242 # When bootstrapping on MinGW with MSYS we must convert the source
1243 # directory to a windows path.
1244 if ${cmake_system_mingw}; then
1245 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1246 else
1247 cmake_root_dir="${cmake_source_dir}"
1250 # Write CMake version
1251 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1252 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1253 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1254 cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1255 cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1256 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
1258 # Regenerate configured headers
1259 for h in Configure VersionConfig; do
1260 if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
1261 rm -f cm${h}.h${_tmp}
1262 else
1263 mv -f cm${h}.h${_tmp} cm${h}.h
1265 done
1267 # Prepare KWSYS
1268 cmake_kwsys_config_replace_string \
1269 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1270 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1271 "${cmake_compiler_settings_comment}"
1272 cmake_kwsys_config_replace_string \
1273 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1274 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1275 "${cmake_compiler_settings_comment}"
1277 for a in ${KWSYS_FILES}; do
1278 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1279 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1280 done
1282 for a in ${KWSYS_IOS_FILES}; do
1283 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1284 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1285 done
1287 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1288 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" KWSYS_STL_HEADER_EXTRA ""
1290 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" \
1291 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" KWSYS_NAMESPACE cmsys
1293 for a in string vector map algorithm; do
1294 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" \
1295 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1296 done
1298 # Generate Makefile
1299 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1300 objs=""
1301 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1302 objs="${objs} ${a}.o"
1303 done
1305 # Generate dependencies for cmBootstrapCommands.cxx
1306 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1307 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1308 done
1309 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1311 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1312 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1315 if [ "x${cmake_c_flags}" != "x" ]; then
1316 cmake_c_flags="${cmake_c_flags} "
1319 if [ "x${cmake_cxx_flags}" != "x" ]; then
1320 cmake_cxx_flags="${cmake_cxx_flags} "
1323 cmake_c_flags_String="-DKWSYS_STRING_C"
1324 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1325 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1326 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1327 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1328 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1329 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1330 for a in ${CMAKE_CXX_SOURCES}; do
1331 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1332 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1333 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1334 done
1335 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1336 for a in ${CMAKE_C_SOURCES}; do
1337 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1338 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1339 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1340 done
1341 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1342 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1343 src_flags=`eval echo \\${cmake_c_flags_\${a}}`
1344 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1345 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1346 done
1347 for a in ${KWSYS_CXX_SOURCES}; do
1348 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1349 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1350 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1351 done
1352 if ${cmake_system_mingw}; then
1353 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1354 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1355 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1356 a="cmsysProcessFwd9xEnc"
1357 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1358 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1359 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1360 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1361 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1362 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1363 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1364 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"
1366 echo '
1367 rebuild_cache:
1368 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1369 ' >> "${cmake_bootstrap_dir}/Makefile"
1371 # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
1372 echo '
1373 # Generated by '"${cmake_source_dir}"'/bootstrap
1374 # Default cmake settings. These may be overridden any settings below.
1375 SET (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1376 SET (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1377 SET (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1378 SET (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1379 ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1381 # Add configuration settings given as command-line options.
1382 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1383 echo '
1384 SET (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
1385 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1387 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1388 echo '
1389 SET (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
1390 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1393 # Add user-specified settings. Handle relative-path case for
1394 # specification of cmake_init_file.
1396 cd "${cmake_binary_dir}"
1397 if [ -f "${cmake_init_file}" ]; then
1398 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1402 echo "---------------------------------------------"
1404 # Run make to build bootstrap cmake
1405 if [ "x${cmake_parallel_make}" != "x" ]; then
1406 ${cmake_make_processor} ${cmake_make_flags}
1407 else
1408 ${cmake_make_processor}
1410 RES=$?
1411 if [ "${RES}" -ne "0" ]; then
1412 cmake_error 9 "Problem while running ${cmake_make_processor}"
1414 cd "${cmake_binary_dir}"
1416 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1417 # build with same compiler and make
1418 CC="${cmake_c_compiler}"
1419 CXX="${cmake_cxx_compiler}"
1420 MAKE="${cmake_make_processor}"
1421 export CC
1422 export CXX
1423 export MAKE
1425 # Run bootstrap CMake to configure real CMake
1426 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1427 RES=$?
1428 if [ "${RES}" -ne "0" ]; then
1429 cmake_error 11 "Problem while running initial CMake"
1432 echo "---------------------------------------------"
1434 # And we are done. Now just run make
1435 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."