KWSys Nightly Date Stamp
[cmake.git] / bootstrap
bloba0fab5bc66167f8b35bebebe54c5270ecc91cea1
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2009-07-22 18:22:45 $
9 # Version: $Revision: 1.122 $
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 cmGlobalGenerator \
192 cmLocalGenerator \
193 cmInstallGenerator \
194 cmInstallExportGenerator \
195 cmInstallFilesGenerator \
196 cmInstallScriptGenerator \
197 cmInstallTargetGenerator \
198 cmScriptGenerator \
199 cmSourceFile \
200 cmSourceFileLocation \
201 cmSystemTools \
202 cmTestGenerator \
203 cmVersion \
204 cmFileTimeComparison \
205 cmGlobalUnixMakefileGenerator3 \
206 cmLocalUnixMakefileGenerator3 \
207 cmMakefileExecutableTargetGenerator \
208 cmMakefileLibraryTargetGenerator \
209 cmMakefileTargetGenerator \
210 cmMakefileUtilityTargetGenerator \
211 cmBootstrapCommands \
212 cmCommands \
213 cmTarget \
214 cmTest \
215 cmCustomCommand \
216 cmDocumentVariables \
217 cmCacheManager \
218 cmListFileCache \
219 cmComputeLinkDepends \
220 cmComputeLinkInformation \
221 cmOrderDirectories \
222 cmComputeTargetDepends \
223 cmComputeComponentGraph \
224 cmExprLexer \
225 cmExprParser \
226 cmExprParserHelper \
229 if ${cmake_system_mingw}; then
230 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
231 cmGlobalMSYSMakefileGenerator \
232 cmGlobalMinGWMakefileGenerator \
233 cmWin32ProcessExecution"
236 CMAKE_C_SOURCES="\
237 cmListFileLexer \
240 if ${cmake_system_mingw}; then
241 KWSYS_C_SOURCES="\
242 ProcessWin32 \
243 String \
244 System"
245 KWSYS_C_MINGW_SOURCES="\
246 ProcessFwd9x \
247 EncodeExecutable"
248 KWSYS_C_GENERATED_SOURCES="\
249 cmsysProcessFwd9xEnc"
250 else
251 KWSYS_C_SOURCES="\
252 ProcessUNIX \
253 String \
254 System"
255 KWSYS_C_MINGW_SOURCES=""
256 KWSYS_C_GENERATED_SOURCES=""
259 KWSYS_CXX_SOURCES="\
260 Directory \
261 Glob \
262 RegularExpression \
263 SystemTools"
265 KWSYS_FILES="\
266 auto_ptr.hxx \
267 Directory.hxx \
268 Glob.hxx \
269 Process.h \
270 RegularExpression.hxx \
271 String.h \
272 String.hxx \
273 System.h \
274 SystemTools.hxx"
276 KWSYS_IOS_FILES="
277 fstream \
278 iosfwd \
279 iostream \
280 sstream"
282 # Display CMake bootstrap usage
283 cmake_usage()
285 echo '
286 Usage: '"$0"' [options]
287 Options: [defaults in brackets after descriptions]
288 Configuration:
289 --help print this message
290 --version only print version information
291 --verbose display more information
292 --parallel=n bootstrap cmake in parallel, where n is
293 number of nodes [1]
294 --init=FILE use FILE for cmake initialization
295 --system-libs use system-installed third-party libraries
296 (for use only by package maintainers)
297 --no-system-libs use cmake-provided third-party libraries
298 (default)
299 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
300 --no-qt-gui do not build the Qt-based GUI (default)
301 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
303 Directory and file names:
304 --prefix=PREFIX install files in tree rooted at PREFIX
305 [${cmake_default_prefix}]
306 --datadir=DIR install data files in PREFIX/DIR
307 [/share/CMake]
308 --docdir=DIR install documentation files in PREFIX/DIR
309 [/doc/CMake]
310 --mandir=DIR install man pages files in PREFIX/DIR/manN
311 [/man]
313 exit 10
316 # Display CMake bootstrap usage
317 cmake_version_display()
319 echo "CMake ${cmake_version_full}, Copyright (c) 2000-2009 Kitware, Inc., Insight Consortium"
322 # Display CMake bootstrap error, display the log file and exit
323 cmake_error()
325 res=$1
326 shift 1
327 echo "---------------------------------------------"
328 echo "Error when bootstrapping CMake:"
329 echo "$*"
330 echo "---------------------------------------------"
331 if [ -f cmake_bootstrap.log ]; then
332 echo "Log of errors: `pwd`/cmake_bootstrap.log"
333 #cat cmake_bootstrap.log
334 echo "---------------------------------------------"
336 exit ${res}
339 # Replace KWSYS_NAMESPACE with cmsys
340 cmake_replace_string ()
342 INFILE="$1"
343 OUTFILE="$2"
344 SEARCHFOR="$3"
345 REPLACEWITH="$4"
346 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
347 cat "${INFILE}" |
348 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
349 if [ -f "${OUTFILE}${_tmp}" ]; then
350 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
351 #echo "Files are the same"
352 rm -f "${OUTFILE}${_tmp}"
353 else
354 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
357 else
358 cmake_error 1 "Cannot find file ${INFILE}"
362 cmake_kwsys_config_replace_string ()
364 INFILE="$1"
365 OUTFILE="$2"
366 shift 2
367 APPEND="$*"
368 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
369 echo "${APPEND}" > "${OUTFILE}${_tmp}"
370 cat "${INFILE}" |
371 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
372 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
373 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
374 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
375 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
376 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
377 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
378 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
379 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
380 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
381 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
382 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
383 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
384 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
385 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
386 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
387 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
388 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
389 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
390 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
391 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
392 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
393 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
394 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
395 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
396 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
397 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
398 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}"
399 if [ -f "${OUTFILE}${_tmp}" ]; then
400 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
401 #echo "Files are the same"
402 rm -f "${OUTFILE}${_tmp}"
403 else
404 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
407 else
408 cmake_error 2 "Cannot find file ${INFILE}"
411 # Write string into a file
412 cmake_report ()
414 FILE=$1
415 shift
416 echo "$*" >> ${FILE}
419 # Escape spaces in strings
420 cmake_escape ()
422 echo $1 | sed "s/ /\\\\ /g"
425 # Write message to the log
426 cmake_log ()
428 echo "$*" >> cmake_bootstrap.log
431 # Return temp file
432 cmake_tmp_file ()
434 echo "cmake_bootstrap_$$_test"
437 # Run a compiler test. First argument is compiler, second one are compiler
438 # flags, third one is test source file to be compiled
439 cmake_try_run ()
441 COMPILER=$1
442 FLAGS=$2
443 TESTFILE=$3
444 if [ ! -f "${TESTFILE}" ]; then
445 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
446 exit 4
448 TMPFILE=`cmake_tmp_file`
449 echo "Try: ${COMPILER}"
450 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
451 echo "---------- file -----------------------"
452 cat "${TESTFILE}"
453 echo "------------------------------------------"
454 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
455 RES=$?
456 if [ "${RES}" -ne "0" ]; then
457 echo "Test failed to compile"
458 return 1
460 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
461 echo "Test failed to produce executable"
462 return 2
464 ./${TMPFILE}
465 RES=$?
466 rm -f "${TMPFILE}"
467 if [ "${RES}" -ne "0" ]; then
468 echo "Test produced non-zero return code"
469 return 3
471 echo "Test succeded"
472 return 0
475 # Run a make test. First argument is the make interpreter.
476 cmake_try_make ()
478 MAKE_PROC="$1"
479 MAKE_FLAGS="$2"
480 echo "Try: ${MAKE_PROC}"
481 "${MAKE_PROC}" ${MAKE_FLAGS}
482 RES=$?
483 if [ "${RES}" -ne "0" ]; then
484 echo "${MAKE_PROC} does not work"
485 return 1
487 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
488 echo "${COMPILER} does not produce output"
489 return 2
491 ./test
492 RES=$?
493 rm -f "test"
494 if [ "${RES}" -ne "0" ]; then
495 echo "${MAKE_PROC} produces strange executable"
496 return 3
498 echo "${MAKE_PROC} works"
499 return 0
502 # Parse arguments
503 cmake_verbose=
504 cmake_parallel_make=
505 cmake_prefix_dir="${cmake_default_prefix}"
506 for a in "$@"; do
507 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
508 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
509 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
511 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
512 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
514 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
515 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
517 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
518 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
520 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
521 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
523 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
524 cmake_init_file=`echo $a | sed "s/^--init=//"`
526 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
527 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
529 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
530 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
532 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
533 cmake_bootstrap_qt_gui="1"
535 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
536 cmake_bootstrap_qt_gui="0"
538 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
539 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
541 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
542 cmake_usage
544 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
545 cmake_version_display
546 exit 2
548 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
549 cmake_verbose=TRUE
551 done
553 # If verbose, display some information about bootstrap
554 if [ -n "${cmake_verbose}" ]; then
555 echo "---------------------------------------------"
556 echo "Source directory: ${cmake_source_dir}"
557 echo "Binary directory: ${cmake_binary_dir}"
558 echo "Prefix directory: ${cmake_prefix_dir}"
559 echo "System: ${cmake_system}"
560 if [ "x${cmake_parallel_make}" != "x" ]; then
561 echo "Doing parallel make: ${cmake_parallel_make}"
563 echo ""
566 echo "---------------------------------------------"
567 # Get CMake version
568 echo "`cmake_version_display`"
570 # Check for in-source build
571 cmake_in_source_build=
572 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
573 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
574 if [ -n "${cmake_verbose}" ]; then
575 echo "Warning: This is an in-source build"
577 cmake_in_source_build=TRUE
580 # If this is not an in-source build, then Bootstrap stuff should not exist.
581 if [ -z "${cmake_in_source_build}" ]; then
582 # Did somebody bootstrap in the source tree?
583 if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
584 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
585 Looks like somebody did bootstrap CMake in the source tree, but now you are
586 trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
587 directory from the source tree."
589 # Is there a cache in the source tree?
590 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
591 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
592 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
593 Looks like somebody tried to build CMake in the source tree, but now you are
594 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
595 from the source tree."
597 done
600 # Make bootstrap directory
601 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
602 if [ ! -d "${cmake_bootstrap_dir}" ]; then
603 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
605 cd "${cmake_bootstrap_dir}"
607 [ -d "cmsys" ] || mkdir "cmsys"
608 if [ ! -d "cmsys" ]; then
609 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
612 for a in stl ios; do
613 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
614 if [ ! -d "cmsys/${a}" ]; then
615 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
617 done
619 # Delete all the bootstrap files
620 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
621 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
622 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
624 # If exist compiler flags, set them
625 cmake_c_flags=${CFLAGS}
626 cmake_cxx_flags=${CXXFLAGS}
627 cmake_ld_flags=${LDFLAGS}
629 # Add Cygwin-specific flags
630 if ${cmake_system_cygwin}; then
631 cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
634 # Add Carbon framework on Darwin
635 if ${cmake_system_darwin}; then
636 cmake_ld_flags="${LDFLAGS} -framework Carbon"
639 # Add BeOS toolkits...
640 if ${cmake_system_beos}; then
641 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
644 # Add Haiku toolkits...
645 if ${cmake_system_haiku}; then
646 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
649 # Test C compiler
650 cmake_c_compiler=
652 # If CC is set, use that for compiler, otherwise use list of known compilers
653 if [ -n "${CC}" ]; then
654 cmake_c_compilers="${CC}"
655 else
656 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
659 # Check if C compiler works
660 TMPFILE=`cmake_tmp_file`
661 echo '
662 #ifdef __cplusplus
663 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
664 #endif
666 #include<stdio.h>
668 #if defined(__CLASSIC_C__)
669 int main(argc, argv)
670 int argc;
671 char* argv[];
672 #else
673 int main(int argc, char* argv[])
674 #endif
676 printf("%d%c", (argv != 0), (char)0x0a);
677 return argc-1;
679 ' > "${TMPFILE}.c"
680 for a in ${cmake_c_compilers}; do
681 if [ -z "${cmake_c_compiler}" ] && \
682 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
683 cmake_c_compiler="${a}"
685 done
686 rm -f "${TMPFILE}.c"
688 if [ -z "${cmake_c_compiler}" ]; then
689 cmake_error 6 "Cannot find appropriate C compiler on this system.
690 Please specify one using environment variable CC.
691 See cmake_bootstrap.log for compilers attempted.
694 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
696 # Test CXX compiler
697 cmake_cxx_compiler=
699 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
701 # If CC is set, use that for compiler, otherwise use list of known compilers
702 if [ -n "${CXX}" ]; then
703 cmake_cxx_compilers="${CXX}"
704 else
705 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
708 # Check if C++ compiler works
709 TMPFILE=`cmake_tmp_file`
710 echo '
711 #if defined(TEST1)
712 # include <iostream>
713 #else
714 # include <iostream.h>
715 #endif
717 class NeedCXX
719 public:
720 NeedCXX() { this->Foo = 1; }
721 int GetFoo() { return this->Foo; }
722 private:
723 int Foo;
725 int main()
727 NeedCXX c;
728 #ifdef TEST3
729 cout << c.GetFoo() << endl;
730 #else
731 std::cout << c.GetFoo() << std::endl;
732 #endif
733 return 0;
735 ' > "${TMPFILE}.cxx"
736 for a in ${cmake_cxx_compilers}; do
737 for b in 1 2 3; do
738 if [ -z "${cmake_cxx_compiler}" ] && \
739 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
740 cmake_cxx_compiler="${a}"
742 done
743 done
744 rm -f "${TMPFILE}.cxx"
746 if [ -z "${cmake_cxx_compiler}" ]; then
747 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
748 Please specify one using environment variable CXX.
749 See cmake_bootstrap.log for compilers attempted."
751 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
753 # Test Make
755 cmake_make_processor=
756 cmake_make_flags=
758 # If MAKE is set, use that for make processor, otherwise use list of known make
759 if [ -n "${MAKE}" ]; then
760 cmake_make_processors="${MAKE}"
761 else
762 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
765 TMPFILE="`cmake_tmp_file`_dir"
766 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
767 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
768 cd "${cmake_bootstrap_dir}/${TMPFILE}"
769 echo '
770 test: test.c
771 "'"${cmake_c_compiler}"'" -o test test.c
772 '>"Makefile"
773 echo '
774 #include <stdio.h>
775 int main(){ printf("1%c", (char)0x0a); return 0; }
776 ' > "test.c"
777 cmake_original_make_flags="${cmake_make_flags}"
778 if [ "x${cmake_parallel_make}" != "x" ]; then
779 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
781 for a in ${cmake_make_processors}; do
782 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
783 cmake_make_processor="${a}"
785 done
786 cmake_full_make_flags="${cmake_make_flags}"
787 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
788 if [ -z "${cmake_make_processor}" ]; then
789 cmake_make_flags="${cmake_original_make_flags}"
790 for a in ${cmake_make_processors}; do
791 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
792 cmake_make_processor="${a}"
794 done
797 cd "${cmake_bootstrap_dir}"
798 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
800 if [ -z "${cmake_make_processor}" ]; then
801 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
802 Please specify one using environment variable MAKE."
804 echo "Makefile processor on this system is: ${cmake_make_processor}"
805 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
806 echo "---------------------------------------------"
807 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
808 echo "---------------------------------------------"
811 # Ok, we have CC, CXX, and MAKE.
813 # Test C++ compiler features
815 # Are we GCC?
817 TMPFILE=`cmake_tmp_file`
818 echo '
819 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
820 #include <iostream>
821 int main() { std::cout << "This is GNU" << std::endl; return 0;}
822 #endif
823 ' > ${TMPFILE}.cxx
824 cmake_cxx_compiler_is_gnu=0
825 if cmake_try_run "${cmake_cxx_compiler}" \
826 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
827 cmake_cxx_compiler_is_gnu=1
829 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
830 echo "${cmake_cxx_compiler} is GNU compiler"
831 else
832 echo "${cmake_cxx_compiler} is not GNU compiler"
834 rm -f "${TMPFILE}.cxx"
836 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
837 # Check for non-GNU compiler flags
839 # If we are on IRIX, check for -LANG:std
840 cmake_test_flags="-LANG:std"
841 if [ "x${cmake_system}" = "xIRIX64" ]; then
842 TMPFILE=`cmake_tmp_file`
843 echo '
844 #include <iostream>
845 int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
846 ' > ${TMPFILE}.cxx
847 cmake_need_lang_std=0
848 if cmake_try_run "${cmake_cxx_compiler}" \
849 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
851 else
852 if cmake_try_run "${cmake_cxx_compiler}" \
853 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
854 cmake_need_lang_std=1
857 if [ "x${cmake_need_lang_std}" = "x1" ]; then
858 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
859 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
860 else
861 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
863 rm -f "${TMPFILE}.cxx"
865 cmake_test_flags=
867 # If we are on OSF, check for -timplicit_local -no_implicit_include
868 cmake_test_flags="-timplicit_local -no_implicit_include"
869 if [ "x${cmake_system}" = "xOSF1" ]; then
870 TMPFILE=`cmake_tmp_file`
871 echo '
872 #include <iostream>
873 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
874 ' > ${TMPFILE}.cxx
875 cmake_need_flags=1
876 if cmake_try_run "${cmake_cxx_compiler}" \
877 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
879 else
880 cmake_need_flags=0
882 if [ "x${cmake_need_flags}" = "x1" ]; then
883 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
884 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
885 else
886 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
888 rm -f "${TMPFILE}.cxx"
890 cmake_test_flags=
892 # If we are on OSF, check for -std strict_ansi -nopure_cname
893 cmake_test_flags="-std strict_ansi -nopure_cname"
894 if [ "x${cmake_system}" = "xOSF1" ]; then
895 TMPFILE=`cmake_tmp_file`
896 echo '
897 #include <iostream>
898 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
899 ' > ${TMPFILE}.cxx
900 cmake_need_flags=1
901 if cmake_try_run "${cmake_cxx_compiler}" \
902 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
904 else
905 cmake_need_flags=0
907 if [ "x${cmake_need_flags}" = "x1" ]; then
908 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
909 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
910 else
911 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
913 rm -f "${TMPFILE}.cxx"
915 cmake_test_flags=
917 # If we are on HP-UX, check for -Ae for the C compiler.
918 cmake_test_flags="-Ae"
919 if [ "x${cmake_system}" = "xHP-UX" ]; then
920 TMPFILE=`cmake_tmp_file`
921 echo '
922 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
923 ' > ${TMPFILE}.c
924 cmake_need_Ae=0
925 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
927 else
928 if cmake_try_run "${cmake_c_compiler}" \
929 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
930 cmake_need_Ae=1
933 if [ "x${cmake_need_Ae}" = "x1" ]; then
934 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
935 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
936 else
937 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
939 rm -f "${TMPFILE}.c"
941 cmake_test_flags=
944 # Test for kwsys features
945 KWSYS_NAME_IS_KWSYS=0
946 KWSYS_BUILD_SHARED=0
947 KWSYS_LFS_AVAILABLE=0
948 KWSYS_LFS_REQUESTED=0
949 KWSYS_IOS_USE_STRSTREAM_H=0
950 KWSYS_IOS_USE_STRSTREA_H=0
951 KWSYS_IOS_HAVE_STD=0
952 KWSYS_IOS_USE_SSTREAM=0
953 KWSYS_IOS_USE_ANSI=0
954 KWSYS_STL_HAVE_STD=0
955 KWSYS_STAT_HAS_ST_MTIM=0
956 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
957 KWSYS_STL_HAS_ITERATOR_TRAITS=0
958 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
959 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
960 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
961 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
962 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
963 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
964 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
965 KWSYS_CXX_HAS_CSTDDEF=0
966 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
967 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
968 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
969 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
971 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
972 KWSYS_STL_STRING_HAVE_ISTREAM=1
973 KWSYS_STL_STRING_HAVE_OSTREAM=1
975 if cmake_try_run "${cmake_cxx_compiler}" \
976 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
977 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
978 KWSYS_STL_HAVE_STD=1
979 echo "${cmake_cxx_compiler} has STL in std:: namespace"
980 else
981 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
984 if cmake_try_run "${cmake_cxx_compiler}" \
985 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
986 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
987 KWSYS_IOS_USE_ANSI=1
988 echo "${cmake_cxx_compiler} has ANSI streams"
989 else
990 echo "${cmake_cxx_compiler} does not have ANSI streams"
993 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
994 if cmake_try_run "${cmake_cxx_compiler}" \
995 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
996 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
997 KWSYS_IOS_HAVE_STD=1
998 echo "${cmake_cxx_compiler} has streams in std:: namespace"
999 else
1000 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
1002 if cmake_try_run "${cmake_cxx_compiler}" \
1003 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
1004 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1005 KWSYS_IOS_USE_SSTREAM=1
1006 echo "${cmake_cxx_compiler} has sstream"
1007 else
1008 echo "${cmake_cxx_compiler} does not have sstream"
1012 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
1013 if cmake_try_run "${cmake_cxx_compiler}" \
1014 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
1015 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1016 KWSYS_IOS_USE_STRSTREAM_H=1
1017 echo "${cmake_cxx_compiler} has strstream.h"
1018 else
1019 echo "${cmake_cxx_compiler} does not have strstream.h"
1021 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
1022 if cmake_try_run "${cmake_cxx_compiler}" \
1023 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
1024 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1025 KWSYS_IOS_USE_STRSTREA_H=1
1026 echo "${cmake_cxx_compiler} has strstrea.h"
1027 else
1028 echo "${cmake_cxx_compiler} does not have strstrea.h"
1033 if cmake_try_run "${cmake_cxx_compiler}" \
1034 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1035 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1036 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1037 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1038 else
1039 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1042 if cmake_try_run "${cmake_cxx_compiler}" \
1043 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1044 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1045 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1046 echo "${cmake_cxx_compiler} has stl iterator_traits"
1047 else
1048 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1051 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1052 if cmake_try_run "${cmake_cxx_compiler}" \
1053 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1054 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1055 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1056 echo "${cmake_cxx_compiler} has old iterator_category"
1057 else
1058 echo "${cmake_cxx_compiler} does not have old iterator_category"
1060 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1061 if cmake_try_run "${cmake_cxx_compiler}" \
1062 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1063 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1064 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1065 echo "${cmake_cxx_compiler} has old __iterator_category"
1066 else
1067 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1072 if cmake_try_run "${cmake_cxx_compiler}" \
1073 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1074 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1075 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1076 echo "${cmake_cxx_compiler} has standard template allocator"
1077 else
1078 echo "${cmake_cxx_compiler} does not have standard template allocator"
1081 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1082 if cmake_try_run "${cmake_cxx_compiler}" \
1083 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1084 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1085 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1086 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1087 else
1088 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1091 if cmake_try_run "${cmake_cxx_compiler}" \
1092 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1093 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1094 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1095 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1096 else
1097 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1099 else
1100 if cmake_try_run "${cmake_cxx_compiler}" \
1101 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1102 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1103 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1104 echo "${cmake_cxx_compiler} has old non-template allocator"
1105 else
1106 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1110 if cmake_try_run "${cmake_cxx_compiler}" \
1111 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1112 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1113 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1114 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1115 else
1116 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1119 if cmake_try_run "${cmake_cxx_compiler}" \
1120 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1121 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1122 KWSYS_CXX_HAS_CSTDDEF=1
1123 echo "${cmake_cxx_compiler} has header cstddef"
1124 else
1125 echo "${cmake_cxx_compiler} does not have header cstddef"
1128 if cmake_try_run "${cmake_cxx_compiler}" \
1129 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1130 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1131 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1132 else
1133 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1134 echo "${cmake_cxx_compiler} requires template friends to use <>"
1137 if cmake_try_run "${cmake_cxx_compiler}" \
1138 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1139 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1140 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1141 echo "${cmake_cxx_compiler} supports member templates"
1142 else
1143 echo "${cmake_cxx_compiler} does not support member templates"
1146 if cmake_try_run "${cmake_cxx_compiler}" \
1147 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1148 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1149 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1150 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1151 else
1152 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1155 if cmake_try_run "${cmake_cxx_compiler}" \
1156 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1157 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1158 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1159 echo "${cmake_cxx_compiler} has argument dependent lookup"
1160 else
1161 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1164 if cmake_try_run "${cmake_cxx_compiler}" \
1165 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1166 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1167 KWSYS_STAT_HAS_ST_MTIM=1
1168 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1169 else
1170 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1173 # Just to be safe, let us store compiler and flags to the header file
1175 cmake_bootstrap_version='$Revision: 1.122 $'
1176 cmake_compiler_settings_comment="/*
1177 * Generated by ${cmake_source_dir}/bootstrap
1178 * Version: ${cmake_bootstrap_version}
1180 * Source directory: ${cmake_source_dir}
1181 * Binary directory: ${cmake_bootstrap_dir}
1183 * C compiler: ${cmake_c_compiler}
1184 * C flags: ${cmake_c_flags}
1186 * C++ compiler: ${cmake_cxx_compiler}
1187 * C++ flags: ${cmake_cxx_flags}
1189 * Make: ${cmake_make_processor}
1191 * Sources:
1192 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1193 * kwSys Sources:
1194 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1198 cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
1200 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1201 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_STD_NAMESPACE */"
1202 else
1203 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_STD_NAMESPACE 1"
1206 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1207 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1208 else
1209 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1212 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1213 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1214 else
1215 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1218 # Test for ansi FOR scope
1219 if cmake_try_run "${cmake_cxx_compiler}" \
1220 "${cmake_cxx_flags}" \
1221 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1222 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1223 echo "${cmake_cxx_compiler} has ANSI for scoping"
1224 else
1225 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1226 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1229 # When bootstrapping on MinGW with MSYS we must convert the source
1230 # directory to a windows path.
1231 if ${cmake_system_mingw}; then
1232 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1233 else
1234 cmake_root_dir="${cmake_source_dir}"
1237 # Write CMake version
1238 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1239 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1240 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1241 cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1242 cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1243 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
1245 # Regenerate configured headers
1246 for h in Configure VersionConfig; do
1247 if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
1248 rm -f cm${h}.h${_tmp}
1249 else
1250 mv -f cm${h}.h${_tmp} cm${h}.h
1252 done
1254 # Prepare KWSYS
1255 cmake_kwsys_config_replace_string \
1256 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1257 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1258 "${cmake_compiler_settings_comment}"
1259 cmake_kwsys_config_replace_string \
1260 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1261 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1262 "${cmake_compiler_settings_comment}"
1264 for a in ${KWSYS_FILES}; do
1265 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1266 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1267 done
1269 for a in ${KWSYS_IOS_FILES}; do
1270 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1271 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1272 done
1274 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1275 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" KWSYS_STL_HEADER_EXTRA ""
1277 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" \
1278 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" KWSYS_NAMESPACE cmsys
1280 for a in string vector map algorithm; do
1281 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" \
1282 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1283 done
1285 # Generate Makefile
1286 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1287 objs=""
1288 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1289 objs="${objs} ${a}.o"
1290 done
1292 # Generate dependencies for cmBootstrapCommands.cxx
1293 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1294 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1295 done
1296 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1298 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1299 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1302 if [ "x${cmake_c_flags}" != "x" ]; then
1303 cmake_c_flags="${cmake_c_flags} "
1306 if [ "x${cmake_cxx_flags}" != "x" ]; then
1307 cmake_cxx_flags="${cmake_cxx_flags} "
1310 cmake_c_flags_String="-DKWSYS_STRING_C"
1311 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1312 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1313 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1314 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1315 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1316 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1317 for a in ${CMAKE_CXX_SOURCES}; do
1318 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1319 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1320 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1321 done
1322 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1323 for a in ${CMAKE_C_SOURCES}; do
1324 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1325 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1326 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1327 done
1328 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1329 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1330 src_flags=`eval echo \\${cmake_c_flags_\${a}}`
1331 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1332 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1333 done
1334 for a in ${KWSYS_CXX_SOURCES}; do
1335 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1336 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1337 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1338 done
1339 if ${cmake_system_mingw}; then
1340 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1341 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1342 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1343 a="cmsysProcessFwd9xEnc"
1344 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1345 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1346 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1347 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1348 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1349 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1350 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1351 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"
1353 echo '
1354 rebuild_cache:
1355 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1356 ' >> "${cmake_bootstrap_dir}/Makefile"
1358 # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
1359 echo '
1360 # Generated by '"${cmake_source_dir}"'/bootstrap
1361 # Default cmake settings. These may be overridden any settings below.
1362 SET (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1363 SET (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1364 SET (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1365 SET (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1366 ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1368 # Add configuration settings given as command-line options.
1369 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1370 echo '
1371 SET (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
1372 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1374 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1375 echo '
1376 SET (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
1377 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1380 # Add user-specified settings. Handle relative-path case for
1381 # specification of cmake_init_file.
1383 cd "${cmake_binary_dir}"
1384 if [ -f "${cmake_init_file}" ]; then
1385 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1389 echo "---------------------------------------------"
1391 # Run make to build bootstrap cmake
1392 if [ "x${cmake_parallel_make}" != "x" ]; then
1393 ${cmake_make_processor} ${cmake_make_flags}
1394 else
1395 ${cmake_make_processor}
1397 RES=$?
1398 if [ "${RES}" -ne "0" ]; then
1399 cmake_error 9 "Problem while running ${cmake_make_processor}"
1401 cd "${cmake_binary_dir}"
1403 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1404 # build with same compiler and make
1405 CC="${cmake_c_compiler}"
1406 CXX="${cmake_cxx_compiler}"
1407 MAKE="${cmake_make_processor}"
1408 export CC
1409 export CXX
1410 export MAKE
1412 # Run bootstrap CMake to configure real CMake
1413 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1414 RES=$?
1415 if [ "${RES}" -ne "0" ]; then
1416 cmake_error 11 "Problem while running initial CMake"
1419 echo "---------------------------------------------"
1421 # And we are done. Now just run make
1422 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."