BUG: Fix KWSys SystemInformation dependencies
[cmake.git] / bootstrap
blob9679235d5e78780a471388c140ffc06004e3bf58
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2008-09-15 21:53:27 $
9 # Version: $Revision: 1.114 $
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_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
41 cmake_version_major="`cmake_version_component MAJOR`"
42 cmake_version_minor="`cmake_version_component MINOR`"
43 cmake_version_patch="`cmake_version_component PATCH`"
44 cmake_version="${cmake_version_major}.${cmake_version_minor}"
45 cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
46 cmake_date_stamp="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
47 cmake_data_dir="/share/cmake-${cmake_version}"
48 cmake_doc_dir="/doc/cmake-${cmake_version}"
49 cmake_man_dir="/man"
50 cmake_init_file=""
51 cmake_bootstrap_system_libs=""
52 cmake_bootstrap_qt_gui=""
53 cmake_bootstrap_qt_qmake=""
55 # Determine whether this is a MinGW environment.
56 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
57 cmake_system_mingw=true
58 else
59 cmake_system_mingw=false
62 # Determine whether this is OS X
63 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
64 cmake_system_darwin=true
65 else
66 cmake_system_darwin=false
69 # Determine whether this is BeOS
70 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
71 cmake_system_beos=true
72 else
73 cmake_system_beos=false
76 # Determine whether this is Haiku
77 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
78 cmake_system_haiku=true
79 else
80 cmake_system_haiku=false
83 # Choose the generator to use for bootstrapping.
84 if ${cmake_system_mingw}; then
85 # Bootstrapping from an MSYS prompt.
86 cmake_bootstrap_generator="MSYS Makefiles"
87 else
88 # Bootstrapping from a standard UNIX prompt.
89 cmake_bootstrap_generator="Unix Makefiles"
92 # Helper function to fix windows paths.
93 cmake_fix_slashes ()
95 echo "$1" | sed 's/\\/\//g'
98 # Choose the default install prefix.
99 if ${cmake_system_mingw}; then
100 if [ "x${PROGRAMFILES}" != "x" ]; then
101 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
102 elif [ "x${ProgramFiles}" != "x" ]; then
103 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
104 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
105 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
106 elif [ "x${SystemDrive}" != "x" ]; then
107 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
108 else
109 cmake_default_prefix="c:/Program Files/CMake"
111 else
112 cmake_default_prefix="/usr/local"
115 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
116 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
117 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
119 CMAKE_PROBLEMATIC_FILES="\
120 CMakeCache.txt \
121 CMakeSystem.cmake \
122 CMakeCCompiler.cmake \
123 CMakeCXXCompiler.cmake \
124 Source/cmConfigure.h \
125 Source/CTest/Curl/config.h \
126 Utilities/cmexpat/expatConfig.h \
127 Utilities/cmexpat/expatDllConfig.h \
130 CMAKE_UNUSED_SOURCES="\
131 cmGlobalXCodeGenerator \
132 cmLocalXCodeGenerator \
133 cmXCodeObject \
134 cmXCode21Object \
135 cmSourceGroup \
138 CMAKE_CXX_SOURCES="\
139 cmake \
140 cmakemain \
141 cmakewizard \
142 cmCommandArgumentLexer \
143 cmCommandArgumentParser \
144 cmCommandArgumentParserHelper \
145 cmDepends \
146 cmDependsC \
147 cmDocumentationFormatter \
148 cmDocumentationFormatterText \
149 cmPolicies \
150 cmProperty \
151 cmPropertyMap \
152 cmPropertyDefinition \
153 cmPropertyDefinitionMap \
154 cmMakeDepend \
155 cmMakefile \
156 cmExportFileGenerator \
157 cmExportInstallFileGenerator \
158 cmInstallDirectoryGenerator \
159 cmGeneratedFileStream \
160 cmGlobalGenerator \
161 cmLocalGenerator \
162 cmInstallGenerator \
163 cmInstallExportGenerator \
164 cmInstallFilesGenerator \
165 cmInstallScriptGenerator \
166 cmInstallTargetGenerator \
167 cmSourceFile \
168 cmSourceFileLocation \
169 cmSystemTools \
170 cmVersion \
171 cmFileTimeComparison \
172 cmGlobalUnixMakefileGenerator3 \
173 cmLocalUnixMakefileGenerator3 \
174 cmMakefileExecutableTargetGenerator \
175 cmMakefileLibraryTargetGenerator \
176 cmMakefileTargetGenerator \
177 cmMakefileUtilityTargetGenerator \
178 cmBootstrapCommands \
179 cmCommands \
180 cmTarget \
181 cmTest \
182 cmCustomCommand \
183 cmDocumentVariables \
184 cmCacheManager \
185 cmListFileCache \
186 cmComputeLinkDepends \
187 cmComputeLinkInformation \
188 cmOrderDirectories \
189 cmComputeTargetDepends \
190 cmComputeComponentGraph \
191 cmExprLexer \
192 cmExprParser \
193 cmExprParserHelper \
196 if ${cmake_system_mingw}; then
197 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
198 cmGlobalMSYSMakefileGenerator \
199 cmGlobalMinGWMakefileGenerator \
200 cmWin32ProcessExecution"
203 CMAKE_C_SOURCES="\
204 cmListFileLexer \
207 if ${cmake_system_mingw}; then
208 KWSYS_C_SOURCES="\
209 ProcessWin32 \
210 String \
211 System"
212 KWSYS_C_MINGW_SOURCES="\
213 ProcessFwd9x \
214 EncodeExecutable"
215 KWSYS_C_GENERATED_SOURCES="\
216 cmsysProcessFwd9xEnc"
217 else
218 KWSYS_C_SOURCES="\
219 ProcessUNIX \
220 String \
221 System"
222 KWSYS_C_MINGW_SOURCES=""
223 KWSYS_C_GENERATED_SOURCES=""
226 KWSYS_CXX_SOURCES="\
227 Directory \
228 Glob \
229 RegularExpression \
230 SystemTools"
232 KWSYS_FILES="\
233 auto_ptr.hxx \
234 Directory.hxx \
235 Glob.hxx \
236 Process.h \
237 RegularExpression.hxx \
238 String.h \
239 String.hxx \
240 System.h \
241 SystemTools.hxx"
243 KWSYS_IOS_FILES="
244 fstream \
245 iosfwd \
246 iostream \
247 sstream"
249 # Display CMake bootstrap usage
250 cmake_usage()
252 cat <<EOF
253 Usage: $0 [options]
254 Options: [defaults in brackets after descriptions]
255 Configuration:
256 --help print this message
257 --version only print version information
258 --verbose display more information
259 --parallel=n bootstrap cmake in parallel, where n is
260 number of nodes [1]
261 --init=FILE use FILE for cmake initialization
262 --system-libs use system-installed third-party libraries
263 (for use only by package maintainers)
264 --no-system-libs use cmake-provided third-party libraries
265 (default)
266 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
267 --no-qt-gui do not build the Qt-based GUI (default)
268 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
270 Directory and file names:
271 --prefix=PREFIX install files in tree rooted at PREFIX
272 [${cmake_default_prefix}]
273 --datadir=DIR install data files in PREFIX/DIR
274 [/share/CMake]
275 --docdir=DIR install documentation files in PREFIX/DIR
276 [/doc/CMake]
277 --mandir=DIR install man pages files in PREFIX/DIR/manN
278 [/man]
280 exit 10
283 # Display CMake bootstrap usage
284 cmake_version_display()
287 # Get CMake version
288 if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
289 version="${cmake_version}-${cmake_date_stamp}"
290 else
291 version="${cmake_version}-${cmake_version_patch}"
293 echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
297 # Display CMake bootstrap error, display the log file and exit
298 cmake_error()
300 res=$1
301 shift 1
302 echo "---------------------------------------------"
303 echo "Error when bootstrapping CMake:"
304 echo "$*"
305 echo "---------------------------------------------"
306 if [ -f cmake_bootstrap.log ]; then
307 echo "Log of errors: `pwd`/cmake_bootstrap.log"
308 #cat cmake_bootstrap.log
309 echo "---------------------------------------------"
311 exit ${res}
314 # Replace KWSYS_NAMESPACE with cmsys
315 cmake_replace_string ()
317 INFILE="$1"
318 OUTFILE="$2"
319 SEARCHFOR="$3"
320 REPLACEWITH="$4"
321 if [ -f "${INFILE}" ]; then
322 cat "${INFILE}" |
323 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
324 if [ -f "${OUTFILE}.tmp" ]; then
325 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
326 #echo "Files are the same"
327 rm -f "${OUTFILE}.tmp"
328 else
329 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
332 else
333 cmake_error 1 "Cannot find file ${INFILE}"
337 cmake_kwsys_config_replace_string ()
339 INFILE="$1"
340 OUTFILE="$2"
341 shift 2
342 APPEND="$*"
343 if [ -f "${INFILE}" ]; then
344 echo "${APPEND}" > "${OUTFILE}.tmp"
345 cat "${INFILE}" |
346 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
347 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
348 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
349 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
350 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
351 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
352 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
353 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
354 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
355 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
356 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
357 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
358 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
359 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
360 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
361 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
362 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
363 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
364 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
365 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
366 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
367 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
368 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
369 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
370 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
371 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
372 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
373 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
374 if [ -f "${OUTFILE}.tmp" ]; then
375 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
376 #echo "Files are the same"
377 rm -f "${OUTFILE}.tmp"
378 else
379 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
382 else
383 cmake_error 2 "Cannot find file ${INFILE}"
386 # Write string into a file
387 cmake_report ()
389 FILE=$1
390 shift
391 echo "$*" >> ${FILE}
394 # Escape spaces in strings
395 cmake_escape ()
397 echo $1 | sed "s/ /\\\\ /g"
400 # Write message to the log
401 cmake_log ()
403 echo "$*" >> cmake_bootstrap.log
406 # Return temp file
407 cmake_tmp_file ()
409 echo "cmake_bootstrap_$$.test"
412 # Run a compiler test. First argument is compiler, second one are compiler
413 # flags, third one is test source file to be compiled
414 cmake_try_run ()
416 COMPILER=$1
417 FLAGS=$2
418 TESTFILE=$3
419 if [ ! -f "${TESTFILE}" ]; then
420 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
421 exit 4
423 TMPFILE=`cmake_tmp_file`
424 echo "Try: ${COMPILER}"
425 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
426 echo "---------- file -----------------------"
427 cat "${TESTFILE}"
428 echo "------------------------------------------"
429 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
430 RES=$?
431 if [ "${RES}" -ne "0" ]; then
432 echo "Test failed to compile"
433 return 1
435 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
436 echo "Test failed to produce executable"
437 return 2
439 ./${TMPFILE}
440 RES=$?
441 rm -f "${TMPFILE}"
442 if [ "${RES}" -ne "0" ]; then
443 echo "Test produced non-zero return code"
444 return 3
446 echo "Test succeded"
447 return 0
450 # Run a make test. First argument is the make interpreter.
451 cmake_try_make ()
453 MAKE_PROC="$1"
454 MAKE_FLAGS="$2"
455 echo "Try: ${MAKE_PROC}"
456 "${MAKE_PROC}" ${MAKE_FLAGS}
457 RES=$?
458 if [ "${RES}" -ne "0" ]; then
459 echo "${MAKE_PROC} does not work"
460 return 1
462 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
463 echo "${COMPILER} does not produce output"
464 return 2
466 ./test
467 RES=$?
468 rm -f "test"
469 if [ "${RES}" -ne "0" ]; then
470 echo "${MAKE_PROC} produces strange executable"
471 return 3
473 echo "${MAKE_PROC} works"
474 return 0
477 # Parse arguments
478 cmake_verbose=
479 cmake_parallel_make=
480 cmake_prefix_dir="${cmake_default_prefix}"
481 for a in "$@"; do
482 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
483 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
484 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
486 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
487 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
489 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
490 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
492 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
493 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
495 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
496 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
498 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
499 cmake_init_file=`echo $a | sed "s/^--init=//"`
501 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
502 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
504 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
505 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
507 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
508 cmake_bootstrap_qt_gui="1"
510 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
511 cmake_bootstrap_qt_gui="0"
513 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
514 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
516 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
517 cmake_usage
519 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
520 cmake_version_display
521 exit 2
523 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
524 cmake_verbose=TRUE
526 done
528 # If verbose, display some information about bootstrap
529 if [ -n "${cmake_verbose}" ]; then
530 echo "---------------------------------------------"
531 echo "Source directory: ${cmake_source_dir}"
532 echo "Binary directory: ${cmake_binary_dir}"
533 echo "Prefix directory: ${cmake_prefix_dir}"
534 echo "System: ${cmake_system}"
535 if [ "x${cmake_parallel_make}" != "x" ]; then
536 echo "Doing parallel make: ${cmake_parallel_make}"
538 echo ""
541 echo "---------------------------------------------"
542 # Get CMake version
543 echo "`cmake_version_display`"
545 # Check for in-source build
546 cmake_in_source_build=
547 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
548 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
549 if [ -n "${cmake_verbose}" ]; then
550 echo "Warning: This is an in-source build"
552 cmake_in_source_build=TRUE
555 # If this is not an in-source build, then Bootstrap stuff should not exist.
556 if [ -z "${cmake_in_source_build}" ]; then
557 # Did somebody bootstrap in the source tree?
558 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
559 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
560 Looks like somebody did bootstrap CMake in the source tree, but now you are
561 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
562 directory from the source tree."
564 # Is there a cache in the source tree?
565 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
566 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
567 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
568 Looks like somebody tried to build CMake in the source tree, but now you are
569 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
570 from the source tree."
572 done
575 # Make bootstrap directory
576 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
577 if [ ! -d "${cmake_bootstrap_dir}" ]; then
578 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
580 cd "${cmake_bootstrap_dir}"
582 [ -d "cmsys" ] || mkdir "cmsys"
583 if [ ! -d "cmsys" ]; then
584 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
587 for a in stl ios; do
588 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
589 if [ ! -d "cmsys/${a}" ]; then
590 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
592 done
594 # Delete all the bootstrap files
595 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
596 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
598 # If exist compiler flags, set them
599 cmake_c_flags=${CFLAGS}
600 cmake_cxx_flags=${CXXFLAGS}
601 cmake_ld_flags=${LDFLAGS}
603 # Add Carbon framework on Darwin
604 if ${cmake_system_darwin}; then
605 cmake_ld_flags="${LDFLAGS} -framework Carbon"
608 # Add BeOS toolkits...
609 if ${cmake_system_beos}; then
610 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
613 # Add Haiku toolkits...
614 if ${cmake_system_haiku}; then
615 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
618 # Test C compiler
619 cmake_c_compiler=
621 # If CC is set, use that for compiler, otherwise use list of known compilers
622 if [ -n "${CC}" ]; then
623 cmake_c_compilers="${CC}"
624 else
625 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
628 # Check if C compiler works
629 TMPFILE=`cmake_tmp_file`
630 cat > "${TMPFILE}.c" <<EOF
631 #ifdef __cplusplus
632 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
633 #endif
635 #include<stdio.h>
637 #if defined(__CLASSIC_C__)
638 int main(argc, argv)
639 int argc;
640 char* argv[];
641 #else
642 int main(int argc, char* argv[])
643 #endif
645 printf("%d\n", (argv != 0));
646 return argc-1;
649 for a in ${cmake_c_compilers}; do
650 if [ -z "${cmake_c_compiler}" ] && \
651 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
652 cmake_c_compiler="${a}"
654 done
655 rm -f "${TMPFILE}.c"
657 if [ -z "${cmake_c_compiler}" ]; then
658 cmake_error 6 "Cannot find appropriate C compiler on this system.
659 Please specify one using environment variable CC.
660 See cmake_bootstrap.log for compilers attempted.
663 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
665 # Test CXX compiler
666 cmake_cxx_compiler=
668 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
670 # If CC is set, use that for compiler, otherwise use list of known compilers
671 if [ -n "${CXX}" ]; then
672 cmake_cxx_compilers="${CXX}"
673 else
674 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
677 # Check if C++ compiler works
678 TMPFILE=`cmake_tmp_file`
679 cat > "${TMPFILE}.cxx" <<EOF
680 #if defined(TEST1)
681 # include <iostream>
682 #else
683 # include <iostream.h>
684 #endif
686 class NeedCXX
688 public:
689 NeedCXX() { this->Foo = 1; }
690 int GetFoo() { return this->Foo; }
691 private:
692 int Foo;
694 int main()
696 NeedCXX c;
697 #ifdef TEST3
698 cout << c.GetFoo() << endl;
699 #else
700 std::cout << c.GetFoo() << std::endl;
701 #endif
702 return 0;
705 for a in ${cmake_cxx_compilers}; do
706 for b in 1 2 3; do
707 if [ -z "${cmake_cxx_compiler}" ] && \
708 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
709 cmake_cxx_compiler="${a}"
711 done
712 done
713 rm -f "${TMPFILE}.cxx"
715 if [ -z "${cmake_cxx_compiler}" ]; then
716 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
717 Please specify one using environment variable CXX.
718 See cmake_bootstrap.log for compilers attempted."
720 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
722 # Test Make
724 cmake_make_processor=
725 cmake_make_flags=
727 # If MAKE is set, use that for make processor, otherwise use list of known make
728 if [ -n "${MAKE}" ]; then
729 cmake_make_processors="${MAKE}"
730 else
731 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
734 TMPFILE="`cmake_tmp_file`_dir"
735 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
736 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
737 cd "${cmake_bootstrap_dir}/${TMPFILE}"
738 cat>"Makefile"<<EOF
739 test: test.c
740 "${cmake_c_compiler}" -o test test.c
742 cat>"test.c"<<EOF
743 #include <stdio.h>
744 int main(){ printf("1\n"); return 0; }
746 cmake_original_make_flags="${cmake_make_flags}"
747 if [ "x${cmake_parallel_make}" != "x" ]; then
748 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
750 for a in ${cmake_make_processors}; do
751 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
752 cmake_make_processor="${a}"
754 done
755 cmake_full_make_flags="${cmake_make_flags}"
756 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
757 if [ -z "${cmake_make_processor}" ]; then
758 cmake_make_flags="${cmake_original_make_flags}"
759 for a in ${cmake_make_processors}; do
760 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
761 cmake_make_processor="${a}"
763 done
766 cd "${cmake_bootstrap_dir}"
767 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
769 if [ -z "${cmake_make_processor}" ]; then
770 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
771 Please specify one using environment variable MAKE."
773 echo "Makefile processor on this system is: ${cmake_make_processor}"
774 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
775 echo "---------------------------------------------"
776 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
777 echo "---------------------------------------------"
780 # Ok, we have CC, CXX, and MAKE.
782 # Test C++ compiler features
784 # Are we GCC?
786 TMPFILE=`cmake_tmp_file`
787 cat > ${TMPFILE}.cxx <<EOF
788 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
789 #include <iostream>
790 int main() { std::cout << "This is GNU" << std::endl; return 0;}
791 #endif
793 cmake_cxx_compiler_is_gnu=0
794 if cmake_try_run "${cmake_cxx_compiler}" \
795 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
796 cmake_cxx_compiler_is_gnu=1
798 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
799 echo "${cmake_cxx_compiler} is GNU compiler"
800 else
801 echo "${cmake_cxx_compiler} is not GNU compiler"
803 rm -f "${TMPFILE}.cxx"
805 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
806 # Check for non-GNU compiler flags
808 # If we are on IRIX, check for -LANG:std
809 cmake_test_flags="-LANG:std"
810 if [ "x${cmake_system}" = "xIRIX64" ]; then
811 TMPFILE=`cmake_tmp_file`
812 cat > ${TMPFILE}.cxx <<EOF
813 #include <iostream>
814 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
816 cmake_need_lang_std=0
817 if cmake_try_run "${cmake_cxx_compiler}" \
818 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
820 else
821 if cmake_try_run "${cmake_cxx_compiler}" \
822 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
823 cmake_need_lang_std=1
826 if [ "x${cmake_need_lang_std}" = "x1" ]; then
827 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
828 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
829 else
830 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
832 rm -f "${TMPFILE}.cxx"
834 cmake_test_flags=
836 # If we are on OSF, check for -timplicit_local -no_implicit_include
837 cmake_test_flags="-timplicit_local -no_implicit_include"
838 if [ "x${cmake_system}" = "xOSF1" ]; then
839 TMPFILE=`cmake_tmp_file`
840 cat > ${TMPFILE}.cxx <<EOF
841 #include <iostream>
842 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
844 cmake_need_flags=1
845 if cmake_try_run "${cmake_cxx_compiler}" \
846 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
848 else
849 cmake_need_flags=0
851 if [ "x${cmake_need_flags}" = "x1" ]; then
852 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
853 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
854 else
855 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
857 rm -f "${TMPFILE}.cxx"
859 cmake_test_flags=
861 # If we are on OSF, check for -std strict_ansi -nopure_cname
862 cmake_test_flags="-std strict_ansi -nopure_cname"
863 if [ "x${cmake_system}" = "xOSF1" ]; then
864 TMPFILE=`cmake_tmp_file`
865 cat > ${TMPFILE}.cxx <<EOF
866 #include <iostream>
867 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
869 cmake_need_flags=1
870 if cmake_try_run "${cmake_cxx_compiler}" \
871 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
873 else
874 cmake_need_flags=0
876 if [ "x${cmake_need_flags}" = "x1" ]; then
877 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
878 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
879 else
880 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
882 rm -f "${TMPFILE}.cxx"
884 cmake_test_flags=
886 # If we are on HP-UX, check for -Ae for the C compiler.
887 cmake_test_flags="-Ae"
888 if [ "x${cmake_system}" = "xHP-UX" ]; then
889 TMPFILE=`cmake_tmp_file`
890 cat > ${TMPFILE}.c <<EOF
891 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
893 cmake_need_Ae=0
894 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
896 else
897 if cmake_try_run "${cmake_c_compiler}" \
898 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
899 cmake_need_Ae=1
902 if [ "x${cmake_need_Ae}" = "x1" ]; then
903 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
904 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
905 else
906 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
908 rm -f "${TMPFILE}.c"
910 cmake_test_flags=
913 # Test for kwsys features
914 KWSYS_NAME_IS_KWSYS=0
915 KWSYS_BUILD_SHARED=0
916 KWSYS_LFS_AVAILABLE=0
917 KWSYS_LFS_REQUESTED=0
918 KWSYS_IOS_USE_STRSTREAM_H=0
919 KWSYS_IOS_USE_STRSTREA_H=0
920 KWSYS_IOS_HAVE_STD=0
921 KWSYS_IOS_USE_SSTREAM=0
922 KWSYS_IOS_USE_ANSI=0
923 KWSYS_STL_HAVE_STD=0
924 KWSYS_STAT_HAS_ST_MTIM=0
925 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
926 KWSYS_STL_HAS_ITERATOR_TRAITS=0
927 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
928 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
929 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
930 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
931 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
932 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
933 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
934 KWSYS_CXX_HAS_CSTDDEF=0
935 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
936 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
937 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
938 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
940 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
941 KWSYS_STL_STRING_HAVE_ISTREAM=1
942 KWSYS_STL_STRING_HAVE_OSTREAM=1
944 if cmake_try_run "${cmake_cxx_compiler}" \
945 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
946 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
947 KWSYS_STL_HAVE_STD=1
948 echo "${cmake_cxx_compiler} has STL in std:: namespace"
949 else
950 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
953 if cmake_try_run "${cmake_cxx_compiler}" \
954 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
955 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
956 KWSYS_IOS_USE_ANSI=1
957 echo "${cmake_cxx_compiler} has ANSI streams"
958 else
959 echo "${cmake_cxx_compiler} does not have ANSI streams"
962 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
963 if cmake_try_run "${cmake_cxx_compiler}" \
964 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
965 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
966 KWSYS_IOS_HAVE_STD=1
967 echo "${cmake_cxx_compiler} has streams in std:: namespace"
968 else
969 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
971 if cmake_try_run "${cmake_cxx_compiler}" \
972 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
973 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
974 KWSYS_IOS_USE_SSTREAM=1
975 echo "${cmake_cxx_compiler} has sstream"
976 else
977 echo "${cmake_cxx_compiler} does not have sstream"
981 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
982 if cmake_try_run "${cmake_cxx_compiler}" \
983 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
984 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
985 KWSYS_IOS_USE_STRSTREAM_H=1
986 echo "${cmake_cxx_compiler} has strstream.h"
987 else
988 echo "${cmake_cxx_compiler} does not have strstream.h"
990 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
991 if cmake_try_run "${cmake_cxx_compiler}" \
992 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
993 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
994 KWSYS_IOS_USE_STRSTREA_H=1
995 echo "${cmake_cxx_compiler} has strstrea.h"
996 else
997 echo "${cmake_cxx_compiler} does not have strstrea.h"
1002 if cmake_try_run "${cmake_cxx_compiler}" \
1003 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1004 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1005 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1006 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1007 else
1008 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1011 if cmake_try_run "${cmake_cxx_compiler}" \
1012 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1013 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1014 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1015 echo "${cmake_cxx_compiler} has stl iterator_traits"
1016 else
1017 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1020 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1021 if cmake_try_run "${cmake_cxx_compiler}" \
1022 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1023 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1024 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1025 echo "${cmake_cxx_compiler} has old iterator_category"
1026 else
1027 echo "${cmake_cxx_compiler} does not have old iterator_category"
1029 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1030 if cmake_try_run "${cmake_cxx_compiler}" \
1031 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1032 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1033 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1034 echo "${cmake_cxx_compiler} has old __iterator_category"
1035 else
1036 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1041 if cmake_try_run "${cmake_cxx_compiler}" \
1042 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1043 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1044 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1045 echo "${cmake_cxx_compiler} has standard template allocator"
1046 else
1047 echo "${cmake_cxx_compiler} does not have standard template allocator"
1050 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1051 if cmake_try_run "${cmake_cxx_compiler}" \
1052 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1053 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1054 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1055 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1056 else
1057 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1060 if cmake_try_run "${cmake_cxx_compiler}" \
1061 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1062 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1063 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1064 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1065 else
1066 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1068 else
1069 if cmake_try_run "${cmake_cxx_compiler}" \
1070 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1071 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1072 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1073 echo "${cmake_cxx_compiler} has old non-template allocator"
1074 else
1075 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1079 if cmake_try_run "${cmake_cxx_compiler}" \
1080 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1081 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1082 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1083 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1084 else
1085 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1088 if cmake_try_run "${cmake_cxx_compiler}" \
1089 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1090 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1091 KWSYS_CXX_HAS_CSTDDEF=1
1092 echo "${cmake_cxx_compiler} has header cstddef"
1093 else
1094 echo "${cmake_cxx_compiler} does not have header cstddef"
1097 if cmake_try_run "${cmake_cxx_compiler}" \
1098 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1099 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1100 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1101 else
1102 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1103 echo "${cmake_cxx_compiler} requires template friends to use <>"
1106 if cmake_try_run "${cmake_cxx_compiler}" \
1107 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1108 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1109 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1110 echo "${cmake_cxx_compiler} supports member templates"
1111 else
1112 echo "${cmake_cxx_compiler} does not support member templates"
1115 if cmake_try_run "${cmake_cxx_compiler}" \
1116 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1117 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1118 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1119 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1120 else
1121 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1124 if cmake_try_run "${cmake_cxx_compiler}" \
1125 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1126 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1127 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1128 echo "${cmake_cxx_compiler} has argument dependent lookup"
1129 else
1130 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1133 if cmake_try_run "${cmake_cxx_compiler}" \
1134 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1135 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1136 KWSYS_STAT_HAS_ST_MTIM=1
1137 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1138 else
1139 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1142 # Just to be safe, let us store compiler and flags to the header file
1144 cmake_bootstrap_version='$Revision: 1.114 $'
1145 cmake_compiler_settings_comment="/*
1146 * Generated by ${cmake_source_dir}/bootstrap
1147 * Version: ${cmake_bootstrap_version}
1149 * Source directory: ${cmake_source_dir}
1150 * Binary directory: ${cmake_bootstrap_dir}
1152 * C compiler: ${cmake_c_compiler}
1153 * C flags: ${cmake_c_flags}
1155 * C++ compiler: ${cmake_cxx_compiler}
1156 * C++ flags: ${cmake_cxx_flags}
1158 * Make: ${cmake_make_processor}
1160 * Sources:
1161 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1162 * kwSys Sources:
1163 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1167 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1169 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1170 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1171 else
1172 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1175 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1176 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1177 else
1178 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1181 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1182 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1183 else
1184 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1187 # Test for ansi FOR scope
1188 if cmake_try_run "${cmake_cxx_compiler}" \
1189 "${cmake_cxx_flags}" \
1190 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1191 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1192 echo "${cmake_cxx_compiler} has ANSI for scoping"
1193 else
1194 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1195 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1198 # When bootstrapping on MinGW with MSYS we must convert the source
1199 # directory to a windows path.
1200 if ${cmake_system_mingw}; then
1201 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1202 else
1203 cmake_root_dir="${cmake_source_dir}"
1206 # Write CMake version
1207 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1208 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1209 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1210 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1211 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1212 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1214 # Regenerate real cmConfigure.h
1215 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1216 rm -f cmConfigure.h.tmp
1217 else
1218 mv -f cmConfigure.h.tmp cmConfigure.h
1221 # Prepare KWSYS
1222 cmake_kwsys_config_replace_string \
1223 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1224 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1225 "${cmake_compiler_settings_comment}"
1226 cmake_kwsys_config_replace_string \
1227 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1228 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1229 "${cmake_compiler_settings_comment}"
1231 cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
1232 /* Minimal DateStamp header for CMake bootstrap build. */
1233 #ifndef cmsys_DateStamp_h
1234 #define cmsys_DateStamp_h
1235 #define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
1236 #endif
1239 for a in ${KWSYS_FILES}; do
1240 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1241 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1242 done
1244 for a in ${KWSYS_IOS_FILES}; do
1245 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1246 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1247 done
1249 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1250 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1252 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1253 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1255 for a in string vector map algorithm; do
1256 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1257 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1258 done
1260 # Generate Makefile
1261 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1262 objs=""
1263 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1264 objs="${objs} ${a}.o"
1265 done
1267 # Generate dependencies for cmBootstrapCommands.cxx
1268 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1269 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1270 done
1271 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1273 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1274 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1277 if [ "x${cmake_c_flags}" != "x" ]; then
1278 cmake_c_flags="${cmake_c_flags} "
1281 if [ "x${cmake_cxx_flags}" != "x" ]; then
1282 cmake_cxx_flags="${cmake_cxx_flags} "
1285 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1286 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1287 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1288 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1289 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1290 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1291 for a in ${CMAKE_CXX_SOURCES}; do
1292 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1293 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1294 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1295 done
1296 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1297 for a in ${CMAKE_C_SOURCES}; do
1298 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1299 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1300 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1301 done
1302 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1303 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1304 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1305 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1306 done
1307 for a in ${KWSYS_CXX_SOURCES}; do
1308 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1309 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1310 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1311 done
1312 if ${cmake_system_mingw}; then
1313 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1314 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1315 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1316 a="cmsysProcessFwd9xEnc"
1317 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1318 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1319 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1320 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1321 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1322 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1323 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1324 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"
1326 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1327 rebuild_cache:
1328 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1331 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1332 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1333 # Generated by ${cmake_source_dir}/bootstrap
1334 # Default cmake settings. These may be overridden any settings below.
1335 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1336 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1337 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1338 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1341 # Add configuration settings given as command-line options.
1342 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1343 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1344 SET (BUILD_QtDialog ${cmake_bootstrap_qt_gui} CACHE BOOL "Build Qt dialog for CMake" FORCE)
1347 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1348 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1349 SET (QT_QMAKE_EXECUTABLE "${cmake_bootstrap_qt_qmake}" CACHE FILEPATH "Location of Qt qmake" FORCE)
1353 # Add user-specified settings. Handle relative-path case for
1354 # specification of cmake_init_file.
1356 cd "${cmake_binary_dir}"
1357 if [ -f "${cmake_init_file}" ]; then
1358 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1362 echo "---------------------------------------------"
1364 # Run make to build bootstrap cmake
1365 if [ "x${cmake_parallel_make}" != "x" ]; then
1366 ${cmake_make_processor} ${cmake_make_flags}
1367 else
1368 ${cmake_make_processor}
1370 RES=$?
1371 if [ "${RES}" -ne "0" ]; then
1372 cmake_error 9 "Problem while running ${cmake_make_processor}"
1374 cd "${cmake_binary_dir}"
1376 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1377 # build with same compiler and make
1378 CC="${cmake_c_compiler}"
1379 CXX="${cmake_cxx_compiler}"
1380 MAKE="${cmake_make_processor}"
1381 export CC
1382 export CXX
1383 export MAKE
1385 # Run bootstrap CMake to configure real CMake
1386 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1387 RES=$?
1388 if [ "${RES}" -ne "0" ]; then
1389 cmake_error 11 "Problem while running initial CMake"
1392 echo "---------------------------------------------"
1394 # And we are done. Now just run make
1395 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."