ENH: update for Tcl/Tk 8.5
[cmake.git] / bootstrap
blobd613539d2a5f69d4f6159a92a262f6cdcc8dfa5d
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2008-01-22 14:13:03 $
9 # Version: $Revision: 1.102 $
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=""
53 # Determine whether this is a MinGW environment.
54 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
55 cmake_system_mingw=true
56 else
57 cmake_system_mingw=false
60 # Determine whether this is OS X
61 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
62 cmake_system_darwin=true
63 else
64 cmake_system_darwin=false
67 # Determine whether this is BeOS
68 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
69 cmake_system_beos=true
70 else
71 cmake_system_beos=false
74 # Choose the generator to use for bootstrapping.
75 if ${cmake_system_mingw}; then
76 # Bootstrapping from an MSYS prompt.
77 cmake_bootstrap_generator="MSYS Makefiles"
78 else
79 # Bootstrapping from a standard UNIX prompt.
80 cmake_bootstrap_generator="Unix Makefiles"
83 # Helper function to fix windows paths.
84 cmake_fix_slashes ()
86 echo "$1" | sed 's/\\/\//g'
89 # Choose the default install prefix.
90 if ${cmake_system_mingw}; then
91 if [ "x${PROGRAMFILES}" != "x" ]; then
92 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
93 elif [ "x${ProgramFiles}" != "x" ]; then
94 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
95 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
96 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
97 elif [ "x${SystemDrive}" != "x" ]; then
98 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
99 else
100 cmake_default_prefix="c:/Program Files/CMake"
102 else
103 cmake_default_prefix="/usr/local"
106 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
107 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
108 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
110 CMAKE_PROBLEMATIC_FILES="\
111 CMakeCache.txt \
112 CMakeSystem.cmake \
113 CMakeCCompiler.cmake \
114 CMakeCXXCompiler.cmake \
115 Source/cmConfigure.h \
116 Source/CTest/Curl/config.h \
117 Utilities/cmexpat/expatConfig.h \
118 Utilities/cmexpat/expatDllConfig.h \
121 CMAKE_UNUSED_SOURCES="\
122 cmGlobalXCodeGenerator \
123 cmLocalXCodeGenerator \
124 cmXCodeObject \
125 cmXCode21Object \
126 cmSourceGroup \
129 CMAKE_CXX_SOURCES="\
130 cmake \
131 cmakemain \
132 cmakewizard \
133 cmCommandArgumentLexer \
134 cmCommandArgumentParser \
135 cmCommandArgumentParserHelper \
136 cmDepends \
137 cmDependsC \
138 cmProperty \
139 cmPropertyMap \
140 cmPropertyDefinition \
141 cmPropertyDefinitionMap \
142 cmMakeDepend \
143 cmMakefile \
144 cmGeneratedFileStream \
145 cmGlobalGenerator \
146 cmLocalGenerator \
147 cmInstallGenerator \
148 cmInstallFilesGenerator \
149 cmInstallScriptGenerator \
150 cmInstallTargetGenerator \
151 cmSourceFile \
152 cmSourceFileLocation \
153 cmSystemTools \
154 cmVersion \
155 cmFileTimeComparison \
156 cmGlobalUnixMakefileGenerator3 \
157 cmLocalUnixMakefileGenerator3 \
158 cmMakefileExecutableTargetGenerator \
159 cmMakefileLibraryTargetGenerator \
160 cmMakefileTargetGenerator \
161 cmMakefileUtilityTargetGenerator \
162 cmBootstrapCommands \
163 cmCommands \
164 cmTarget \
165 cmTest \
166 cmCustomCommand \
167 cmDocumentVariables \
168 cmCacheManager \
169 cmListFileCache \
170 cmComputeLinkInformation \
173 if ${cmake_system_mingw}; then
174 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
175 cmGlobalMSYSMakefileGenerator \
176 cmGlobalMinGWMakefileGenerator \
177 cmWin32ProcessExecution"
180 CMAKE_C_SOURCES="\
181 cmListFileLexer \
184 if ${cmake_system_mingw}; then
185 KWSYS_C_SOURCES="\
186 ProcessWin32 \
187 String \
188 System"
189 KWSYS_C_MINGW_SOURCES="\
190 ProcessFwd9x \
191 EncodeExecutable"
192 KWSYS_C_GENERATED_SOURCES="\
193 cmsysProcessFwd9xEnc"
194 else
195 KWSYS_C_SOURCES="\
196 ProcessUNIX \
197 String \
198 System"
199 KWSYS_C_MINGW_SOURCES=""
200 KWSYS_C_GENERATED_SOURCES=""
203 KWSYS_CXX_SOURCES="\
204 Directory \
205 Glob \
206 RegularExpression \
207 SystemTools"
209 KWSYS_FILES="\
210 auto_ptr.hxx \
211 Directory.hxx \
212 Glob.hxx \
213 Process.h \
214 RegularExpression.hxx \
215 String.h \
216 String.hxx \
217 System.h \
218 SystemTools.hxx"
220 KWSYS_IOS_FILES="
221 fstream \
222 iosfwd \
223 iostream \
224 sstream"
226 # Display CMake bootstrap usage
227 cmake_usage()
229 cat <<EOF
230 Usage: $0 [options]
231 Options: [defaults in brackets after descriptions]
232 Configuration:
233 --help print this message
234 --version only print version information
235 --verbose display more information
236 --parallel=n bootstrap cmake in parallel, where n is
237 number of nodes [1]
238 --init=FILE use FILE for cmake initialization
239 --system-libs use system-installed third-party libraries
240 (for use only by package maintainers)
241 --no-system-libs use cmake-provided third-party libraries
242 (default)
244 Directory and file names:
245 --prefix=PREFIX install files in tree rooted at PREFIX
246 [${cmake_default_prefix}]
247 --datadir=DIR install data files in PREFIX/DIR
248 [/share/CMake]
249 --docdir=DIR install documentation files in PREFIX/DIR
250 [/doc/CMake]
251 --mandir=DIR install man pages files in PREFIX/DIR/manN
252 [/man]
254 exit 10
257 # Display CMake bootstrap usage
258 cmake_version()
261 # Get CMake version
262 if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
263 version="${cmake_version}-${cmake_date_stamp}"
264 else
265 version="${cmake_version}-${cmake_version_patch}"
267 echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
271 # Display CMake bootstrap error, display the log file and exit
272 cmake_error()
274 res=$1
275 shift 1
276 echo "---------------------------------------------"
277 echo "Error when bootstrapping CMake:"
278 echo "$*"
279 echo "---------------------------------------------"
280 if [ -f cmake_bootstrap.log ]; then
281 echo "Log of errors: `pwd`/cmake_bootstrap.log"
282 #cat cmake_bootstrap.log
283 echo "---------------------------------------------"
285 exit ${res}
288 # Replace KWSYS_NAMESPACE with cmsys
289 cmake_replace_string ()
291 INFILE="$1"
292 OUTFILE="$2"
293 SEARCHFOR="$3"
294 REPLACEWITH="$4"
295 if [ -f "${INFILE}" ]; then
296 cat "${INFILE}" |
297 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
298 if [ -f "${OUTFILE}.tmp" ]; then
299 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
300 #echo "Files are the same"
301 rm -f "${OUTFILE}.tmp"
302 else
303 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
306 else
307 cmake_error 1 "Cannot find file ${INFILE}"
311 cmake_kwsys_config_replace_string ()
313 INFILE="$1"
314 OUTFILE="$2"
315 shift 2
316 APPEND="$*"
317 if [ -f "${INFILE}" ]; then
318 echo "${APPEND}" > "${OUTFILE}.tmp"
319 cat "${INFILE}" |
320 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
321 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
322 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
323 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
324 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
325 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
326 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
327 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
328 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
329 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
330 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
331 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
332 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
333 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
334 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
335 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
336 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
337 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
338 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
339 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
340 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
341 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
342 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
343 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
344 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
345 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
346 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
347 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
348 if [ -f "${OUTFILE}.tmp" ]; then
349 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
350 #echo "Files are the same"
351 rm -f "${OUTFILE}.tmp"
352 else
353 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
356 else
357 cmake_error 2 "Cannot find file ${INFILE}"
360 # Write string into a file
361 cmake_report ()
363 FILE=$1
364 shift
365 echo "$*" >> ${FILE}
368 # Escape spaces in strings
369 cmake_escape ()
371 echo $1 | sed "s/ /\\\\ /g"
374 # Write message to the log
375 cmake_log ()
377 echo "$*" >> cmake_bootstrap.log
380 # Return temp file
381 cmake_tmp_file ()
383 echo "cmake_bootstrap_$$.test"
386 # Run a compiler test. First argument is compiler, second one are compiler
387 # flags, third one is test source file to be compiled
388 cmake_try_run ()
390 COMPILER=$1
391 FLAGS=$2
392 TESTFILE=$3
393 if [ ! -f "${TESTFILE}" ]; then
394 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
395 exit 4
397 TMPFILE=`cmake_tmp_file`
398 echo "Try: ${COMPILER}"
399 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
400 echo "---------- file -----------------------"
401 cat "${TESTFILE}"
402 echo "------------------------------------------"
403 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
404 RES=$?
405 if [ "${RES}" -ne "0" ]; then
406 echo "Test failed to compile"
407 return 1
409 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
410 echo "Test failed to produce executable"
411 return 2
413 ./${TMPFILE}
414 RES=$?
415 rm -f "${TMPFILE}"
416 if [ "${RES}" -ne "0" ]; then
417 echo "Test produced non-zero return code"
418 return 3
420 echo "Test succeded"
421 return 0
424 # Run a make test. First argument is the make interpreter.
425 cmake_try_make ()
427 MAKE_PROC="$1"
428 MAKE_FLAGS="$2"
429 echo "Try: ${MAKE_PROC}"
430 "${MAKE_PROC}" ${MAKE_FLAGS}
431 RES=$?
432 if [ "${RES}" -ne "0" ]; then
433 echo "${MAKE_PROC} does not work"
434 return 1
436 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
437 echo "${COMPILER} does not produce output"
438 return 2
440 ./test
441 RES=$?
442 rm -f "test"
443 if [ "${RES}" -ne "0" ]; then
444 echo "${MAKE_PROC} produces strange executable"
445 return 3
447 echo "${MAKE_PROC} works"
448 return 0
451 # Parse arguments
452 cmake_verbose=
453 cmake_parallel_make=
454 cmake_prefix_dir="${cmake_default_prefix}"
455 for a in "$@"; do
456 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
457 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
458 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
460 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
461 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
463 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
464 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
466 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
467 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
469 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
470 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
472 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
473 cmake_init_file=`echo $a | sed "s/^--init=//"`
475 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
476 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
478 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
479 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
481 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
482 cmake_usage
484 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
485 cmake_version
486 exit 2
488 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
489 cmake_verbose=TRUE
491 done
493 # If verbose, display some information about bootstrap
494 if [ -n "${cmake_verbose}" ]; then
495 echo "---------------------------------------------"
496 echo "Source directory: ${cmake_source_dir}"
497 echo "Binary directory: ${cmake_binary_dir}"
498 echo "Prefix directory: ${cmake_prefix_dir}"
499 echo "System: ${cmake_system}"
500 if [ "x${cmake_parallel_make}" != "x" ]; then
501 echo "Doing parallel make: ${cmake_parallel_make}"
503 echo ""
506 echo "---------------------------------------------"
507 # Get CMake version
508 echo "`cmake_version`"
510 # Check for in-source build
511 cmake_in_source_build=
512 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
513 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
514 if [ -n "${cmake_verbose}" ]; then
515 echo "Warning: This is an in-source build"
517 cmake_in_source_build=TRUE
520 # If this is not an in-source build, then Bootstrap stuff should not exist.
521 if [ -z "${cmake_in_source_build}" ]; then
522 # Did somebody bootstrap in the source tree?
523 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
524 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
525 Looks like somebody did bootstrap CMake in the source tree, but now you are
526 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
527 directory from the source tree."
529 # Is there a cache in the source tree?
530 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
531 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
532 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
533 Looks like somebody tried to build CMake in the source tree, but now you are
534 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
535 from the source tree."
537 done
540 # Make bootstrap directory
541 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
542 if [ ! -d "${cmake_bootstrap_dir}" ]; then
543 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
545 cd "${cmake_bootstrap_dir}"
547 [ -d "cmsys" ] || mkdir "cmsys"
548 if [ ! -d "cmsys" ]; then
549 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
552 for a in stl ios; do
553 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
554 if [ ! -d "cmsys/${a}" ]; then
555 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
557 done
559 # Delete all the bootstrap files
560 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
561 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
563 # If exist compiler flags, set them
564 cmake_c_flags=${CFLAGS}
565 cmake_cxx_flags=${CXXFLAGS}
566 cmake_ld_flags=${LDFLAGS}
568 # Add Carbon framework on Darwin
569 if ${cmake_system_darwin}; then
570 cmake_ld_flags="${LDFLAGS} -framework Carbon"
573 # Add BeOS toolkits...
574 if ${cmake_system_beos}; then
575 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
578 # Test C compiler
579 cmake_c_compiler=
581 # If CC is set, use that for compiler, otherwise use list of known compilers
582 if [ -n "${CC}" ]; then
583 cmake_c_compilers="${CC}"
584 else
585 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
588 # Check if C compiler works
589 TMPFILE=`cmake_tmp_file`
590 cat > "${TMPFILE}.c" <<EOF
591 #ifdef __cplusplus
592 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
593 #endif
595 #include<stdio.h>
597 #if defined(__CLASSIC_C__)
598 int main(argc, argv)
599 int argc;
600 char* argv[];
601 #else
602 int main(int argc, char* argv[])
603 #endif
605 printf("%d\n", (argv != 0));
606 return argc-1;
609 for a in ${cmake_c_compilers}; do
610 if [ -z "${cmake_c_compiler}" ] && \
611 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
612 cmake_c_compiler="${a}"
614 done
615 rm -f "${TMPFILE}.c"
617 if [ -z "${cmake_c_compiler}" ]; then
618 cmake_error 6 "Cannot find appropriate C compiler on this system.
619 Please specify one using environment variable CC.
620 See cmake_bootstrap.log for compilers attempted.
623 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
625 # Test CXX compiler
626 cmake_cxx_compiler=
628 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
630 # If CC is set, use that for compiler, otherwise use list of known compilers
631 if [ -n "${CXX}" ]; then
632 cmake_cxx_compilers="${CXX}"
633 else
634 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
637 # Check if C++ compiler works
638 TMPFILE=`cmake_tmp_file`
639 cat > "${TMPFILE}.cxx" <<EOF
640 #if defined(TEST1)
641 # include <iostream>
642 #else
643 # include <iostream.h>
644 #endif
646 class NeedCXX
648 public:
649 NeedCXX() { this->Foo = 1; }
650 int GetFoo() { return this->Foo; }
651 private:
652 int Foo;
654 int main()
656 NeedCXX c;
657 #ifdef TEST3
658 cout << c.GetFoo() << endl;
659 #else
660 std::cout << c.GetFoo() << std::endl;
661 #endif
662 return 0;
665 for a in ${cmake_cxx_compilers}; do
666 for b in 1 2 3; do
667 if [ -z "${cmake_cxx_compiler}" ] && \
668 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
669 cmake_cxx_compiler="${a}"
671 done
672 done
673 rm -f "${TMPFILE}.cxx"
675 if [ -z "${cmake_cxx_compiler}" ]; then
676 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
677 Please specify one using environment variable CXX.
678 See cmake_bootstrap.log for compilers attempted."
680 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
682 # Test Make
684 cmake_make_processor=
685 cmake_make_flags=
687 # If MAKE is set, use that for make processor, otherwise use list of known make
688 if [ -n "${MAKE}" ]; then
689 cmake_make_processors="${MAKE}"
690 else
691 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
694 TMPFILE="`cmake_tmp_file`_dir"
695 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
696 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
697 cd "${cmake_bootstrap_dir}/${TMPFILE}"
698 cat>"Makefile"<<EOF
699 test: test.c
700 "${cmake_c_compiler}" -o test test.c
702 cat>"test.c"<<EOF
703 #include <stdio.h>
704 int main(){ printf("1\n"); return 0; }
706 cmake_original_make_flags="${cmake_make_flags}"
707 if [ "x${cmake_parallel_make}" != "x" ]; then
708 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
710 for a in ${cmake_make_processors}; do
711 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
712 cmake_make_processor="${a}"
714 done
715 cmake_full_make_flags="${cmake_make_flags}"
716 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
717 if [ -z "${cmake_make_processor}" ]; then
718 cmake_make_flags="${cmake_original_make_flags}"
719 for a in ${cmake_make_processors}; do
720 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
721 cmake_make_processor="${a}"
723 done
726 cd "${cmake_bootstrap_dir}"
727 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
729 if [ -z "${cmake_make_processor}" ]; then
730 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
731 Please specify one using environment variable MAKE."
733 echo "Makefile processor on this system is: ${cmake_make_processor}"
734 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
735 echo "---------------------------------------------"
736 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
737 echo "---------------------------------------------"
740 # Ok, we have CC, CXX, and MAKE.
742 # Test C++ compiler features
744 # Are we GCC?
746 TMPFILE=`cmake_tmp_file`
747 cat > ${TMPFILE}.cxx <<EOF
748 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
749 #include <iostream>
750 int main() { std::cout << "This is GNU" << std::endl; return 0;}
751 #endif
753 cmake_cxx_compiler_is_gnu=0
754 if cmake_try_run "${cmake_cxx_compiler}" \
755 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
756 cmake_cxx_compiler_is_gnu=1
758 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
759 echo "${cmake_cxx_compiler} is GNU compiler"
760 else
761 echo "${cmake_cxx_compiler} is not GNU compiler"
763 rm -f "${TMPFILE}.cxx"
765 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
766 # Check for non-GNU compiler flags
768 # If we are on IRIX, check for -LANG:std
769 cmake_test_flags="-LANG:std"
770 if [ "x${cmake_system}" = "xIRIX64" ]; then
771 TMPFILE=`cmake_tmp_file`
772 cat > ${TMPFILE}.cxx <<EOF
773 #include <iostream>
774 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
776 cmake_need_lang_std=0
777 if cmake_try_run "${cmake_cxx_compiler}" \
778 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
780 else
781 if cmake_try_run "${cmake_cxx_compiler}" \
782 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
783 cmake_need_lang_std=1
786 if [ "x${cmake_need_lang_std}" = "x1" ]; then
787 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
788 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
789 else
790 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
792 rm -f "${TMPFILE}.cxx"
794 cmake_test_flags=
796 # If we are on OSF, check for -timplicit_local -no_implicit_include
797 cmake_test_flags="-timplicit_local -no_implicit_include"
798 if [ "x${cmake_system}" = "xOSF1" ]; then
799 TMPFILE=`cmake_tmp_file`
800 cat > ${TMPFILE}.cxx <<EOF
801 #include <iostream>
802 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
804 cmake_need_flags=1
805 if cmake_try_run "${cmake_cxx_compiler}" \
806 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
808 else
809 cmake_need_flags=0
811 if [ "x${cmake_need_flags}" = "x1" ]; then
812 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
813 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
814 else
815 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
817 rm -f "${TMPFILE}.cxx"
819 cmake_test_flags=
821 # If we are on OSF, check for -std strict_ansi -nopure_cname
822 cmake_test_flags="-std strict_ansi -nopure_cname"
823 if [ "x${cmake_system}" = "xOSF1" ]; then
824 TMPFILE=`cmake_tmp_file`
825 cat > ${TMPFILE}.cxx <<EOF
826 #include <iostream>
827 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
829 cmake_need_flags=1
830 if cmake_try_run "${cmake_cxx_compiler}" \
831 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
833 else
834 cmake_need_flags=0
836 if [ "x${cmake_need_flags}" = "x1" ]; then
837 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
838 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
839 else
840 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
842 rm -f "${TMPFILE}.cxx"
844 cmake_test_flags=
846 # If we are on HP-UX, check for -Ae for the C compiler.
847 cmake_test_flags="-Ae"
848 if [ "x${cmake_system}" = "xHP-UX" ]; then
849 TMPFILE=`cmake_tmp_file`
850 cat > ${TMPFILE}.c <<EOF
851 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
853 cmake_need_Ae=0
854 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
856 else
857 if cmake_try_run "${cmake_c_compiler}" \
858 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
859 cmake_need_Ae=1
862 if [ "x${cmake_need_Ae}" = "x1" ]; then
863 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
864 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
865 else
866 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
868 rm -f "${TMPFILE}.c"
870 cmake_test_flags=
873 # Test for kwsys features
874 KWSYS_NAME_IS_KWSYS=0
875 KWSYS_BUILD_SHARED=0
876 KWSYS_LFS_AVAILABLE=0
877 KWSYS_LFS_REQUESTED=0
878 KWSYS_IOS_USE_STRSTREAM_H=0
879 KWSYS_IOS_USE_STRSTREA_H=0
880 KWSYS_IOS_HAVE_STD=0
881 KWSYS_IOS_USE_SSTREAM=0
882 KWSYS_IOS_USE_ANSI=0
883 KWSYS_STL_HAVE_STD=0
884 KWSYS_STAT_HAS_ST_MTIM=0
885 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
886 KWSYS_STL_HAS_ITERATOR_TRAITS=0
887 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
888 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
889 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
890 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
891 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
892 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
893 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
894 KWSYS_CXX_HAS_CSTDDEF=0
895 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
896 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
897 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
898 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
900 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
901 KWSYS_STL_STRING_HAVE_ISTREAM=1
902 KWSYS_STL_STRING_HAVE_OSTREAM=1
904 if cmake_try_run "${cmake_cxx_compiler}" \
905 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
906 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
907 KWSYS_STL_HAVE_STD=1
908 echo "${cmake_cxx_compiler} has STL in std:: namespace"
909 else
910 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
913 if cmake_try_run "${cmake_cxx_compiler}" \
914 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
915 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
916 KWSYS_IOS_USE_ANSI=1
917 echo "${cmake_cxx_compiler} has ANSI streams"
918 else
919 echo "${cmake_cxx_compiler} does not have ANSI streams"
922 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
923 if cmake_try_run "${cmake_cxx_compiler}" \
924 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
925 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
926 KWSYS_IOS_HAVE_STD=1
927 echo "${cmake_cxx_compiler} has streams in std:: namespace"
928 else
929 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
931 if cmake_try_run "${cmake_cxx_compiler}" \
932 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
933 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
934 KWSYS_IOS_USE_SSTREAM=1
935 echo "${cmake_cxx_compiler} has sstream"
936 else
937 echo "${cmake_cxx_compiler} does not have sstream"
941 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
942 if cmake_try_run "${cmake_cxx_compiler}" \
943 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
944 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
945 KWSYS_IOS_USE_STRSTREAM_H=1
946 echo "${cmake_cxx_compiler} has strstream.h"
947 else
948 echo "${cmake_cxx_compiler} does not have strstream.h"
950 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
951 if cmake_try_run "${cmake_cxx_compiler}" \
952 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
953 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
954 KWSYS_IOS_USE_STRSTREA_H=1
955 echo "${cmake_cxx_compiler} has strstrea.h"
956 else
957 echo "${cmake_cxx_compiler} does not have strstrea.h"
962 if cmake_try_run "${cmake_cxx_compiler}" \
963 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
964 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
965 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
966 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
967 else
968 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
971 if cmake_try_run "${cmake_cxx_compiler}" \
972 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
973 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
974 KWSYS_STL_HAS_ITERATOR_TRAITS=1
975 echo "${cmake_cxx_compiler} has stl iterator_traits"
976 else
977 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
980 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
981 if cmake_try_run "${cmake_cxx_compiler}" \
982 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
983 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
984 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
985 echo "${cmake_cxx_compiler} has old iterator_category"
986 else
987 echo "${cmake_cxx_compiler} does not have old iterator_category"
989 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
990 if cmake_try_run "${cmake_cxx_compiler}" \
991 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
992 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
993 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
994 echo "${cmake_cxx_compiler} has old __iterator_category"
995 else
996 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1001 if cmake_try_run "${cmake_cxx_compiler}" \
1002 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1003 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1004 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1005 echo "${cmake_cxx_compiler} has standard template allocator"
1006 else
1007 echo "${cmake_cxx_compiler} does not have standard template allocator"
1010 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1011 if cmake_try_run "${cmake_cxx_compiler}" \
1012 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -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_ALLOCATOR_REBIND=1
1015 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1016 else
1017 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1020 if cmake_try_run "${cmake_cxx_compiler}" \
1021 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1022 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1023 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1024 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1025 else
1026 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1028 else
1029 if cmake_try_run "${cmake_cxx_compiler}" \
1030 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1031 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1032 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1033 echo "${cmake_cxx_compiler} has old non-template allocator"
1034 else
1035 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1039 if cmake_try_run "${cmake_cxx_compiler}" \
1040 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1041 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1042 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1043 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1044 else
1045 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1048 if cmake_try_run "${cmake_cxx_compiler}" \
1049 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1050 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1051 KWSYS_CXX_HAS_CSTDDEF=1
1052 echo "${cmake_cxx_compiler} has header cstddef"
1053 else
1054 echo "${cmake_cxx_compiler} does not have header cstddef"
1057 if cmake_try_run "${cmake_cxx_compiler}" \
1058 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1059 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1060 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1061 else
1062 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1063 echo "${cmake_cxx_compiler} requires template friends to use <>"
1066 if cmake_try_run "${cmake_cxx_compiler}" \
1067 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1068 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1069 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1070 echo "${cmake_cxx_compiler} supports member templates"
1071 else
1072 echo "${cmake_cxx_compiler} does not support member templates"
1075 if cmake_try_run "${cmake_cxx_compiler}" \
1076 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1077 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1078 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1079 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1080 else
1081 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1084 if cmake_try_run "${cmake_cxx_compiler}" \
1085 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1086 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1087 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1088 echo "${cmake_cxx_compiler} has argument dependent lookup"
1089 else
1090 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1093 if cmake_try_run "${cmake_cxx_compiler}" \
1094 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1095 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1096 KWSYS_STAT_HAS_ST_MTIM=1
1097 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1098 else
1099 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1102 # Just to be safe, let us store compiler and flags to the header file
1104 cmake_bootstrap_version='$Revision: 1.102 $'
1105 cmake_compiler_settings_comment="/*
1106 * Generated by ${cmake_source_dir}/bootstrap
1107 * Version: ${cmake_bootstrap_version}
1109 * Source directory: ${cmake_source_dir}
1110 * Binary directory: ${cmake_bootstrap_dir}
1112 * C compiler: ${cmake_c_compiler}
1113 * C flags: ${cmake_c_flags}
1115 * C++ compiler: ${cmake_cxx_compiler}
1116 * C++ flags: ${cmake_cxx_flags}
1118 * Make: ${cmake_make_processor}
1120 * Sources:
1121 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1122 * kwSys Sources:
1123 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1127 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1129 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1130 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1131 else
1132 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1135 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1136 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1137 else
1138 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1141 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1142 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1143 else
1144 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1147 # Test for ansi FOR scope
1148 if cmake_try_run "${cmake_cxx_compiler}" \
1149 "${cmake_cxx_flags}" \
1150 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1151 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1152 echo "${cmake_cxx_compiler} has ANSI for scoping"
1153 else
1154 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1155 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1158 # When bootstrapping on MinGW with MSYS we must convert the source
1159 # directory to a windows path.
1160 if ${cmake_system_mingw}; then
1161 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1162 else
1163 cmake_root_dir="${cmake_source_dir}"
1166 # Write CMake version
1167 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1168 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1169 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1170 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1171 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1172 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1174 # Regenerate real cmConfigure.h
1175 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1176 rm -f cmConfigure.h.tmp
1177 else
1178 mv -f cmConfigure.h.tmp cmConfigure.h
1181 # Prepare KWSYS
1182 cmake_kwsys_config_replace_string \
1183 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1184 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1185 "${cmake_compiler_settings_comment}"
1186 cmake_kwsys_config_replace_string \
1187 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1188 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1189 "${cmake_compiler_settings_comment}"
1191 cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
1192 /* Minimal DateStamp header for CMake bootstrap build. */
1193 #ifndef cmsys_DateStamp_h
1194 #define cmsys_DateStamp_h
1195 #define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
1196 #endif
1199 for a in ${KWSYS_FILES}; do
1200 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1201 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1202 done
1204 for a in ${KWSYS_IOS_FILES}; do
1205 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1206 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1207 done
1209 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1210 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1212 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1213 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1215 for a in string vector map; do
1216 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1217 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1218 done
1220 # Generate Makefile
1221 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1222 objs=""
1223 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1224 objs="${objs} ${a}.o"
1225 done
1227 # Generate dependencies for cmBootstrapCommands.cxx
1228 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1229 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1230 done
1231 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1233 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1234 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1237 if [ "x${cmake_c_flags}" != "x" ]; then
1238 cmake_c_flags="${cmake_c_flags} "
1241 if [ "x${cmake_cxx_flags}" != "x" ]; then
1242 cmake_cxx_flags="${cmake_cxx_flags} "
1245 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1246 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1247 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1248 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1249 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1250 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1251 for a in ${CMAKE_CXX_SOURCES}; do
1252 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1253 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1254 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1255 done
1256 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1257 for a in ${CMAKE_C_SOURCES}; do
1258 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1259 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1260 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1261 done
1262 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1263 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1264 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1265 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1266 done
1267 for a in ${KWSYS_CXX_SOURCES}; do
1268 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1269 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1270 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1271 done
1272 if ${cmake_system_mingw}; then
1273 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1274 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1275 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1276 a="cmsysProcessFwd9xEnc"
1277 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1278 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1279 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1280 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1281 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1282 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1283 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1284 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"
1286 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1287 rebuild_cache:
1288 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1291 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1292 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1293 # Generated by ${cmake_source_dir}/bootstrap
1294 # Default cmake settings. These may be overridden any settings below.
1295 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1296 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1297 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1298 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1301 # Add user-specified settings. Handle relative-path case for
1302 # specification of cmake_init_file.
1304 cd "${cmake_binary_dir}"
1305 if [ -f "${cmake_init_file}" ]; then
1306 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1310 echo "---------------------------------------------"
1312 # Run make to build bootstrap cmake
1313 if [ "x${cmake_parallel_make}" != "x" ]; then
1314 ${cmake_make_processor} ${cmake_make_flags}
1315 else
1316 ${cmake_make_processor}
1318 RES=$?
1319 if [ "${RES}" -ne "0" ]; then
1320 cmake_error 9 "Problem while running ${cmake_make_processor}"
1322 cd "${cmake_binary_dir}"
1324 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1325 # build with same compiler and make
1326 CC="${cmake_c_compiler}"
1327 CXX="${cmake_cxx_compiler}"
1328 MAKE="${cmake_make_processor}"
1329 export CC
1330 export CXX
1331 export MAKE
1333 # Run bootstrap CMake to configure real CMake
1334 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1335 RES=$?
1336 if [ "${RES}" -ne "0" ]; then
1337 cmake_error 11 "Problem while running initial CMake"
1340 echo "---------------------------------------------"
1342 # And we are done. Now just run make
1343 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."