Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / bootstrap
blob36d9751a9aee73dd59265e1f6868a3b206690245
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2009-03-16 14:40:46 $
9 # Version: $Revision: 1.117 $
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 if echo "${cmake_version_minor}" | grep "[0-9]*[13579]" > /dev/null 2>&1; then
44 cmake_version_patch="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
45 else
46 cmake_version_patch="`cmake_version_component PATCH`"
48 cmake_version="${cmake_version_major}.${cmake_version_minor}"
49 cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
50 cmake_data_dir="/share/cmake-${cmake_version}"
51 cmake_doc_dir="/doc/cmake-${cmake_version}"
52 cmake_man_dir="/man"
53 cmake_init_file=""
54 cmake_bootstrap_system_libs=""
55 cmake_bootstrap_qt_gui=""
56 cmake_bootstrap_qt_qmake=""
58 # Determine whether this is a MinGW environment.
59 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
60 cmake_system_mingw=true
61 else
62 cmake_system_mingw=false
65 # Determine whether this is OS X
66 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
67 cmake_system_darwin=true
68 else
69 cmake_system_darwin=false
72 # Determine whether this is BeOS
73 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
74 cmake_system_beos=true
75 else
76 cmake_system_beos=false
79 # Determine whether this is Haiku
80 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
81 cmake_system_haiku=true
82 else
83 cmake_system_haiku=false
86 # Choose the generator to use for bootstrapping.
87 if ${cmake_system_mingw}; then
88 # Bootstrapping from an MSYS prompt.
89 cmake_bootstrap_generator="MSYS Makefiles"
90 else
91 # Bootstrapping from a standard UNIX prompt.
92 cmake_bootstrap_generator="Unix Makefiles"
95 # Helper function to fix windows paths.
96 cmake_fix_slashes ()
98 echo "$1" | sed 's/\\/\//g'
101 # Choose the default install prefix.
102 if ${cmake_system_mingw}; then
103 if [ "x${PROGRAMFILES}" != "x" ]; then
104 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
105 elif [ "x${ProgramFiles}" != "x" ]; then
106 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
107 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
108 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
109 elif [ "x${SystemDrive}" != "x" ]; then
110 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
111 else
112 cmake_default_prefix="c:/Program Files/CMake"
114 else
115 cmake_default_prefix="/usr/local"
118 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
119 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
120 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
122 CMAKE_PROBLEMATIC_FILES="\
123 CMakeCache.txt \
124 CMakeSystem.cmake \
125 CMakeCCompiler.cmake \
126 CMakeCXXCompiler.cmake \
127 Source/cmConfigure.h \
128 Source/CTest/Curl/config.h \
129 Utilities/cmexpat/expatConfig.h \
130 Utilities/cmexpat/expatDllConfig.h \
133 CMAKE_UNUSED_SOURCES="\
134 cmGlobalXCodeGenerator \
135 cmLocalXCodeGenerator \
136 cmXCodeObject \
137 cmXCode21Object \
138 cmSourceGroup \
141 CMAKE_CXX_SOURCES="\
142 cmake \
143 cmakemain \
144 cmakewizard \
145 cmCommandArgumentLexer \
146 cmCommandArgumentParser \
147 cmCommandArgumentParserHelper \
148 cmDepends \
149 cmDependsC \
150 cmDocumentationFormatter \
151 cmDocumentationFormatterText \
152 cmPolicies \
153 cmProperty \
154 cmPropertyMap \
155 cmPropertyDefinition \
156 cmPropertyDefinitionMap \
157 cmMakeDepend \
158 cmMakefile \
159 cmExportFileGenerator \
160 cmExportInstallFileGenerator \
161 cmInstallDirectoryGenerator \
162 cmGeneratedFileStream \
163 cmGlobalGenerator \
164 cmLocalGenerator \
165 cmInstallGenerator \
166 cmInstallExportGenerator \
167 cmInstallFilesGenerator \
168 cmInstallScriptGenerator \
169 cmInstallTargetGenerator \
170 cmScriptGenerator \
171 cmSourceFile \
172 cmSourceFileLocation \
173 cmSystemTools \
174 cmTestGenerator \
175 cmVersion \
176 cmFileTimeComparison \
177 cmGlobalUnixMakefileGenerator3 \
178 cmLocalUnixMakefileGenerator3 \
179 cmMakefileExecutableTargetGenerator \
180 cmMakefileLibraryTargetGenerator \
181 cmMakefileTargetGenerator \
182 cmMakefileUtilityTargetGenerator \
183 cmBootstrapCommands \
184 cmCommands \
185 cmTarget \
186 cmTest \
187 cmCustomCommand \
188 cmDocumentVariables \
189 cmCacheManager \
190 cmListFileCache \
191 cmComputeLinkDepends \
192 cmComputeLinkInformation \
193 cmOrderDirectories \
194 cmComputeTargetDepends \
195 cmComputeComponentGraph \
196 cmExprLexer \
197 cmExprParser \
198 cmExprParserHelper \
201 if ${cmake_system_mingw}; then
202 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
203 cmGlobalMSYSMakefileGenerator \
204 cmGlobalMinGWMakefileGenerator \
205 cmWin32ProcessExecution"
208 CMAKE_C_SOURCES="\
209 cmListFileLexer \
212 if ${cmake_system_mingw}; then
213 KWSYS_C_SOURCES="\
214 ProcessWin32 \
215 String \
216 System"
217 KWSYS_C_MINGW_SOURCES="\
218 ProcessFwd9x \
219 EncodeExecutable"
220 KWSYS_C_GENERATED_SOURCES="\
221 cmsysProcessFwd9xEnc"
222 else
223 KWSYS_C_SOURCES="\
224 ProcessUNIX \
225 String \
226 System"
227 KWSYS_C_MINGW_SOURCES=""
228 KWSYS_C_GENERATED_SOURCES=""
231 KWSYS_CXX_SOURCES="\
232 Directory \
233 Glob \
234 RegularExpression \
235 SystemTools"
237 KWSYS_FILES="\
238 auto_ptr.hxx \
239 Directory.hxx \
240 Glob.hxx \
241 Process.h \
242 RegularExpression.hxx \
243 String.h \
244 String.hxx \
245 System.h \
246 SystemTools.hxx"
248 KWSYS_IOS_FILES="
249 fstream \
250 iosfwd \
251 iostream \
252 sstream"
254 # Display CMake bootstrap usage
255 cmake_usage()
257 cat <<EOF
258 Usage: $0 [options]
259 Options: [defaults in brackets after descriptions]
260 Configuration:
261 --help print this message
262 --version only print version information
263 --verbose display more information
264 --parallel=n bootstrap cmake in parallel, where n is
265 number of nodes [1]
266 --init=FILE use FILE for cmake initialization
267 --system-libs use system-installed third-party libraries
268 (for use only by package maintainers)
269 --no-system-libs use cmake-provided third-party libraries
270 (default)
271 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
272 --no-qt-gui do not build the Qt-based GUI (default)
273 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
275 Directory and file names:
276 --prefix=PREFIX install files in tree rooted at PREFIX
277 [${cmake_default_prefix}]
278 --datadir=DIR install data files in PREFIX/DIR
279 [/share/CMake]
280 --docdir=DIR install documentation files in PREFIX/DIR
281 [/doc/CMake]
282 --mandir=DIR install man pages files in PREFIX/DIR/manN
283 [/man]
285 exit 10
288 # Display CMake bootstrap usage
289 cmake_version_display()
291 echo "CMake ${cmake_version_full}, Copyright (c) 2000-2009 Kitware, Inc., Insight Consortium"
294 # Display CMake bootstrap error, display the log file and exit
295 cmake_error()
297 res=$1
298 shift 1
299 echo "---------------------------------------------"
300 echo "Error when bootstrapping CMake:"
301 echo "$*"
302 echo "---------------------------------------------"
303 if [ -f cmake_bootstrap.log ]; then
304 echo "Log of errors: `pwd`/cmake_bootstrap.log"
305 #cat cmake_bootstrap.log
306 echo "---------------------------------------------"
308 exit ${res}
311 # Replace KWSYS_NAMESPACE with cmsys
312 cmake_replace_string ()
314 INFILE="$1"
315 OUTFILE="$2"
316 SEARCHFOR="$3"
317 REPLACEWITH="$4"
318 if [ -f "${INFILE}" ]; then
319 cat "${INFILE}" |
320 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
321 if [ -f "${OUTFILE}.tmp" ]; then
322 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
323 #echo "Files are the same"
324 rm -f "${OUTFILE}.tmp"
325 else
326 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
329 else
330 cmake_error 1 "Cannot find file ${INFILE}"
334 cmake_kwsys_config_replace_string ()
336 INFILE="$1"
337 OUTFILE="$2"
338 shift 2
339 APPEND="$*"
340 if [ -f "${INFILE}" ]; then
341 echo "${APPEND}" > "${OUTFILE}.tmp"
342 cat "${INFILE}" |
343 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
344 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
345 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
346 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
347 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
348 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
349 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
350 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
351 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
352 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
353 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
354 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
355 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
356 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
357 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
358 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
359 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
360 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
361 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
362 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
363 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
364 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
365 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
366 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
367 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
368 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
369 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
370 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
371 if [ -f "${OUTFILE}.tmp" ]; then
372 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
373 #echo "Files are the same"
374 rm -f "${OUTFILE}.tmp"
375 else
376 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
379 else
380 cmake_error 2 "Cannot find file ${INFILE}"
383 # Write string into a file
384 cmake_report ()
386 FILE=$1
387 shift
388 echo "$*" >> ${FILE}
391 # Escape spaces in strings
392 cmake_escape ()
394 echo $1 | sed "s/ /\\\\ /g"
397 # Write message to the log
398 cmake_log ()
400 echo "$*" >> cmake_bootstrap.log
403 # Return temp file
404 cmake_tmp_file ()
406 echo "cmake_bootstrap_$$.test"
409 # Run a compiler test. First argument is compiler, second one are compiler
410 # flags, third one is test source file to be compiled
411 cmake_try_run ()
413 COMPILER=$1
414 FLAGS=$2
415 TESTFILE=$3
416 if [ ! -f "${TESTFILE}" ]; then
417 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
418 exit 4
420 TMPFILE=`cmake_tmp_file`
421 echo "Try: ${COMPILER}"
422 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
423 echo "---------- file -----------------------"
424 cat "${TESTFILE}"
425 echo "------------------------------------------"
426 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
427 RES=$?
428 if [ "${RES}" -ne "0" ]; then
429 echo "Test failed to compile"
430 return 1
432 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
433 echo "Test failed to produce executable"
434 return 2
436 ./${TMPFILE}
437 RES=$?
438 rm -f "${TMPFILE}"
439 if [ "${RES}" -ne "0" ]; then
440 echo "Test produced non-zero return code"
441 return 3
443 echo "Test succeded"
444 return 0
447 # Run a make test. First argument is the make interpreter.
448 cmake_try_make ()
450 MAKE_PROC="$1"
451 MAKE_FLAGS="$2"
452 echo "Try: ${MAKE_PROC}"
453 "${MAKE_PROC}" ${MAKE_FLAGS}
454 RES=$?
455 if [ "${RES}" -ne "0" ]; then
456 echo "${MAKE_PROC} does not work"
457 return 1
459 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
460 echo "${COMPILER} does not produce output"
461 return 2
463 ./test
464 RES=$?
465 rm -f "test"
466 if [ "${RES}" -ne "0" ]; then
467 echo "${MAKE_PROC} produces strange executable"
468 return 3
470 echo "${MAKE_PROC} works"
471 return 0
474 # Parse arguments
475 cmake_verbose=
476 cmake_parallel_make=
477 cmake_prefix_dir="${cmake_default_prefix}"
478 for a in "$@"; do
479 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
480 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
481 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
483 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
484 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
486 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
487 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
489 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
490 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
492 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
493 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
495 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
496 cmake_init_file=`echo $a | sed "s/^--init=//"`
498 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
499 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
501 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
502 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
504 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
505 cmake_bootstrap_qt_gui="1"
507 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
508 cmake_bootstrap_qt_gui="0"
510 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
511 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
513 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
514 cmake_usage
516 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
517 cmake_version_display
518 exit 2
520 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
521 cmake_verbose=TRUE
523 done
525 # If verbose, display some information about bootstrap
526 if [ -n "${cmake_verbose}" ]; then
527 echo "---------------------------------------------"
528 echo "Source directory: ${cmake_source_dir}"
529 echo "Binary directory: ${cmake_binary_dir}"
530 echo "Prefix directory: ${cmake_prefix_dir}"
531 echo "System: ${cmake_system}"
532 if [ "x${cmake_parallel_make}" != "x" ]; then
533 echo "Doing parallel make: ${cmake_parallel_make}"
535 echo ""
538 echo "---------------------------------------------"
539 # Get CMake version
540 echo "`cmake_version_display`"
542 # Check for in-source build
543 cmake_in_source_build=
544 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
545 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
546 if [ -n "${cmake_verbose}" ]; then
547 echo "Warning: This is an in-source build"
549 cmake_in_source_build=TRUE
552 # If this is not an in-source build, then Bootstrap stuff should not exist.
553 if [ -z "${cmake_in_source_build}" ]; then
554 # Did somebody bootstrap in the source tree?
555 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
556 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
557 Looks like somebody did bootstrap CMake in the source tree, but now you are
558 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
559 directory from the source tree."
561 # Is there a cache in the source tree?
562 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
563 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
564 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
565 Looks like somebody tried to build CMake in the source tree, but now you are
566 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
567 from the source tree."
569 done
572 # Make bootstrap directory
573 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
574 if [ ! -d "${cmake_bootstrap_dir}" ]; then
575 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
577 cd "${cmake_bootstrap_dir}"
579 [ -d "cmsys" ] || mkdir "cmsys"
580 if [ ! -d "cmsys" ]; then
581 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
584 for a in stl ios; do
585 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
586 if [ ! -d "cmsys/${a}" ]; then
587 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
589 done
591 # Delete all the bootstrap files
592 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
593 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
594 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h.tmp"
596 # If exist compiler flags, set them
597 cmake_c_flags=${CFLAGS}
598 cmake_cxx_flags=${CXXFLAGS}
599 cmake_ld_flags=${LDFLAGS}
601 # Add Carbon framework on Darwin
602 if ${cmake_system_darwin}; then
603 cmake_ld_flags="${LDFLAGS} -framework Carbon"
606 # Add BeOS toolkits...
607 if ${cmake_system_beos}; then
608 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
611 # Add Haiku toolkits...
612 if ${cmake_system_haiku}; then
613 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
616 # Test C compiler
617 cmake_c_compiler=
619 # If CC is set, use that for compiler, otherwise use list of known compilers
620 if [ -n "${CC}" ]; then
621 cmake_c_compilers="${CC}"
622 else
623 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
626 # Check if C compiler works
627 TMPFILE=`cmake_tmp_file`
628 cat > "${TMPFILE}.c" <<EOF
629 #ifdef __cplusplus
630 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
631 #endif
633 #include<stdio.h>
635 #if defined(__CLASSIC_C__)
636 int main(argc, argv)
637 int argc;
638 char* argv[];
639 #else
640 int main(int argc, char* argv[])
641 #endif
643 printf("%d\n", (argv != 0));
644 return argc-1;
647 for a in ${cmake_c_compilers}; do
648 if [ -z "${cmake_c_compiler}" ] && \
649 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
650 cmake_c_compiler="${a}"
652 done
653 rm -f "${TMPFILE}.c"
655 if [ -z "${cmake_c_compiler}" ]; then
656 cmake_error 6 "Cannot find appropriate C compiler on this system.
657 Please specify one using environment variable CC.
658 See cmake_bootstrap.log for compilers attempted.
661 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
663 # Test CXX compiler
664 cmake_cxx_compiler=
666 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
668 # If CC is set, use that for compiler, otherwise use list of known compilers
669 if [ -n "${CXX}" ]; then
670 cmake_cxx_compilers="${CXX}"
671 else
672 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
675 # Check if C++ compiler works
676 TMPFILE=`cmake_tmp_file`
677 cat > "${TMPFILE}.cxx" <<EOF
678 #if defined(TEST1)
679 # include <iostream>
680 #else
681 # include <iostream.h>
682 #endif
684 class NeedCXX
686 public:
687 NeedCXX() { this->Foo = 1; }
688 int GetFoo() { return this->Foo; }
689 private:
690 int Foo;
692 int main()
694 NeedCXX c;
695 #ifdef TEST3
696 cout << c.GetFoo() << endl;
697 #else
698 std::cout << c.GetFoo() << std::endl;
699 #endif
700 return 0;
703 for a in ${cmake_cxx_compilers}; do
704 for b in 1 2 3; do
705 if [ -z "${cmake_cxx_compiler}" ] && \
706 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
707 cmake_cxx_compiler="${a}"
709 done
710 done
711 rm -f "${TMPFILE}.cxx"
713 if [ -z "${cmake_cxx_compiler}" ]; then
714 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
715 Please specify one using environment variable CXX.
716 See cmake_bootstrap.log for compilers attempted."
718 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
720 # Test Make
722 cmake_make_processor=
723 cmake_make_flags=
725 # If MAKE is set, use that for make processor, otherwise use list of known make
726 if [ -n "${MAKE}" ]; then
727 cmake_make_processors="${MAKE}"
728 else
729 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
732 TMPFILE="`cmake_tmp_file`_dir"
733 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
734 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
735 cd "${cmake_bootstrap_dir}/${TMPFILE}"
736 cat>"Makefile"<<EOF
737 test: test.c
738 "${cmake_c_compiler}" -o test test.c
740 cat>"test.c"<<EOF
741 #include <stdio.h>
742 int main(){ printf("1\n"); return 0; }
744 cmake_original_make_flags="${cmake_make_flags}"
745 if [ "x${cmake_parallel_make}" != "x" ]; then
746 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
748 for a in ${cmake_make_processors}; do
749 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
750 cmake_make_processor="${a}"
752 done
753 cmake_full_make_flags="${cmake_make_flags}"
754 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
755 if [ -z "${cmake_make_processor}" ]; then
756 cmake_make_flags="${cmake_original_make_flags}"
757 for a in ${cmake_make_processors}; do
758 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
759 cmake_make_processor="${a}"
761 done
764 cd "${cmake_bootstrap_dir}"
765 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
767 if [ -z "${cmake_make_processor}" ]; then
768 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
769 Please specify one using environment variable MAKE."
771 echo "Makefile processor on this system is: ${cmake_make_processor}"
772 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
773 echo "---------------------------------------------"
774 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
775 echo "---------------------------------------------"
778 # Ok, we have CC, CXX, and MAKE.
780 # Test C++ compiler features
782 # Are we GCC?
784 TMPFILE=`cmake_tmp_file`
785 cat > ${TMPFILE}.cxx <<EOF
786 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
787 #include <iostream>
788 int main() { std::cout << "This is GNU" << std::endl; return 0;}
789 #endif
791 cmake_cxx_compiler_is_gnu=0
792 if cmake_try_run "${cmake_cxx_compiler}" \
793 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
794 cmake_cxx_compiler_is_gnu=1
796 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
797 echo "${cmake_cxx_compiler} is GNU compiler"
798 else
799 echo "${cmake_cxx_compiler} is not GNU compiler"
801 rm -f "${TMPFILE}.cxx"
803 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
804 # Check for non-GNU compiler flags
806 # If we are on IRIX, check for -LANG:std
807 cmake_test_flags="-LANG:std"
808 if [ "x${cmake_system}" = "xIRIX64" ]; then
809 TMPFILE=`cmake_tmp_file`
810 cat > ${TMPFILE}.cxx <<EOF
811 #include <iostream>
812 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
814 cmake_need_lang_std=0
815 if cmake_try_run "${cmake_cxx_compiler}" \
816 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
818 else
819 if cmake_try_run "${cmake_cxx_compiler}" \
820 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
821 cmake_need_lang_std=1
824 if [ "x${cmake_need_lang_std}" = "x1" ]; then
825 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
826 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
827 else
828 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
830 rm -f "${TMPFILE}.cxx"
832 cmake_test_flags=
834 # If we are on OSF, check for -timplicit_local -no_implicit_include
835 cmake_test_flags="-timplicit_local -no_implicit_include"
836 if [ "x${cmake_system}" = "xOSF1" ]; then
837 TMPFILE=`cmake_tmp_file`
838 cat > ${TMPFILE}.cxx <<EOF
839 #include <iostream>
840 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
842 cmake_need_flags=1
843 if cmake_try_run "${cmake_cxx_compiler}" \
844 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
846 else
847 cmake_need_flags=0
849 if [ "x${cmake_need_flags}" = "x1" ]; then
850 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
851 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
852 else
853 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
855 rm -f "${TMPFILE}.cxx"
857 cmake_test_flags=
859 # If we are on OSF, check for -std strict_ansi -nopure_cname
860 cmake_test_flags="-std strict_ansi -nopure_cname"
861 if [ "x${cmake_system}" = "xOSF1" ]; then
862 TMPFILE=`cmake_tmp_file`
863 cat > ${TMPFILE}.cxx <<EOF
864 #include <iostream>
865 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
867 cmake_need_flags=1
868 if cmake_try_run "${cmake_cxx_compiler}" \
869 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
871 else
872 cmake_need_flags=0
874 if [ "x${cmake_need_flags}" = "x1" ]; then
875 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
876 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
877 else
878 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
880 rm -f "${TMPFILE}.cxx"
882 cmake_test_flags=
884 # If we are on HP-UX, check for -Ae for the C compiler.
885 cmake_test_flags="-Ae"
886 if [ "x${cmake_system}" = "xHP-UX" ]; then
887 TMPFILE=`cmake_tmp_file`
888 cat > ${TMPFILE}.c <<EOF
889 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
891 cmake_need_Ae=0
892 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
894 else
895 if cmake_try_run "${cmake_c_compiler}" \
896 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
897 cmake_need_Ae=1
900 if [ "x${cmake_need_Ae}" = "x1" ]; then
901 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
902 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
903 else
904 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
906 rm -f "${TMPFILE}.c"
908 cmake_test_flags=
911 # Test for kwsys features
912 KWSYS_NAME_IS_KWSYS=0
913 KWSYS_BUILD_SHARED=0
914 KWSYS_LFS_AVAILABLE=0
915 KWSYS_LFS_REQUESTED=0
916 KWSYS_IOS_USE_STRSTREAM_H=0
917 KWSYS_IOS_USE_STRSTREA_H=0
918 KWSYS_IOS_HAVE_STD=0
919 KWSYS_IOS_USE_SSTREAM=0
920 KWSYS_IOS_USE_ANSI=0
921 KWSYS_STL_HAVE_STD=0
922 KWSYS_STAT_HAS_ST_MTIM=0
923 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
924 KWSYS_STL_HAS_ITERATOR_TRAITS=0
925 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
926 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
927 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
928 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
929 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
930 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
931 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
932 KWSYS_CXX_HAS_CSTDDEF=0
933 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
934 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
935 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
936 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
938 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
939 KWSYS_STL_STRING_HAVE_ISTREAM=1
940 KWSYS_STL_STRING_HAVE_OSTREAM=1
942 if cmake_try_run "${cmake_cxx_compiler}" \
943 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
944 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
945 KWSYS_STL_HAVE_STD=1
946 echo "${cmake_cxx_compiler} has STL in std:: namespace"
947 else
948 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
951 if cmake_try_run "${cmake_cxx_compiler}" \
952 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
953 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
954 KWSYS_IOS_USE_ANSI=1
955 echo "${cmake_cxx_compiler} has ANSI streams"
956 else
957 echo "${cmake_cxx_compiler} does not have ANSI streams"
960 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
961 if cmake_try_run "${cmake_cxx_compiler}" \
962 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
963 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
964 KWSYS_IOS_HAVE_STD=1
965 echo "${cmake_cxx_compiler} has streams in std:: namespace"
966 else
967 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
969 if cmake_try_run "${cmake_cxx_compiler}" \
970 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
971 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
972 KWSYS_IOS_USE_SSTREAM=1
973 echo "${cmake_cxx_compiler} has sstream"
974 else
975 echo "${cmake_cxx_compiler} does not have sstream"
979 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
980 if cmake_try_run "${cmake_cxx_compiler}" \
981 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
982 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
983 KWSYS_IOS_USE_STRSTREAM_H=1
984 echo "${cmake_cxx_compiler} has strstream.h"
985 else
986 echo "${cmake_cxx_compiler} does not have strstream.h"
988 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
989 if cmake_try_run "${cmake_cxx_compiler}" \
990 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
991 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
992 KWSYS_IOS_USE_STRSTREA_H=1
993 echo "${cmake_cxx_compiler} has strstrea.h"
994 else
995 echo "${cmake_cxx_compiler} does not have strstrea.h"
1000 if cmake_try_run "${cmake_cxx_compiler}" \
1001 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1002 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1003 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1004 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1005 else
1006 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1009 if cmake_try_run "${cmake_cxx_compiler}" \
1010 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1011 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1012 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1013 echo "${cmake_cxx_compiler} has stl iterator_traits"
1014 else
1015 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1018 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1019 if cmake_try_run "${cmake_cxx_compiler}" \
1020 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1021 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1022 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1023 echo "${cmake_cxx_compiler} has old iterator_category"
1024 else
1025 echo "${cmake_cxx_compiler} does not have old iterator_category"
1027 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1028 if cmake_try_run "${cmake_cxx_compiler}" \
1029 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1030 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1031 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1032 echo "${cmake_cxx_compiler} has old __iterator_category"
1033 else
1034 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1039 if cmake_try_run "${cmake_cxx_compiler}" \
1040 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -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_TEMPLATE=1
1043 echo "${cmake_cxx_compiler} has standard template allocator"
1044 else
1045 echo "${cmake_cxx_compiler} does not have standard template allocator"
1048 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1049 if cmake_try_run "${cmake_cxx_compiler}" \
1050 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1051 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1052 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1053 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1054 else
1055 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1058 if cmake_try_run "${cmake_cxx_compiler}" \
1059 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1060 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1061 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1062 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1063 else
1064 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1066 else
1067 if cmake_try_run "${cmake_cxx_compiler}" \
1068 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1069 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1070 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1071 echo "${cmake_cxx_compiler} has old non-template allocator"
1072 else
1073 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1077 if cmake_try_run "${cmake_cxx_compiler}" \
1078 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1079 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1080 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1081 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1082 else
1083 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1086 if cmake_try_run "${cmake_cxx_compiler}" \
1087 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1088 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1089 KWSYS_CXX_HAS_CSTDDEF=1
1090 echo "${cmake_cxx_compiler} has header cstddef"
1091 else
1092 echo "${cmake_cxx_compiler} does not have header cstddef"
1095 if cmake_try_run "${cmake_cxx_compiler}" \
1096 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1097 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1098 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1099 else
1100 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1101 echo "${cmake_cxx_compiler} requires template friends to use <>"
1104 if cmake_try_run "${cmake_cxx_compiler}" \
1105 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1106 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1107 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1108 echo "${cmake_cxx_compiler} supports member templates"
1109 else
1110 echo "${cmake_cxx_compiler} does not support member templates"
1113 if cmake_try_run "${cmake_cxx_compiler}" \
1114 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1115 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1116 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1117 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1118 else
1119 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1122 if cmake_try_run "${cmake_cxx_compiler}" \
1123 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1124 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1125 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1126 echo "${cmake_cxx_compiler} has argument dependent lookup"
1127 else
1128 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1131 if cmake_try_run "${cmake_cxx_compiler}" \
1132 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1133 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1134 KWSYS_STAT_HAS_ST_MTIM=1
1135 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1136 else
1137 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1140 # Just to be safe, let us store compiler and flags to the header file
1142 cmake_bootstrap_version='$Revision: 1.117 $'
1143 cmake_compiler_settings_comment="/*
1144 * Generated by ${cmake_source_dir}/bootstrap
1145 * Version: ${cmake_bootstrap_version}
1147 * Source directory: ${cmake_source_dir}
1148 * Binary directory: ${cmake_bootstrap_dir}
1150 * C compiler: ${cmake_c_compiler}
1151 * C flags: ${cmake_c_flags}
1153 * C++ compiler: ${cmake_cxx_compiler}
1154 * C++ flags: ${cmake_cxx_flags}
1156 * Make: ${cmake_make_processor}
1158 * Sources:
1159 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1160 * kwSys Sources:
1161 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1165 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1167 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1168 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1169 else
1170 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1173 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1174 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1175 else
1176 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1179 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1180 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1181 else
1182 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1185 # Test for ansi FOR scope
1186 if cmake_try_run "${cmake_cxx_compiler}" \
1187 "${cmake_cxx_flags}" \
1188 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1189 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1190 echo "${cmake_cxx_compiler} has ANSI for scoping"
1191 else
1192 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1193 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1196 # When bootstrapping on MinGW with MSYS we must convert the source
1197 # directory to a windows path.
1198 if ${cmake_system_mingw}; then
1199 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1200 else
1201 cmake_root_dir="${cmake_source_dir}"
1204 # Write CMake version
1205 cmake_report cmVersionConfig.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1206 cmake_report cmVersionConfig.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1207 cmake_report cmVersionConfig.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1208 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1209 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1210 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1212 # Regenerate configured headers
1213 for h in Configure VersionConfig; do
1214 if diff cm${h}.h cm${h}.h.tmp > /dev/null 2> /dev/null; then
1215 rm -f cm${h}.h.tmp
1216 else
1217 mv -f cm${h}.h.tmp cm${h}.h
1219 done
1221 # Prepare KWSYS
1222 cmake_kwsys_config_replace_string \
1223 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1224 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1225 "${cmake_compiler_settings_comment}"
1226 cmake_kwsys_config_replace_string \
1227 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1228 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1229 "${cmake_compiler_settings_comment}"
1231 for a in ${KWSYS_FILES}; do
1232 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1233 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1234 done
1236 for a in ${KWSYS_IOS_FILES}; do
1237 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1238 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1239 done
1241 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1242 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1244 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1245 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1247 for a in string vector map algorithm; do
1248 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1249 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1250 done
1252 # Generate Makefile
1253 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1254 objs=""
1255 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1256 objs="${objs} ${a}.o"
1257 done
1259 # Generate dependencies for cmBootstrapCommands.cxx
1260 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1261 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1262 done
1263 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1265 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1266 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1269 if [ "x${cmake_c_flags}" != "x" ]; then
1270 cmake_c_flags="${cmake_c_flags} "
1273 if [ "x${cmake_cxx_flags}" != "x" ]; then
1274 cmake_cxx_flags="${cmake_cxx_flags} "
1277 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1278 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1279 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1280 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1281 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1282 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1283 for a in ${CMAKE_CXX_SOURCES}; do
1284 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1285 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1286 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1287 done
1288 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1289 for a in ${CMAKE_C_SOURCES}; do
1290 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1291 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1292 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1293 done
1294 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1295 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1296 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1297 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1298 done
1299 for a in ${KWSYS_CXX_SOURCES}; do
1300 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1301 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1302 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1303 done
1304 if ${cmake_system_mingw}; then
1305 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1306 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1307 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1308 a="cmsysProcessFwd9xEnc"
1309 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1310 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1311 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1312 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1313 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1314 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1315 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1316 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"
1318 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1319 rebuild_cache:
1320 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1323 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1324 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1325 # Generated by ${cmake_source_dir}/bootstrap
1326 # Default cmake settings. These may be overridden any settings below.
1327 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1328 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1329 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1330 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1333 # Add configuration settings given as command-line options.
1334 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1335 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1336 SET (BUILD_QtDialog ${cmake_bootstrap_qt_gui} CACHE BOOL "Build Qt dialog for CMake" FORCE)
1339 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1340 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1341 SET (QT_QMAKE_EXECUTABLE "${cmake_bootstrap_qt_qmake}" CACHE FILEPATH "Location of Qt qmake" FORCE)
1345 # Add user-specified settings. Handle relative-path case for
1346 # specification of cmake_init_file.
1348 cd "${cmake_binary_dir}"
1349 if [ -f "${cmake_init_file}" ]; then
1350 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1354 echo "---------------------------------------------"
1356 # Run make to build bootstrap cmake
1357 if [ "x${cmake_parallel_make}" != "x" ]; then
1358 ${cmake_make_processor} ${cmake_make_flags}
1359 else
1360 ${cmake_make_processor}
1362 RES=$?
1363 if [ "${RES}" -ne "0" ]; then
1364 cmake_error 9 "Problem while running ${cmake_make_processor}"
1366 cd "${cmake_binary_dir}"
1368 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1369 # build with same compiler and make
1370 CC="${cmake_c_compiler}"
1371 CXX="${cmake_cxx_compiler}"
1372 MAKE="${cmake_make_processor}"
1373 export CC
1374 export CXX
1375 export MAKE
1377 # Run bootstrap CMake to configure real CMake
1378 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1379 RES=$?
1380 if [ "${RES}" -ne "0" ]; then
1381 cmake_error 11 "Problem while running initial CMake"
1384 echo "---------------------------------------------"
1386 # And we are done. Now just run make
1387 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."