ENH: fancier logo
[cmake.git] / bootstrap
blob4b73b3e634a39e8bf21630edeb0145aea1efc008
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2007-11-15 02:17:53 $
9 # Version: $Revision: 1.100 $
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 cmOrderLinkDirectories \
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 System"
188 KWSYS_C_MINGW_SOURCES="\
189 ProcessFwd9x \
190 EncodeExecutable"
191 KWSYS_C_GENERATED_SOURCES="\
192 cmsysProcessFwd9xEnc"
193 else
194 KWSYS_C_SOURCES="\
195 ProcessUNIX \
196 System"
197 KWSYS_C_MINGW_SOURCES=""
198 KWSYS_C_GENERATED_SOURCES=""
201 KWSYS_CXX_SOURCES="\
202 Directory \
203 Glob \
204 RegularExpression \
205 SystemTools"
207 KWSYS_FILES="\
208 Directory.hxx \
209 Glob.hxx \
210 Process.h \
211 RegularExpression.hxx \
212 String.hxx \
213 System.h \
214 SystemTools.hxx"
216 KWSYS_IOS_FILES="
217 fstream \
218 iosfwd \
219 iostream \
220 sstream"
222 # Display CMake bootstrap usage
223 cmake_usage()
225 cat <<EOF
226 Usage: $0 [options]
227 Options: [defaults in brackets after descriptions]
228 Configuration:
229 --help print this message
230 --version only print version information
231 --verbose display more information
232 --parallel=n bootstrap cmake in parallel, where n is
233 number of nodes [1]
234 --init=FILE use FILE for cmake initialization
235 --system-libs use system-installed third-party libraries
236 (for use only by package maintainers)
237 --no-system-libs use cmake-provided third-party libraries
238 (default)
240 Directory and file names:
241 --prefix=PREFIX install files in tree rooted at PREFIX
242 [${cmake_default_prefix}]
243 --datadir=DIR install data files in PREFIX/DIR
244 [/share/CMake]
245 --docdir=DIR install documentation files in PREFIX/DIR
246 [/doc/CMake]
247 --mandir=DIR install man pages files in PREFIX/DIR/manN
248 [/man]
250 exit 10
253 # Display CMake bootstrap usage
254 cmake_version()
257 # Get CMake version
258 if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
259 version="${cmake_version}-${cmake_date_stamp}"
260 else
261 version="${cmake_version}-${cmake_version_patch}"
263 echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
267 # Display CMake bootstrap error, display the log file and exit
268 cmake_error()
270 res=$1
271 shift 1
272 echo "---------------------------------------------"
273 echo "Error when bootstrapping CMake:"
274 echo "$*"
275 echo "---------------------------------------------"
276 if [ -f cmake_bootstrap.log ]; then
277 echo "Log of errors: `pwd`/cmake_bootstrap.log"
278 #cat cmake_bootstrap.log
279 echo "---------------------------------------------"
281 exit ${res}
284 # Replace KWSYS_NAMESPACE with cmsys
285 cmake_replace_string ()
287 INFILE="$1"
288 OUTFILE="$2"
289 SEARCHFOR="$3"
290 REPLACEWITH="$4"
291 if [ -f "${INFILE}" ]; then
292 cat "${INFILE}" |
293 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
294 if [ -f "${OUTFILE}.tmp" ]; then
295 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
296 #echo "Files are the same"
297 rm -f "${OUTFILE}.tmp"
298 else
299 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
302 else
303 cmake_error 1 "Cannot find file ${INFILE}"
307 cmake_kwsys_config_replace_string ()
309 INFILE="$1"
310 OUTFILE="$2"
311 shift 2
312 APPEND="$*"
313 if [ -f "${INFILE}" ]; then
314 echo "${APPEND}" > "${OUTFILE}.tmp"
315 cat "${INFILE}" |
316 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
317 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
318 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
319 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
320 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
321 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
322 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
323 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
324 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
325 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
326 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
327 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
328 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
329 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
330 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
331 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
332 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
333 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
334 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
335 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
336 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
337 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
338 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
339 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
340 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
341 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
342 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
343 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
344 if [ -f "${OUTFILE}.tmp" ]; then
345 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
346 #echo "Files are the same"
347 rm -f "${OUTFILE}.tmp"
348 else
349 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
352 else
353 cmake_error 2 "Cannot find file ${INFILE}"
356 # Write string into a file
357 cmake_report ()
359 FILE=$1
360 shift
361 echo "$*" >> ${FILE}
364 # Escape spaces in strings
365 cmake_escape ()
367 echo $1 | sed "s/ /\\\\ /g"
370 # Write message to the log
371 cmake_log ()
373 echo "$*" >> cmake_bootstrap.log
376 # Return temp file
377 cmake_tmp_file ()
379 echo "cmake_bootstrap_$$.test"
382 # Run a compiler test. First argument is compiler, second one are compiler
383 # flags, third one is test source file to be compiled
384 cmake_try_run ()
386 COMPILER=$1
387 FLAGS=$2
388 TESTFILE=$3
389 if [ ! -f "${TESTFILE}" ]; then
390 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
391 exit 4
393 TMPFILE=`cmake_tmp_file`
394 echo "Try: ${COMPILER}"
395 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
396 echo "---------- file -----------------------"
397 cat "${TESTFILE}"
398 echo "------------------------------------------"
399 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
400 RES=$?
401 if [ "${RES}" -ne "0" ]; then
402 echo "Test failed to compile"
403 return 1
405 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
406 echo "Test failed to produce executable"
407 return 2
409 ./${TMPFILE}
410 RES=$?
411 rm -f "${TMPFILE}"
412 if [ "${RES}" -ne "0" ]; then
413 echo "Test produced non-zero return code"
414 return 3
416 echo "Test succeded"
417 return 0
420 # Run a make test. First argument is the make interpreter.
421 cmake_try_make ()
423 MAKE_PROC="$1"
424 MAKE_FLAGS="$2"
425 echo "Try: ${MAKE_PROC}"
426 "${MAKE_PROC}" ${MAKE_FLAGS}
427 RES=$?
428 if [ "${RES}" -ne "0" ]; then
429 echo "${MAKE_PROC} does not work"
430 return 1
432 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
433 echo "${COMPILER} does not produce output"
434 return 2
436 ./test
437 RES=$?
438 rm -f "test"
439 if [ "${RES}" -ne "0" ]; then
440 echo "${MAKE_PROC} produces strange executable"
441 return 3
443 echo "${MAKE_PROC} works"
444 return 0
447 # Parse arguments
448 cmake_verbose=
449 cmake_parallel_make=
450 cmake_prefix_dir="${cmake_default_prefix}"
451 for a in "$@"; do
452 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
453 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
454 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
456 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
457 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
459 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
460 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
462 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
463 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
465 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
466 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
468 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
469 cmake_init_file=`echo $a | sed "s/^--init=//"`
471 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
472 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
474 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
475 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
477 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
478 cmake_usage
480 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
481 cmake_version
482 exit 2
484 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
485 cmake_verbose=TRUE
487 done
489 # If verbose, display some information about bootstrap
490 if [ -n "${cmake_verbose}" ]; then
491 echo "---------------------------------------------"
492 echo "Source directory: ${cmake_source_dir}"
493 echo "Binary directory: ${cmake_binary_dir}"
494 echo "Prefix directory: ${cmake_prefix_dir}"
495 echo "System: ${cmake_system}"
496 if [ "x${cmake_parallel_make}" != "x" ]; then
497 echo "Doing parallel make: ${cmake_parallel_make}"
499 echo ""
502 echo "---------------------------------------------"
503 # Get CMake version
504 echo "`cmake_version`"
506 # Check for in-source build
507 cmake_in_source_build=
508 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
509 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
510 if [ -n "${cmake_verbose}" ]; then
511 echo "Warning: This is an in-source build"
513 cmake_in_source_build=TRUE
516 # If this is not an in-source build, then Bootstrap stuff should not exist.
517 if [ -z "${cmake_in_source_build}" ]; then
518 # Did somebody bootstrap in the source tree?
519 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
520 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
521 Looks like somebody did bootstrap CMake in the source tree, but now you are
522 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
523 directory from the source tree."
525 # Is there a cache in the source tree?
526 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
527 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
528 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
529 Looks like somebody tried to build CMake in the source tree, but now you are
530 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
531 from the source tree."
533 done
536 # Make bootstrap directory
537 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
538 if [ ! -d "${cmake_bootstrap_dir}" ]; then
539 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
541 cd "${cmake_bootstrap_dir}"
543 [ -d "cmsys" ] || mkdir "cmsys"
544 if [ ! -d "cmsys" ]; then
545 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
548 for a in stl ios; do
549 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
550 if [ ! -d "cmsys/${a}" ]; then
551 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
553 done
555 # Delete all the bootstrap files
556 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
557 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
559 # If exist compiler flags, set them
560 cmake_c_flags=${CFLAGS}
561 cmake_cxx_flags=${CXXFLAGS}
562 cmake_ld_flags=${LDFLAGS}
564 # Add Carbon framework on Darwin
565 if ${cmake_system_darwin}; then
566 cmake_ld_flags="${LDFLAGS} -framework Carbon"
569 # Add BeOS toolkits...
570 if ${cmake_system_beos}; then
571 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
574 # Test C compiler
575 cmake_c_compiler=
577 # If CC is set, use that for compiler, otherwise use list of known compilers
578 if [ -n "${CC}" ]; then
579 cmake_c_compilers="${CC}"
580 else
581 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
584 # Check if C compiler works
585 TMPFILE=`cmake_tmp_file`
586 cat > "${TMPFILE}.c" <<EOF
587 #ifdef __cplusplus
588 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
589 #endif
591 #include<stdio.h>
593 #if defined(__CLASSIC_C__)
594 int main(argc, argv)
595 int argc;
596 char* argv[];
597 #else
598 int main(int argc, char* argv[])
599 #endif
601 printf("%d\n", (argv != 0));
602 return argc-1;
605 for a in ${cmake_c_compilers}; do
606 if [ -z "${cmake_c_compiler}" ] && \
607 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
608 cmake_c_compiler="${a}"
610 done
611 rm -f "${TMPFILE}.c"
613 if [ -z "${cmake_c_compiler}" ]; then
614 cmake_error 6 "Cannot find appropriate C compiler on this system.
615 Please specify one using environment variable CC.
616 See cmake_bootstrap.log for compilers attempted.
619 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
621 # Test CXX compiler
622 cmake_cxx_compiler=
624 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
626 # If CC is set, use that for compiler, otherwise use list of known compilers
627 if [ -n "${CXX}" ]; then
628 cmake_cxx_compilers="${CXX}"
629 else
630 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
633 # Check if C++ compiler works
634 TMPFILE=`cmake_tmp_file`
635 cat > "${TMPFILE}.cxx" <<EOF
636 #if defined(TEST1)
637 # include <iostream>
638 #else
639 # include <iostream.h>
640 #endif
642 class NeedCXX
644 public:
645 NeedCXX() { this->Foo = 1; }
646 int GetFoo() { return this->Foo; }
647 private:
648 int Foo;
650 int main()
652 NeedCXX c;
653 #ifdef TEST3
654 cout << c.GetFoo() << endl;
655 #else
656 std::cout << c.GetFoo() << std::endl;
657 #endif
658 return 0;
661 for a in ${cmake_cxx_compilers}; do
662 for b in 1 2 3; do
663 if [ -z "${cmake_cxx_compiler}" ] && \
664 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
665 cmake_cxx_compiler="${a}"
667 done
668 done
669 rm -f "${TMPFILE}.cxx"
671 if [ -z "${cmake_cxx_compiler}" ]; then
672 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
673 Please specify one using environment variable CXX.
674 See cmake_bootstrap.log for compilers attempted."
676 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
678 # Test Make
680 cmake_make_processor=
681 cmake_make_flags=
683 # If MAKE is set, use that for make processor, otherwise use list of known make
684 if [ -n "${MAKE}" ]; then
685 cmake_make_processors="${MAKE}"
686 else
687 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
690 TMPFILE="`cmake_tmp_file`_dir"
691 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
692 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
693 cd "${cmake_bootstrap_dir}/${TMPFILE}"
694 cat>"Makefile"<<EOF
695 test: test.c
696 "${cmake_c_compiler}" -o test test.c
698 cat>"test.c"<<EOF
699 #include <stdio.h>
700 int main(){ printf("1\n"); return 0; }
702 cmake_original_make_flags="${cmake_make_flags}"
703 if [ "x${cmake_parallel_make}" != "x" ]; then
704 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
706 for a in ${cmake_make_processors}; do
707 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
708 cmake_make_processor="${a}"
710 done
711 cmake_full_make_flags="${cmake_make_flags}"
712 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
713 if [ -z "${cmake_make_processor}" ]; then
714 cmake_make_flags="${cmake_original_make_flags}"
715 for a in ${cmake_make_processors}; do
716 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
717 cmake_make_processor="${a}"
719 done
722 cd "${cmake_bootstrap_dir}"
723 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
725 if [ -z "${cmake_make_processor}" ]; then
726 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
727 Please specify one using environment variable MAKE."
729 echo "Makefile processor on this system is: ${cmake_make_processor}"
730 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
731 echo "---------------------------------------------"
732 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
733 echo "---------------------------------------------"
736 # Ok, we have CC, CXX, and MAKE.
738 # Test C++ compiler features
740 # Are we GCC?
742 TMPFILE=`cmake_tmp_file`
743 cat > ${TMPFILE}.cxx <<EOF
744 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
745 #include <iostream>
746 int main() { std::cout << "This is GNU" << std::endl; return 0;}
747 #endif
749 cmake_cxx_compiler_is_gnu=0
750 if cmake_try_run "${cmake_cxx_compiler}" \
751 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
752 cmake_cxx_compiler_is_gnu=1
754 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
755 echo "${cmake_cxx_compiler} is GNU compiler"
756 else
757 echo "${cmake_cxx_compiler} is not GNU compiler"
759 rm -f "${TMPFILE}.cxx"
761 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
762 # Check for non-GNU compiler flags
764 # If we are on IRIX, check for -LANG:std
765 cmake_test_flags="-LANG:std"
766 if [ "x${cmake_system}" = "xIRIX64" ]; then
767 TMPFILE=`cmake_tmp_file`
768 cat > ${TMPFILE}.cxx <<EOF
769 #include <iostream>
770 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
772 cmake_need_lang_std=0
773 if cmake_try_run "${cmake_cxx_compiler}" \
774 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
776 else
777 if cmake_try_run "${cmake_cxx_compiler}" \
778 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
779 cmake_need_lang_std=1
782 if [ "x${cmake_need_lang_std}" = "x1" ]; then
783 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
784 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
785 else
786 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
788 rm -f "${TMPFILE}.cxx"
790 cmake_test_flags=
792 # If we are on OSF, check for -timplicit_local -no_implicit_include
793 cmake_test_flags="-timplicit_local -no_implicit_include"
794 if [ "x${cmake_system}" = "xOSF1" ]; then
795 TMPFILE=`cmake_tmp_file`
796 cat > ${TMPFILE}.cxx <<EOF
797 #include <iostream>
798 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
800 cmake_need_flags=1
801 if cmake_try_run "${cmake_cxx_compiler}" \
802 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
804 else
805 cmake_need_flags=0
807 if [ "x${cmake_need_flags}" = "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 -std strict_ansi -nopure_cname
818 cmake_test_flags="-std strict_ansi -nopure_cname"
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 HP-UX, check for -Ae for the C compiler.
843 cmake_test_flags="-Ae"
844 if [ "x${cmake_system}" = "xHP-UX" ]; then
845 TMPFILE=`cmake_tmp_file`
846 cat > ${TMPFILE}.c <<EOF
847 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
849 cmake_need_Ae=0
850 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
852 else
853 if cmake_try_run "${cmake_c_compiler}" \
854 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
855 cmake_need_Ae=1
858 if [ "x${cmake_need_Ae}" = "x1" ]; then
859 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
860 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
861 else
862 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
864 rm -f "${TMPFILE}.c"
866 cmake_test_flags=
869 # Test for kwsys features
870 KWSYS_NAME_IS_KWSYS=0
871 KWSYS_BUILD_SHARED=0
872 KWSYS_LFS_AVAILABLE=0
873 KWSYS_LFS_REQUESTED=0
874 KWSYS_IOS_USE_STRSTREAM_H=0
875 KWSYS_IOS_USE_STRSTREA_H=0
876 KWSYS_IOS_HAVE_STD=0
877 KWSYS_IOS_USE_SSTREAM=0
878 KWSYS_IOS_USE_ANSI=0
879 KWSYS_STL_HAVE_STD=0
880 KWSYS_STAT_HAS_ST_MTIM=0
881 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
882 KWSYS_STL_HAS_ITERATOR_TRAITS=0
883 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
884 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
885 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
886 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
887 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
888 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
889 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
890 KWSYS_CXX_HAS_CSTDDEF=0
891 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
892 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
893 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
894 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
896 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
897 KWSYS_STL_STRING_HAVE_ISTREAM=1
898 KWSYS_STL_STRING_HAVE_OSTREAM=1
900 if cmake_try_run "${cmake_cxx_compiler}" \
901 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
902 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
903 KWSYS_STL_HAVE_STD=1
904 echo "${cmake_cxx_compiler} has STL in std:: namespace"
905 else
906 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
909 if cmake_try_run "${cmake_cxx_compiler}" \
910 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
911 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
912 KWSYS_IOS_USE_ANSI=1
913 echo "${cmake_cxx_compiler} has ANSI streams"
914 else
915 echo "${cmake_cxx_compiler} does not have ANSI streams"
918 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
919 if cmake_try_run "${cmake_cxx_compiler}" \
920 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
921 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
922 KWSYS_IOS_HAVE_STD=1
923 echo "${cmake_cxx_compiler} has streams in std:: namespace"
924 else
925 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
927 if cmake_try_run "${cmake_cxx_compiler}" \
928 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
929 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
930 KWSYS_IOS_USE_SSTREAM=1
931 echo "${cmake_cxx_compiler} has sstream"
932 else
933 echo "${cmake_cxx_compiler} does not have sstream"
937 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
938 if cmake_try_run "${cmake_cxx_compiler}" \
939 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
940 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
941 KWSYS_IOS_USE_STRSTREAM_H=1
942 echo "${cmake_cxx_compiler} has strstream.h"
943 else
944 echo "${cmake_cxx_compiler} does not have strstream.h"
946 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
947 if cmake_try_run "${cmake_cxx_compiler}" \
948 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
949 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
950 KWSYS_IOS_USE_STRSTREA_H=1
951 echo "${cmake_cxx_compiler} has strstrea.h"
952 else
953 echo "${cmake_cxx_compiler} does not have strstrea.h"
958 if cmake_try_run "${cmake_cxx_compiler}" \
959 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
960 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
961 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
962 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
963 else
964 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
967 if cmake_try_run "${cmake_cxx_compiler}" \
968 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
969 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
970 KWSYS_STL_HAS_ITERATOR_TRAITS=1
971 echo "${cmake_cxx_compiler} has stl iterator_traits"
972 else
973 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
976 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
977 if cmake_try_run "${cmake_cxx_compiler}" \
978 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
979 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
980 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
981 echo "${cmake_cxx_compiler} has old iterator_category"
982 else
983 echo "${cmake_cxx_compiler} does not have old iterator_category"
985 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
986 if cmake_try_run "${cmake_cxx_compiler}" \
987 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
988 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
989 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
990 echo "${cmake_cxx_compiler} has old __iterator_category"
991 else
992 echo "${cmake_cxx_compiler} does not have old __iterator_category"
997 if cmake_try_run "${cmake_cxx_compiler}" \
998 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
999 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1000 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1001 echo "${cmake_cxx_compiler} has standard template allocator"
1002 else
1003 echo "${cmake_cxx_compiler} does not have standard template allocator"
1006 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1007 if cmake_try_run "${cmake_cxx_compiler}" \
1008 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1009 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1010 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1011 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1012 else
1013 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1016 if cmake_try_run "${cmake_cxx_compiler}" \
1017 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1018 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1019 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1020 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1021 else
1022 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1024 else
1025 if cmake_try_run "${cmake_cxx_compiler}" \
1026 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1027 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1028 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1029 echo "${cmake_cxx_compiler} has old non-template allocator"
1030 else
1031 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1035 if cmake_try_run "${cmake_cxx_compiler}" \
1036 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1037 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1038 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1039 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1040 else
1041 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1044 if cmake_try_run "${cmake_cxx_compiler}" \
1045 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1046 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1047 KWSYS_CXX_HAS_CSTDDEF=1
1048 echo "${cmake_cxx_compiler} has header cstddef"
1049 else
1050 echo "${cmake_cxx_compiler} does not have header cstddef"
1053 if cmake_try_run "${cmake_cxx_compiler}" \
1054 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1055 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1056 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1057 else
1058 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1059 echo "${cmake_cxx_compiler} requires template friends to use <>"
1062 if cmake_try_run "${cmake_cxx_compiler}" \
1063 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1064 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1065 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1066 echo "${cmake_cxx_compiler} supports member templates"
1067 else
1068 echo "${cmake_cxx_compiler} does not support member templates"
1071 if cmake_try_run "${cmake_cxx_compiler}" \
1072 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1073 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1074 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1075 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1076 else
1077 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1080 if cmake_try_run "${cmake_cxx_compiler}" \
1081 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1082 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1083 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1084 echo "${cmake_cxx_compiler} has argument dependent lookup"
1085 else
1086 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1089 if cmake_try_run "${cmake_cxx_compiler}" \
1090 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1091 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1092 KWSYS_STAT_HAS_ST_MTIM=1
1093 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1094 else
1095 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1098 # Just to be safe, let us store compiler and flags to the header file
1100 cmake_bootstrap_version='$Revision: 1.100 $'
1101 cmake_compiler_settings_comment="/*
1102 * Generated by ${cmake_source_dir}/bootstrap
1103 * Version: ${cmake_bootstrap_version}
1105 * Source directory: ${cmake_source_dir}
1106 * Binary directory: ${cmake_bootstrap_dir}
1108 * C compiler: ${cmake_c_compiler}
1109 * C flags: ${cmake_c_flags}
1111 * C++ compiler: ${cmake_cxx_compiler}
1112 * C++ flags: ${cmake_cxx_flags}
1114 * Make: ${cmake_make_processor}
1116 * Sources:
1117 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1118 * kwSys Sources:
1119 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1123 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1125 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1126 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1127 else
1128 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1131 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1132 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1133 else
1134 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1137 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1138 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1139 else
1140 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1143 # Test for ansi FOR scope
1144 if cmake_try_run "${cmake_cxx_compiler}" \
1145 "${cmake_cxx_flags}" \
1146 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1147 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1148 echo "${cmake_cxx_compiler} has ANSI for scoping"
1149 else
1150 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1151 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1154 # When bootstrapping on MinGW with MSYS we must convert the source
1155 # directory to a windows path.
1156 if ${cmake_system_mingw}; then
1157 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1158 else
1159 cmake_root_dir="${cmake_source_dir}"
1162 # Write CMake version
1163 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1164 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1165 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1166 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1167 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1168 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1170 # Regenerate real cmConfigure.h
1171 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1172 rm -f cmConfigure.h.tmp
1173 else
1174 mv -f cmConfigure.h.tmp cmConfigure.h
1177 # Prepare KWSYS
1178 cmake_kwsys_config_replace_string \
1179 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1180 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1181 "${cmake_compiler_settings_comment}"
1182 cmake_kwsys_config_replace_string \
1183 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1184 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1185 "${cmake_compiler_settings_comment}"
1187 cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
1188 /* Minimal DateStamp header for CMake bootstrap build. */
1189 #ifndef cmsys_DateStamp_h
1190 #define cmsys_DateStamp_h
1191 #define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
1192 #endif
1195 for a in ${KWSYS_FILES}; do
1196 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1197 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1198 done
1200 for a in ${KWSYS_IOS_FILES}; do
1201 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1202 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1203 done
1205 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1206 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1208 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1209 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1211 for a in string vector map; do
1212 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1213 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1214 done
1216 # Generate Makefile
1217 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1218 objs=""
1219 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1220 objs="${objs} ${a}.o"
1221 done
1223 # Generate dependencies for cmBootstrapCommands.cxx
1224 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1225 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1226 done
1227 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1229 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1230 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1233 if [ "x${cmake_c_flags}" != "x" ]; then
1234 cmake_c_flags="${cmake_c_flags} "
1237 if [ "x${cmake_cxx_flags}" != "x" ]; then
1238 cmake_cxx_flags="${cmake_cxx_flags} "
1241 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1242 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1243 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1244 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1245 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1246 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1247 for a in ${CMAKE_CXX_SOURCES}; do
1248 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1249 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1250 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1251 done
1252 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1253 for a in ${CMAKE_C_SOURCES}; do
1254 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1255 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1256 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1257 done
1258 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1259 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1260 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1261 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1262 done
1263 for a in ${KWSYS_CXX_SOURCES}; do
1264 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1265 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1266 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1267 done
1268 if ${cmake_system_mingw}; then
1269 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1270 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1271 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1272 a="cmsysProcessFwd9xEnc"
1273 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1274 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1275 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1276 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1277 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1278 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1279 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1280 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"
1282 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1283 rebuild_cache:
1284 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1287 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1288 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1289 # Generated by ${cmake_source_dir}/bootstrap
1290 # Default cmake settings. These may be overridden any settings below.
1291 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1292 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1293 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1294 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1297 # Add user-specified settings. Handle relative-path case for
1298 # specification of cmake_init_file.
1300 cd "${cmake_binary_dir}"
1301 if [ -f "${cmake_init_file}" ]; then
1302 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1306 echo "---------------------------------------------"
1308 # Run make to build bootstrap cmake
1309 if [ "x${cmake_parallel_make}" != "x" ]; then
1310 ${cmake_make_processor} ${cmake_make_flags}
1311 else
1312 ${cmake_make_processor}
1314 RES=$?
1315 if [ "${RES}" -ne "0" ]; then
1316 cmake_error 9 "Problem while running ${cmake_make_processor}"
1318 cd "${cmake_binary_dir}"
1320 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1321 # build with same compiler and make
1322 CC="${cmake_c_compiler}"
1323 CXX="${cmake_cxx_compiler}"
1324 MAKE="${cmake_make_processor}"
1325 export CC
1326 export CXX
1327 export MAKE
1329 # Run bootstrap CMake to configure real CMake
1330 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1331 RES=$?
1332 if [ "${RES}" -ne "0" ]; then
1333 cmake_error 11 "Problem while running initial CMake"
1336 echo "---------------------------------------------"
1338 # And we are done. Now just run make
1339 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."