ENH: fix advanced bug
[cmake.git] / bootstrap
blob5089e3c45f7b3c110c42fd31650dc46067010e49
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2008-02-13 19:47:03 $
9 # Version: $Revision: 1.109 $
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 # Choose the generator to use for bootstrapping.
77 if ${cmake_system_mingw}; then
78 # Bootstrapping from an MSYS prompt.
79 cmake_bootstrap_generator="MSYS Makefiles"
80 else
81 # Bootstrapping from a standard UNIX prompt.
82 cmake_bootstrap_generator="Unix Makefiles"
85 # Helper function to fix windows paths.
86 cmake_fix_slashes ()
88 echo "$1" | sed 's/\\/\//g'
91 # Choose the default install prefix.
92 if ${cmake_system_mingw}; then
93 if [ "x${PROGRAMFILES}" != "x" ]; then
94 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
95 elif [ "x${ProgramFiles}" != "x" ]; then
96 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
97 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
98 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
99 elif [ "x${SystemDrive}" != "x" ]; then
100 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
101 else
102 cmake_default_prefix="c:/Program Files/CMake"
104 else
105 cmake_default_prefix="/usr/local"
108 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
109 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
110 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
112 CMAKE_PROBLEMATIC_FILES="\
113 CMakeCache.txt \
114 CMakeSystem.cmake \
115 CMakeCCompiler.cmake \
116 CMakeCXXCompiler.cmake \
117 Source/cmConfigure.h \
118 Source/CTest/Curl/config.h \
119 Utilities/cmexpat/expatConfig.h \
120 Utilities/cmexpat/expatDllConfig.h \
123 CMAKE_UNUSED_SOURCES="\
124 cmGlobalXCodeGenerator \
125 cmLocalXCodeGenerator \
126 cmXCodeObject \
127 cmXCode21Object \
128 cmSourceGroup \
131 CMAKE_CXX_SOURCES="\
132 cmake \
133 cmakemain \
134 cmakewizard \
135 cmCommandArgumentLexer \
136 cmCommandArgumentParser \
137 cmCommandArgumentParserHelper \
138 cmDepends \
139 cmDependsC \
140 cmProperty \
141 cmPropertyMap \
142 cmPropertyDefinition \
143 cmPropertyDefinitionMap \
144 cmMakeDepend \
145 cmMakefile \
146 cmGeneratedFileStream \
147 cmGlobalGenerator \
148 cmLocalGenerator \
149 cmInstallGenerator \
150 cmInstallFilesGenerator \
151 cmInstallScriptGenerator \
152 cmInstallTargetGenerator \
153 cmSourceFile \
154 cmSourceFileLocation \
155 cmSystemTools \
156 cmVersion \
157 cmFileTimeComparison \
158 cmGlobalUnixMakefileGenerator3 \
159 cmLocalUnixMakefileGenerator3 \
160 cmMakefileExecutableTargetGenerator \
161 cmMakefileLibraryTargetGenerator \
162 cmMakefileTargetGenerator \
163 cmMakefileUtilityTargetGenerator \
164 cmBootstrapCommands \
165 cmCommands \
166 cmTarget \
167 cmTest \
168 cmCustomCommand \
169 cmDocumentVariables \
170 cmCacheManager \
171 cmListFileCache \
172 cmComputeLinkDepends \
173 cmComputeLinkInformation \
174 cmOrderRuntimeDirectories \
175 cmComputeTargetDepends \
176 cmComputeComponentGraph \
177 cmExprLexer \
178 cmExprParser \
179 cmExprParserHelper \
182 if ${cmake_system_mingw}; then
183 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
184 cmGlobalMSYSMakefileGenerator \
185 cmGlobalMinGWMakefileGenerator \
186 cmWin32ProcessExecution"
189 CMAKE_C_SOURCES="\
190 cmListFileLexer \
193 if ${cmake_system_mingw}; then
194 KWSYS_C_SOURCES="\
195 ProcessWin32 \
196 String \
197 System"
198 KWSYS_C_MINGW_SOURCES="\
199 ProcessFwd9x \
200 EncodeExecutable"
201 KWSYS_C_GENERATED_SOURCES="\
202 cmsysProcessFwd9xEnc"
203 else
204 KWSYS_C_SOURCES="\
205 ProcessUNIX \
206 String \
207 System"
208 KWSYS_C_MINGW_SOURCES=""
209 KWSYS_C_GENERATED_SOURCES=""
212 KWSYS_CXX_SOURCES="\
213 Directory \
214 Glob \
215 RegularExpression \
216 SystemTools"
218 KWSYS_FILES="\
219 auto_ptr.hxx \
220 Directory.hxx \
221 Glob.hxx \
222 Process.h \
223 RegularExpression.hxx \
224 String.h \
225 String.hxx \
226 System.h \
227 SystemTools.hxx"
229 KWSYS_IOS_FILES="
230 fstream \
231 iosfwd \
232 iostream \
233 sstream"
235 # Display CMake bootstrap usage
236 cmake_usage()
238 cat <<EOF
239 Usage: $0 [options]
240 Options: [defaults in brackets after descriptions]
241 Configuration:
242 --help print this message
243 --version only print version information
244 --verbose display more information
245 --parallel=n bootstrap cmake in parallel, where n is
246 number of nodes [1]
247 --init=FILE use FILE for cmake initialization
248 --system-libs use system-installed third-party libraries
249 (for use only by package maintainers)
250 --no-system-libs use cmake-provided third-party libraries
251 (default)
252 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
253 --no-qt-gui do not build the Qt-based GUI (default)
254 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
256 Directory and file names:
257 --prefix=PREFIX install files in tree rooted at PREFIX
258 [${cmake_default_prefix}]
259 --datadir=DIR install data files in PREFIX/DIR
260 [/share/CMake]
261 --docdir=DIR install documentation files in PREFIX/DIR
262 [/doc/CMake]
263 --mandir=DIR install man pages files in PREFIX/DIR/manN
264 [/man]
266 exit 10
269 # Display CMake bootstrap usage
270 cmake_version_display()
273 # Get CMake version
274 if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
275 version="${cmake_version}-${cmake_date_stamp}"
276 else
277 version="${cmake_version}-${cmake_version_patch}"
279 echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
283 # Display CMake bootstrap error, display the log file and exit
284 cmake_error()
286 res=$1
287 shift 1
288 echo "---------------------------------------------"
289 echo "Error when bootstrapping CMake:"
290 echo "$*"
291 echo "---------------------------------------------"
292 if [ -f cmake_bootstrap.log ]; then
293 echo "Log of errors: `pwd`/cmake_bootstrap.log"
294 #cat cmake_bootstrap.log
295 echo "---------------------------------------------"
297 exit ${res}
300 # Replace KWSYS_NAMESPACE with cmsys
301 cmake_replace_string ()
303 INFILE="$1"
304 OUTFILE="$2"
305 SEARCHFOR="$3"
306 REPLACEWITH="$4"
307 if [ -f "${INFILE}" ]; then
308 cat "${INFILE}" |
309 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
310 if [ -f "${OUTFILE}.tmp" ]; then
311 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
312 #echo "Files are the same"
313 rm -f "${OUTFILE}.tmp"
314 else
315 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
318 else
319 cmake_error 1 "Cannot find file ${INFILE}"
323 cmake_kwsys_config_replace_string ()
325 INFILE="$1"
326 OUTFILE="$2"
327 shift 2
328 APPEND="$*"
329 if [ -f "${INFILE}" ]; then
330 echo "${APPEND}" > "${OUTFILE}.tmp"
331 cat "${INFILE}" |
332 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
333 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
334 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
335 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
336 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
337 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
338 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
339 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
340 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
341 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
342 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
343 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
344 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
345 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
346 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
347 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
348 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
349 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
350 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
351 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
352 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
353 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
354 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
355 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
356 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
357 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
358 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
359 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
360 if [ -f "${OUTFILE}.tmp" ]; then
361 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
362 #echo "Files are the same"
363 rm -f "${OUTFILE}.tmp"
364 else
365 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
368 else
369 cmake_error 2 "Cannot find file ${INFILE}"
372 # Write string into a file
373 cmake_report ()
375 FILE=$1
376 shift
377 echo "$*" >> ${FILE}
380 # Escape spaces in strings
381 cmake_escape ()
383 echo $1 | sed "s/ /\\\\ /g"
386 # Write message to the log
387 cmake_log ()
389 echo "$*" >> cmake_bootstrap.log
392 # Return temp file
393 cmake_tmp_file ()
395 echo "cmake_bootstrap_$$.test"
398 # Run a compiler test. First argument is compiler, second one are compiler
399 # flags, third one is test source file to be compiled
400 cmake_try_run ()
402 COMPILER=$1
403 FLAGS=$2
404 TESTFILE=$3
405 if [ ! -f "${TESTFILE}" ]; then
406 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
407 exit 4
409 TMPFILE=`cmake_tmp_file`
410 echo "Try: ${COMPILER}"
411 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
412 echo "---------- file -----------------------"
413 cat "${TESTFILE}"
414 echo "------------------------------------------"
415 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
416 RES=$?
417 if [ "${RES}" -ne "0" ]; then
418 echo "Test failed to compile"
419 return 1
421 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
422 echo "Test failed to produce executable"
423 return 2
425 ./${TMPFILE}
426 RES=$?
427 rm -f "${TMPFILE}"
428 if [ "${RES}" -ne "0" ]; then
429 echo "Test produced non-zero return code"
430 return 3
432 echo "Test succeded"
433 return 0
436 # Run a make test. First argument is the make interpreter.
437 cmake_try_make ()
439 MAKE_PROC="$1"
440 MAKE_FLAGS="$2"
441 echo "Try: ${MAKE_PROC}"
442 "${MAKE_PROC}" ${MAKE_FLAGS}
443 RES=$?
444 if [ "${RES}" -ne "0" ]; then
445 echo "${MAKE_PROC} does not work"
446 return 1
448 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
449 echo "${COMPILER} does not produce output"
450 return 2
452 ./test
453 RES=$?
454 rm -f "test"
455 if [ "${RES}" -ne "0" ]; then
456 echo "${MAKE_PROC} produces strange executable"
457 return 3
459 echo "${MAKE_PROC} works"
460 return 0
463 # Parse arguments
464 cmake_verbose=
465 cmake_parallel_make=
466 cmake_prefix_dir="${cmake_default_prefix}"
467 for a in "$@"; do
468 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
469 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
470 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
472 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
473 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
475 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
476 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
478 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
479 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
481 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
482 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
484 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
485 cmake_init_file=`echo $a | sed "s/^--init=//"`
487 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
488 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
490 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
491 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
493 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
494 cmake_bootstrap_qt_gui="1"
496 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
497 cmake_bootstrap_qt_gui="0"
499 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
500 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
502 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
503 cmake_usage
505 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
506 cmake_version_display
507 exit 2
509 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
510 cmake_verbose=TRUE
512 done
514 # If verbose, display some information about bootstrap
515 if [ -n "${cmake_verbose}" ]; then
516 echo "---------------------------------------------"
517 echo "Source directory: ${cmake_source_dir}"
518 echo "Binary directory: ${cmake_binary_dir}"
519 echo "Prefix directory: ${cmake_prefix_dir}"
520 echo "System: ${cmake_system}"
521 if [ "x${cmake_parallel_make}" != "x" ]; then
522 echo "Doing parallel make: ${cmake_parallel_make}"
524 echo ""
527 echo "---------------------------------------------"
528 # Get CMake version
529 echo "`cmake_version_display`"
531 # Check for in-source build
532 cmake_in_source_build=
533 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
534 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
535 if [ -n "${cmake_verbose}" ]; then
536 echo "Warning: This is an in-source build"
538 cmake_in_source_build=TRUE
541 # If this is not an in-source build, then Bootstrap stuff should not exist.
542 if [ -z "${cmake_in_source_build}" ]; then
543 # Did somebody bootstrap in the source tree?
544 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
545 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
546 Looks like somebody did bootstrap CMake in the source tree, but now you are
547 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
548 directory from the source tree."
550 # Is there a cache in the source tree?
551 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
552 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
553 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
554 Looks like somebody tried to build CMake in the source tree, but now you are
555 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
556 from the source tree."
558 done
561 # Make bootstrap directory
562 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
563 if [ ! -d "${cmake_bootstrap_dir}" ]; then
564 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
566 cd "${cmake_bootstrap_dir}"
568 [ -d "cmsys" ] || mkdir "cmsys"
569 if [ ! -d "cmsys" ]; then
570 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
573 for a in stl ios; do
574 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
575 if [ ! -d "cmsys/${a}" ]; then
576 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
578 done
580 # Delete all the bootstrap files
581 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
582 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
584 # If exist compiler flags, set them
585 cmake_c_flags=${CFLAGS}
586 cmake_cxx_flags=${CXXFLAGS}
587 cmake_ld_flags=${LDFLAGS}
589 # Add Carbon framework on Darwin
590 if ${cmake_system_darwin}; then
591 cmake_ld_flags="${LDFLAGS} -framework Carbon"
594 # Add BeOS toolkits...
595 if ${cmake_system_beos}; then
596 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
599 # Test C compiler
600 cmake_c_compiler=
602 # If CC is set, use that for compiler, otherwise use list of known compilers
603 if [ -n "${CC}" ]; then
604 cmake_c_compilers="${CC}"
605 else
606 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
609 # Check if C compiler works
610 TMPFILE=`cmake_tmp_file`
611 cat > "${TMPFILE}.c" <<EOF
612 #ifdef __cplusplus
613 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
614 #endif
616 #include<stdio.h>
618 #if defined(__CLASSIC_C__)
619 int main(argc, argv)
620 int argc;
621 char* argv[];
622 #else
623 int main(int argc, char* argv[])
624 #endif
626 printf("%d\n", (argv != 0));
627 return argc-1;
630 for a in ${cmake_c_compilers}; do
631 if [ -z "${cmake_c_compiler}" ] && \
632 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
633 cmake_c_compiler="${a}"
635 done
636 rm -f "${TMPFILE}.c"
638 if [ -z "${cmake_c_compiler}" ]; then
639 cmake_error 6 "Cannot find appropriate C compiler on this system.
640 Please specify one using environment variable CC.
641 See cmake_bootstrap.log for compilers attempted.
644 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
646 # Test CXX compiler
647 cmake_cxx_compiler=
649 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
651 # If CC is set, use that for compiler, otherwise use list of known compilers
652 if [ -n "${CXX}" ]; then
653 cmake_cxx_compilers="${CXX}"
654 else
655 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
658 # Check if C++ compiler works
659 TMPFILE=`cmake_tmp_file`
660 cat > "${TMPFILE}.cxx" <<EOF
661 #if defined(TEST1)
662 # include <iostream>
663 #else
664 # include <iostream.h>
665 #endif
667 class NeedCXX
669 public:
670 NeedCXX() { this->Foo = 1; }
671 int GetFoo() { return this->Foo; }
672 private:
673 int Foo;
675 int main()
677 NeedCXX c;
678 #ifdef TEST3
679 cout << c.GetFoo() << endl;
680 #else
681 std::cout << c.GetFoo() << std::endl;
682 #endif
683 return 0;
686 for a in ${cmake_cxx_compilers}; do
687 for b in 1 2 3; do
688 if [ -z "${cmake_cxx_compiler}" ] && \
689 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
690 cmake_cxx_compiler="${a}"
692 done
693 done
694 rm -f "${TMPFILE}.cxx"
696 if [ -z "${cmake_cxx_compiler}" ]; then
697 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
698 Please specify one using environment variable CXX.
699 See cmake_bootstrap.log for compilers attempted."
701 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
703 # Test Make
705 cmake_make_processor=
706 cmake_make_flags=
708 # If MAKE is set, use that for make processor, otherwise use list of known make
709 if [ -n "${MAKE}" ]; then
710 cmake_make_processors="${MAKE}"
711 else
712 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
715 TMPFILE="`cmake_tmp_file`_dir"
716 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
717 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
718 cd "${cmake_bootstrap_dir}/${TMPFILE}"
719 cat>"Makefile"<<EOF
720 test: test.c
721 "${cmake_c_compiler}" -o test test.c
723 cat>"test.c"<<EOF
724 #include <stdio.h>
725 int main(){ printf("1\n"); return 0; }
727 cmake_original_make_flags="${cmake_make_flags}"
728 if [ "x${cmake_parallel_make}" != "x" ]; then
729 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
731 for a in ${cmake_make_processors}; do
732 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
733 cmake_make_processor="${a}"
735 done
736 cmake_full_make_flags="${cmake_make_flags}"
737 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
738 if [ -z "${cmake_make_processor}" ]; then
739 cmake_make_flags="${cmake_original_make_flags}"
740 for a in ${cmake_make_processors}; do
741 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
742 cmake_make_processor="${a}"
744 done
747 cd "${cmake_bootstrap_dir}"
748 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
750 if [ -z "${cmake_make_processor}" ]; then
751 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
752 Please specify one using environment variable MAKE."
754 echo "Makefile processor on this system is: ${cmake_make_processor}"
755 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
756 echo "---------------------------------------------"
757 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
758 echo "---------------------------------------------"
761 # Ok, we have CC, CXX, and MAKE.
763 # Test C++ compiler features
765 # Are we GCC?
767 TMPFILE=`cmake_tmp_file`
768 cat > ${TMPFILE}.cxx <<EOF
769 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
770 #include <iostream>
771 int main() { std::cout << "This is GNU" << std::endl; return 0;}
772 #endif
774 cmake_cxx_compiler_is_gnu=0
775 if cmake_try_run "${cmake_cxx_compiler}" \
776 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
777 cmake_cxx_compiler_is_gnu=1
779 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
780 echo "${cmake_cxx_compiler} is GNU compiler"
781 else
782 echo "${cmake_cxx_compiler} is not GNU compiler"
784 rm -f "${TMPFILE}.cxx"
786 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
787 # Check for non-GNU compiler flags
789 # If we are on IRIX, check for -LANG:std
790 cmake_test_flags="-LANG:std"
791 if [ "x${cmake_system}" = "xIRIX64" ]; then
792 TMPFILE=`cmake_tmp_file`
793 cat > ${TMPFILE}.cxx <<EOF
794 #include <iostream>
795 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
797 cmake_need_lang_std=0
798 if cmake_try_run "${cmake_cxx_compiler}" \
799 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
801 else
802 if cmake_try_run "${cmake_cxx_compiler}" \
803 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
804 cmake_need_lang_std=1
807 if [ "x${cmake_need_lang_std}" = "x1" ]; then
808 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
809 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
810 else
811 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
813 rm -f "${TMPFILE}.cxx"
815 cmake_test_flags=
817 # If we are on OSF, check for -timplicit_local -no_implicit_include
818 cmake_test_flags="-timplicit_local -no_implicit_include"
819 if [ "x${cmake_system}" = "xOSF1" ]; then
820 TMPFILE=`cmake_tmp_file`
821 cat > ${TMPFILE}.cxx <<EOF
822 #include <iostream>
823 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
825 cmake_need_flags=1
826 if cmake_try_run "${cmake_cxx_compiler}" \
827 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
829 else
830 cmake_need_flags=0
832 if [ "x${cmake_need_flags}" = "x1" ]; then
833 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
834 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
835 else
836 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
838 rm -f "${TMPFILE}.cxx"
840 cmake_test_flags=
842 # If we are on OSF, check for -std strict_ansi -nopure_cname
843 cmake_test_flags="-std strict_ansi -nopure_cname"
844 if [ "x${cmake_system}" = "xOSF1" ]; then
845 TMPFILE=`cmake_tmp_file`
846 cat > ${TMPFILE}.cxx <<EOF
847 #include <iostream>
848 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
850 cmake_need_flags=1
851 if cmake_try_run "${cmake_cxx_compiler}" \
852 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
854 else
855 cmake_need_flags=0
857 if [ "x${cmake_need_flags}" = "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 HP-UX, check for -Ae for the C compiler.
868 cmake_test_flags="-Ae"
869 if [ "x${cmake_system}" = "xHP-UX" ]; then
870 TMPFILE=`cmake_tmp_file`
871 cat > ${TMPFILE}.c <<EOF
872 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
874 cmake_need_Ae=0
875 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
877 else
878 if cmake_try_run "${cmake_c_compiler}" \
879 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
880 cmake_need_Ae=1
883 if [ "x${cmake_need_Ae}" = "x1" ]; then
884 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
885 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
886 else
887 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
889 rm -f "${TMPFILE}.c"
891 cmake_test_flags=
894 # Test for kwsys features
895 KWSYS_NAME_IS_KWSYS=0
896 KWSYS_BUILD_SHARED=0
897 KWSYS_LFS_AVAILABLE=0
898 KWSYS_LFS_REQUESTED=0
899 KWSYS_IOS_USE_STRSTREAM_H=0
900 KWSYS_IOS_USE_STRSTREA_H=0
901 KWSYS_IOS_HAVE_STD=0
902 KWSYS_IOS_USE_SSTREAM=0
903 KWSYS_IOS_USE_ANSI=0
904 KWSYS_STL_HAVE_STD=0
905 KWSYS_STAT_HAS_ST_MTIM=0
906 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
907 KWSYS_STL_HAS_ITERATOR_TRAITS=0
908 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
909 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
910 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
911 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
912 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
913 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
914 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
915 KWSYS_CXX_HAS_CSTDDEF=0
916 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
917 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
918 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
919 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
921 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
922 KWSYS_STL_STRING_HAVE_ISTREAM=1
923 KWSYS_STL_STRING_HAVE_OSTREAM=1
925 if cmake_try_run "${cmake_cxx_compiler}" \
926 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
927 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
928 KWSYS_STL_HAVE_STD=1
929 echo "${cmake_cxx_compiler} has STL in std:: namespace"
930 else
931 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
934 if cmake_try_run "${cmake_cxx_compiler}" \
935 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
936 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
937 KWSYS_IOS_USE_ANSI=1
938 echo "${cmake_cxx_compiler} has ANSI streams"
939 else
940 echo "${cmake_cxx_compiler} does not have ANSI streams"
943 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
944 if cmake_try_run "${cmake_cxx_compiler}" \
945 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
946 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
947 KWSYS_IOS_HAVE_STD=1
948 echo "${cmake_cxx_compiler} has streams in std:: namespace"
949 else
950 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
952 if cmake_try_run "${cmake_cxx_compiler}" \
953 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
954 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
955 KWSYS_IOS_USE_SSTREAM=1
956 echo "${cmake_cxx_compiler} has sstream"
957 else
958 echo "${cmake_cxx_compiler} does not have sstream"
962 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
963 if cmake_try_run "${cmake_cxx_compiler}" \
964 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
965 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
966 KWSYS_IOS_USE_STRSTREAM_H=1
967 echo "${cmake_cxx_compiler} has strstream.h"
968 else
969 echo "${cmake_cxx_compiler} does not have strstream.h"
971 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
972 if cmake_try_run "${cmake_cxx_compiler}" \
973 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
974 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
975 KWSYS_IOS_USE_STRSTREA_H=1
976 echo "${cmake_cxx_compiler} has strstrea.h"
977 else
978 echo "${cmake_cxx_compiler} does not have strstrea.h"
983 if cmake_try_run "${cmake_cxx_compiler}" \
984 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
985 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
986 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
987 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
988 else
989 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
992 if cmake_try_run "${cmake_cxx_compiler}" \
993 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
994 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
995 KWSYS_STL_HAS_ITERATOR_TRAITS=1
996 echo "${cmake_cxx_compiler} has stl iterator_traits"
997 else
998 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1001 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1002 if cmake_try_run "${cmake_cxx_compiler}" \
1003 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -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_HAS_ITERATOR_CATEGORY=1
1006 echo "${cmake_cxx_compiler} has old iterator_category"
1007 else
1008 echo "${cmake_cxx_compiler} does not have old iterator_category"
1010 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1011 if cmake_try_run "${cmake_cxx_compiler}" \
1012 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -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_CATEGORY=1
1015 echo "${cmake_cxx_compiler} has old __iterator_category"
1016 else
1017 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1022 if cmake_try_run "${cmake_cxx_compiler}" \
1023 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1024 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1025 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1026 echo "${cmake_cxx_compiler} has standard template allocator"
1027 else
1028 echo "${cmake_cxx_compiler} does not have standard template allocator"
1031 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1032 if cmake_try_run "${cmake_cxx_compiler}" \
1033 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1034 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1035 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1036 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1037 else
1038 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1041 if cmake_try_run "${cmake_cxx_compiler}" \
1042 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -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_MAX_SIZE_ARGUMENT=1
1045 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1046 else
1047 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1049 else
1050 if cmake_try_run "${cmake_cxx_compiler}" \
1051 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1052 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1053 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1054 echo "${cmake_cxx_compiler} has old non-template allocator"
1055 else
1056 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1060 if cmake_try_run "${cmake_cxx_compiler}" \
1061 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -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_OBJECTS=1
1064 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1065 else
1066 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1069 if cmake_try_run "${cmake_cxx_compiler}" \
1070 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1071 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1072 KWSYS_CXX_HAS_CSTDDEF=1
1073 echo "${cmake_cxx_compiler} has header cstddef"
1074 else
1075 echo "${cmake_cxx_compiler} does not have header cstddef"
1078 if cmake_try_run "${cmake_cxx_compiler}" \
1079 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1080 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1081 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1082 else
1083 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1084 echo "${cmake_cxx_compiler} requires template friends to use <>"
1087 if cmake_try_run "${cmake_cxx_compiler}" \
1088 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1089 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1090 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1091 echo "${cmake_cxx_compiler} supports member templates"
1092 else
1093 echo "${cmake_cxx_compiler} does not support member templates"
1096 if cmake_try_run "${cmake_cxx_compiler}" \
1097 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1098 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1099 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1100 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1101 else
1102 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1105 if cmake_try_run "${cmake_cxx_compiler}" \
1106 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1107 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1108 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1109 echo "${cmake_cxx_compiler} has argument dependent lookup"
1110 else
1111 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1114 if cmake_try_run "${cmake_cxx_compiler}" \
1115 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1116 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1117 KWSYS_STAT_HAS_ST_MTIM=1
1118 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1119 else
1120 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1123 # Just to be safe, let us store compiler and flags to the header file
1125 cmake_bootstrap_version='$Revision: 1.109 $'
1126 cmake_compiler_settings_comment="/*
1127 * Generated by ${cmake_source_dir}/bootstrap
1128 * Version: ${cmake_bootstrap_version}
1130 * Source directory: ${cmake_source_dir}
1131 * Binary directory: ${cmake_bootstrap_dir}
1133 * C compiler: ${cmake_c_compiler}
1134 * C flags: ${cmake_c_flags}
1136 * C++ compiler: ${cmake_cxx_compiler}
1137 * C++ flags: ${cmake_cxx_flags}
1139 * Make: ${cmake_make_processor}
1141 * Sources:
1142 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1143 * kwSys Sources:
1144 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1148 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1150 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1151 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1152 else
1153 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1156 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1157 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1158 else
1159 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1162 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1163 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1164 else
1165 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1168 # Test for ansi FOR scope
1169 if cmake_try_run "${cmake_cxx_compiler}" \
1170 "${cmake_cxx_flags}" \
1171 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1172 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1173 echo "${cmake_cxx_compiler} has ANSI for scoping"
1174 else
1175 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1176 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1179 # When bootstrapping on MinGW with MSYS we must convert the source
1180 # directory to a windows path.
1181 if ${cmake_system_mingw}; then
1182 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1183 else
1184 cmake_root_dir="${cmake_source_dir}"
1187 # Write CMake version
1188 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1189 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1190 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1191 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1192 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1193 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1195 # Regenerate real cmConfigure.h
1196 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1197 rm -f cmConfigure.h.tmp
1198 else
1199 mv -f cmConfigure.h.tmp cmConfigure.h
1202 # Prepare KWSYS
1203 cmake_kwsys_config_replace_string \
1204 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1205 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1206 "${cmake_compiler_settings_comment}"
1207 cmake_kwsys_config_replace_string \
1208 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1209 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1210 "${cmake_compiler_settings_comment}"
1212 cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
1213 /* Minimal DateStamp header for CMake bootstrap build. */
1214 #ifndef cmsys_DateStamp_h
1215 #define cmsys_DateStamp_h
1216 #define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
1217 #endif
1220 for a in ${KWSYS_FILES}; do
1221 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1222 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1223 done
1225 for a in ${KWSYS_IOS_FILES}; do
1226 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1227 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1228 done
1230 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1231 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1233 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1234 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1236 for a in string vector map algorithm; do
1237 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1238 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1239 done
1241 # Generate Makefile
1242 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1243 objs=""
1244 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1245 objs="${objs} ${a}.o"
1246 done
1248 # Generate dependencies for cmBootstrapCommands.cxx
1249 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1250 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1251 done
1252 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1254 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1255 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1258 if [ "x${cmake_c_flags}" != "x" ]; then
1259 cmake_c_flags="${cmake_c_flags} "
1262 if [ "x${cmake_cxx_flags}" != "x" ]; then
1263 cmake_cxx_flags="${cmake_cxx_flags} "
1266 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1267 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1268 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1269 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1270 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1271 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1272 for a in ${CMAKE_CXX_SOURCES}; do
1273 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1274 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1275 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1276 done
1277 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1278 for a in ${CMAKE_C_SOURCES}; do
1279 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1280 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1281 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1282 done
1283 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1284 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1285 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1286 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1287 done
1288 for a in ${KWSYS_CXX_SOURCES}; do
1289 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1290 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1291 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1292 done
1293 if ${cmake_system_mingw}; then
1294 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1295 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1296 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1297 a="cmsysProcessFwd9xEnc"
1298 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1299 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1300 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1301 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1302 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1303 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1304 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1305 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"
1307 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1308 rebuild_cache:
1309 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1312 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1313 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1314 # Generated by ${cmake_source_dir}/bootstrap
1315 # Default cmake settings. These may be overridden any settings below.
1316 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1317 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1318 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1319 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1322 # Add configuration settings given as command-line options.
1323 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1324 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1325 SET (BUILD_QtDialog ${cmake_bootstrap_qt_gui} CACHE BOOL "Build Qt dialog for CMake" FORCE)
1328 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1329 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1330 SET (QT_QMAKE_EXECUTABLE "${cmake_bootstrap_qt_qmake}" CACHE FILEPATH "Location of Qt qmake" FORCE)
1334 # Add user-specified settings. Handle relative-path case for
1335 # specification of cmake_init_file.
1337 cd "${cmake_binary_dir}"
1338 if [ -f "${cmake_init_file}" ]; then
1339 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1343 echo "---------------------------------------------"
1345 # Run make to build bootstrap cmake
1346 if [ "x${cmake_parallel_make}" != "x" ]; then
1347 ${cmake_make_processor} ${cmake_make_flags}
1348 else
1349 ${cmake_make_processor}
1351 RES=$?
1352 if [ "${RES}" -ne "0" ]; then
1353 cmake_error 9 "Problem while running ${cmake_make_processor}"
1355 cd "${cmake_binary_dir}"
1357 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1358 # build with same compiler and make
1359 CC="${cmake_c_compiler}"
1360 CXX="${cmake_cxx_compiler}"
1361 MAKE="${cmake_make_processor}"
1362 export CC
1363 export CXX
1364 export MAKE
1366 # Run bootstrap CMake to configure real CMake
1367 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1368 RES=$?
1369 if [ "${RES}" -ne "0" ]; then
1370 cmake_error 11 "Problem while running initial CMake"
1373 echo "---------------------------------------------"
1375 # And we are done. Now just run make
1376 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."