ENH: for some reasons there was never a FindCVS module?
[cmake.git] / bootstrap
blob5da59a763e09ecd0f12f660830a58a23cbc8e530
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2008-03-07 21:26:29 $
9 # Version: $Revision: 1.113 $
11 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
12 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
14 # This software is distributed WITHOUT ANY WARRANTY; without even
15 # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 # PURPOSE. See the above copyright notices for more information.
18 #=========================================================================
20 # Version number extraction function.
21 cmake_version_component()
23 cat "${cmake_source_dir}/CMakeLists.txt" | sed -n "
24 /^SET(CMake_VERSION_${1}/ {s/SET(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
28 cmake_date_stamp_component()
30 cat "${cmake_source_dir}/Source/kwsys/kwsysDateStamp.cmake" | sed -n "
31 /KWSYS_DATE_STAMP_${1}/ {s/^.* \([0-9][0-9]*\))$/\1/;p;}
35 # Detect system and directory information.
36 cmake_system=`uname`
37 cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
38 cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
39 cmake_binary_dir=`pwd`
40 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
41 cmake_version_major="`cmake_version_component MAJOR`"
42 cmake_version_minor="`cmake_version_component MINOR`"
43 cmake_version_patch="`cmake_version_component PATCH`"
44 cmake_version="${cmake_version_major}.${cmake_version_minor}"
45 cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
46 cmake_date_stamp="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
47 cmake_data_dir="/share/cmake-${cmake_version}"
48 cmake_doc_dir="/doc/cmake-${cmake_version}"
49 cmake_man_dir="/man"
50 cmake_init_file=""
51 cmake_bootstrap_system_libs=""
52 cmake_bootstrap_qt_gui=""
53 cmake_bootstrap_qt_qmake=""
55 # Determine whether this is a MinGW environment.
56 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
57 cmake_system_mingw=true
58 else
59 cmake_system_mingw=false
62 # Determine whether this is OS X
63 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
64 cmake_system_darwin=true
65 else
66 cmake_system_darwin=false
69 # Determine whether this is BeOS
70 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
71 cmake_system_beos=true
72 else
73 cmake_system_beos=false
76 # Choose the generator to use for bootstrapping.
77 if ${cmake_system_mingw}; then
78 # Bootstrapping from an MSYS prompt.
79 cmake_bootstrap_generator="MSYS Makefiles"
80 else
81 # Bootstrapping from a standard UNIX prompt.
82 cmake_bootstrap_generator="Unix Makefiles"
85 # Helper function to fix windows paths.
86 cmake_fix_slashes ()
88 echo "$1" | sed 's/\\/\//g'
91 # Choose the default install prefix.
92 if ${cmake_system_mingw}; then
93 if [ "x${PROGRAMFILES}" != "x" ]; then
94 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
95 elif [ "x${ProgramFiles}" != "x" ]; then
96 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
97 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
98 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
99 elif [ "x${SystemDrive}" != "x" ]; then
100 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
101 else
102 cmake_default_prefix="c:/Program Files/CMake"
104 else
105 cmake_default_prefix="/usr/local"
108 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
109 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
110 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
112 CMAKE_PROBLEMATIC_FILES="\
113 CMakeCache.txt \
114 CMakeSystem.cmake \
115 CMakeCCompiler.cmake \
116 CMakeCXXCompiler.cmake \
117 Source/cmConfigure.h \
118 Source/CTest/Curl/config.h \
119 Utilities/cmexpat/expatConfig.h \
120 Utilities/cmexpat/expatDllConfig.h \
123 CMAKE_UNUSED_SOURCES="\
124 cmGlobalXCodeGenerator \
125 cmLocalXCodeGenerator \
126 cmXCodeObject \
127 cmXCode21Object \
128 cmSourceGroup \
131 CMAKE_CXX_SOURCES="\
132 cmake \
133 cmakemain \
134 cmakewizard \
135 cmCommandArgumentLexer \
136 cmCommandArgumentParser \
137 cmCommandArgumentParserHelper \
138 cmDepends \
139 cmDependsC \
140 cmDocumentationFormatter \
141 cmDocumentationFormatterText \
142 cmPolicies \
143 cmProperty \
144 cmPropertyMap \
145 cmPropertyDefinition \
146 cmPropertyDefinitionMap \
147 cmMakeDepend \
148 cmMakefile \
149 cmExportFileGenerator \
150 cmExportInstallFileGenerator \
151 cmInstallDirectoryGenerator \
152 cmGeneratedFileStream \
153 cmGlobalGenerator \
154 cmLocalGenerator \
155 cmInstallGenerator \
156 cmInstallExportGenerator \
157 cmInstallFilesGenerator \
158 cmInstallScriptGenerator \
159 cmInstallTargetGenerator \
160 cmSourceFile \
161 cmSourceFileLocation \
162 cmSystemTools \
163 cmVersion \
164 cmFileTimeComparison \
165 cmGlobalUnixMakefileGenerator3 \
166 cmLocalUnixMakefileGenerator3 \
167 cmMakefileExecutableTargetGenerator \
168 cmMakefileLibraryTargetGenerator \
169 cmMakefileTargetGenerator \
170 cmMakefileUtilityTargetGenerator \
171 cmBootstrapCommands \
172 cmCommands \
173 cmTarget \
174 cmTest \
175 cmCustomCommand \
176 cmDocumentVariables \
177 cmCacheManager \
178 cmListFileCache \
179 cmComputeLinkDepends \
180 cmComputeLinkInformation \
181 cmOrderDirectories \
182 cmComputeTargetDepends \
183 cmComputeComponentGraph \
184 cmExprLexer \
185 cmExprParser \
186 cmExprParserHelper \
189 if ${cmake_system_mingw}; then
190 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
191 cmGlobalMSYSMakefileGenerator \
192 cmGlobalMinGWMakefileGenerator \
193 cmWin32ProcessExecution"
196 CMAKE_C_SOURCES="\
197 cmListFileLexer \
200 if ${cmake_system_mingw}; then
201 KWSYS_C_SOURCES="\
202 ProcessWin32 \
203 String \
204 System"
205 KWSYS_C_MINGW_SOURCES="\
206 ProcessFwd9x \
207 EncodeExecutable"
208 KWSYS_C_GENERATED_SOURCES="\
209 cmsysProcessFwd9xEnc"
210 else
211 KWSYS_C_SOURCES="\
212 ProcessUNIX \
213 String \
214 System"
215 KWSYS_C_MINGW_SOURCES=""
216 KWSYS_C_GENERATED_SOURCES=""
219 KWSYS_CXX_SOURCES="\
220 Directory \
221 Glob \
222 RegularExpression \
223 SystemTools"
225 KWSYS_FILES="\
226 auto_ptr.hxx \
227 Directory.hxx \
228 Glob.hxx \
229 Process.h \
230 RegularExpression.hxx \
231 String.h \
232 String.hxx \
233 System.h \
234 SystemTools.hxx"
236 KWSYS_IOS_FILES="
237 fstream \
238 iosfwd \
239 iostream \
240 sstream"
242 # Display CMake bootstrap usage
243 cmake_usage()
245 cat <<EOF
246 Usage: $0 [options]
247 Options: [defaults in brackets after descriptions]
248 Configuration:
249 --help print this message
250 --version only print version information
251 --verbose display more information
252 --parallel=n bootstrap cmake in parallel, where n is
253 number of nodes [1]
254 --init=FILE use FILE for cmake initialization
255 --system-libs use system-installed third-party libraries
256 (for use only by package maintainers)
257 --no-system-libs use cmake-provided third-party libraries
258 (default)
259 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
260 --no-qt-gui do not build the Qt-based GUI (default)
261 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
263 Directory and file names:
264 --prefix=PREFIX install files in tree rooted at PREFIX
265 [${cmake_default_prefix}]
266 --datadir=DIR install data files in PREFIX/DIR
267 [/share/CMake]
268 --docdir=DIR install documentation files in PREFIX/DIR
269 [/doc/CMake]
270 --mandir=DIR install man pages files in PREFIX/DIR/manN
271 [/man]
273 exit 10
276 # Display CMake bootstrap usage
277 cmake_version_display()
280 # Get CMake version
281 if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
282 version="${cmake_version}-${cmake_date_stamp}"
283 else
284 version="${cmake_version}-${cmake_version_patch}"
286 echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
290 # Display CMake bootstrap error, display the log file and exit
291 cmake_error()
293 res=$1
294 shift 1
295 echo "---------------------------------------------"
296 echo "Error when bootstrapping CMake:"
297 echo "$*"
298 echo "---------------------------------------------"
299 if [ -f cmake_bootstrap.log ]; then
300 echo "Log of errors: `pwd`/cmake_bootstrap.log"
301 #cat cmake_bootstrap.log
302 echo "---------------------------------------------"
304 exit ${res}
307 # Replace KWSYS_NAMESPACE with cmsys
308 cmake_replace_string ()
310 INFILE="$1"
311 OUTFILE="$2"
312 SEARCHFOR="$3"
313 REPLACEWITH="$4"
314 if [ -f "${INFILE}" ]; then
315 cat "${INFILE}" |
316 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
317 if [ -f "${OUTFILE}.tmp" ]; then
318 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
319 #echo "Files are the same"
320 rm -f "${OUTFILE}.tmp"
321 else
322 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
325 else
326 cmake_error 1 "Cannot find file ${INFILE}"
330 cmake_kwsys_config_replace_string ()
332 INFILE="$1"
333 OUTFILE="$2"
334 shift 2
335 APPEND="$*"
336 if [ -f "${INFILE}" ]; then
337 echo "${APPEND}" > "${OUTFILE}.tmp"
338 cat "${INFILE}" |
339 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
340 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
341 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
342 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
343 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
344 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
345 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
346 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
347 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
348 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
349 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
350 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
351 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
352 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
353 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
354 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
355 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
356 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
357 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
358 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
359 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
360 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
361 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
362 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
363 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
364 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
365 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
366 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
367 if [ -f "${OUTFILE}.tmp" ]; then
368 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
369 #echo "Files are the same"
370 rm -f "${OUTFILE}.tmp"
371 else
372 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
375 else
376 cmake_error 2 "Cannot find file ${INFILE}"
379 # Write string into a file
380 cmake_report ()
382 FILE=$1
383 shift
384 echo "$*" >> ${FILE}
387 # Escape spaces in strings
388 cmake_escape ()
390 echo $1 | sed "s/ /\\\\ /g"
393 # Write message to the log
394 cmake_log ()
396 echo "$*" >> cmake_bootstrap.log
399 # Return temp file
400 cmake_tmp_file ()
402 echo "cmake_bootstrap_$$.test"
405 # Run a compiler test. First argument is compiler, second one are compiler
406 # flags, third one is test source file to be compiled
407 cmake_try_run ()
409 COMPILER=$1
410 FLAGS=$2
411 TESTFILE=$3
412 if [ ! -f "${TESTFILE}" ]; then
413 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
414 exit 4
416 TMPFILE=`cmake_tmp_file`
417 echo "Try: ${COMPILER}"
418 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
419 echo "---------- file -----------------------"
420 cat "${TESTFILE}"
421 echo "------------------------------------------"
422 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
423 RES=$?
424 if [ "${RES}" -ne "0" ]; then
425 echo "Test failed to compile"
426 return 1
428 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
429 echo "Test failed to produce executable"
430 return 2
432 ./${TMPFILE}
433 RES=$?
434 rm -f "${TMPFILE}"
435 if [ "${RES}" -ne "0" ]; then
436 echo "Test produced non-zero return code"
437 return 3
439 echo "Test succeded"
440 return 0
443 # Run a make test. First argument is the make interpreter.
444 cmake_try_make ()
446 MAKE_PROC="$1"
447 MAKE_FLAGS="$2"
448 echo "Try: ${MAKE_PROC}"
449 "${MAKE_PROC}" ${MAKE_FLAGS}
450 RES=$?
451 if [ "${RES}" -ne "0" ]; then
452 echo "${MAKE_PROC} does not work"
453 return 1
455 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
456 echo "${COMPILER} does not produce output"
457 return 2
459 ./test
460 RES=$?
461 rm -f "test"
462 if [ "${RES}" -ne "0" ]; then
463 echo "${MAKE_PROC} produces strange executable"
464 return 3
466 echo "${MAKE_PROC} works"
467 return 0
470 # Parse arguments
471 cmake_verbose=
472 cmake_parallel_make=
473 cmake_prefix_dir="${cmake_default_prefix}"
474 for a in "$@"; do
475 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
476 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
477 cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"`
479 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
480 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
482 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
483 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
485 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
486 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
488 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
489 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
491 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
492 cmake_init_file=`echo $a | sed "s/^--init=//"`
494 if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then
495 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1"
497 if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
498 cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
500 if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
501 cmake_bootstrap_qt_gui="1"
503 if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
504 cmake_bootstrap_qt_gui="0"
506 if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
507 cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
509 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
510 cmake_usage
512 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
513 cmake_version_display
514 exit 2
516 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
517 cmake_verbose=TRUE
519 done
521 # If verbose, display some information about bootstrap
522 if [ -n "${cmake_verbose}" ]; then
523 echo "---------------------------------------------"
524 echo "Source directory: ${cmake_source_dir}"
525 echo "Binary directory: ${cmake_binary_dir}"
526 echo "Prefix directory: ${cmake_prefix_dir}"
527 echo "System: ${cmake_system}"
528 if [ "x${cmake_parallel_make}" != "x" ]; then
529 echo "Doing parallel make: ${cmake_parallel_make}"
531 echo ""
534 echo "---------------------------------------------"
535 # Get CMake version
536 echo "`cmake_version_display`"
538 # Check for in-source build
539 cmake_in_source_build=
540 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
541 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
542 if [ -n "${cmake_verbose}" ]; then
543 echo "Warning: This is an in-source build"
545 cmake_in_source_build=TRUE
548 # If this is not an in-source build, then Bootstrap stuff should not exist.
549 if [ -z "${cmake_in_source_build}" ]; then
550 # Did somebody bootstrap in the source tree?
551 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
552 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
553 Looks like somebody did bootstrap CMake in the source tree, but now you are
554 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
555 directory from the source tree."
557 # Is there a cache in the source tree?
558 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
559 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
560 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
561 Looks like somebody tried to build CMake in the source tree, but now you are
562 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
563 from the source tree."
565 done
568 # Make bootstrap directory
569 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
570 if [ ! -d "${cmake_bootstrap_dir}" ]; then
571 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
573 cd "${cmake_bootstrap_dir}"
575 [ -d "cmsys" ] || mkdir "cmsys"
576 if [ ! -d "cmsys" ]; then
577 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
580 for a in stl ios; do
581 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
582 if [ ! -d "cmsys/${a}" ]; then
583 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
585 done
587 # Delete all the bootstrap files
588 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
589 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
591 # If exist compiler flags, set them
592 cmake_c_flags=${CFLAGS}
593 cmake_cxx_flags=${CXXFLAGS}
594 cmake_ld_flags=${LDFLAGS}
596 # Add Carbon framework on Darwin
597 if ${cmake_system_darwin}; then
598 cmake_ld_flags="${LDFLAGS} -framework Carbon"
601 # Add BeOS toolkits...
602 if ${cmake_system_beos}; then
603 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
606 # Test C compiler
607 cmake_c_compiler=
609 # If CC is set, use that for compiler, otherwise use list of known compilers
610 if [ -n "${CC}" ]; then
611 cmake_c_compilers="${CC}"
612 else
613 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
616 # Check if C compiler works
617 TMPFILE=`cmake_tmp_file`
618 cat > "${TMPFILE}.c" <<EOF
619 #ifdef __cplusplus
620 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
621 #endif
623 #include<stdio.h>
625 #if defined(__CLASSIC_C__)
626 int main(argc, argv)
627 int argc;
628 char* argv[];
629 #else
630 int main(int argc, char* argv[])
631 #endif
633 printf("%d\n", (argv != 0));
634 return argc-1;
637 for a in ${cmake_c_compilers}; do
638 if [ -z "${cmake_c_compiler}" ] && \
639 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
640 cmake_c_compiler="${a}"
642 done
643 rm -f "${TMPFILE}.c"
645 if [ -z "${cmake_c_compiler}" ]; then
646 cmake_error 6 "Cannot find appropriate C compiler on this system.
647 Please specify one using environment variable CC.
648 See cmake_bootstrap.log for compilers attempted.
651 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
653 # Test CXX compiler
654 cmake_cxx_compiler=
656 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
658 # If CC is set, use that for compiler, otherwise use list of known compilers
659 if [ -n "${CXX}" ]; then
660 cmake_cxx_compilers="${CXX}"
661 else
662 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
665 # Check if C++ compiler works
666 TMPFILE=`cmake_tmp_file`
667 cat > "${TMPFILE}.cxx" <<EOF
668 #if defined(TEST1)
669 # include <iostream>
670 #else
671 # include <iostream.h>
672 #endif
674 class NeedCXX
676 public:
677 NeedCXX() { this->Foo = 1; }
678 int GetFoo() { return this->Foo; }
679 private:
680 int Foo;
682 int main()
684 NeedCXX c;
685 #ifdef TEST3
686 cout << c.GetFoo() << endl;
687 #else
688 std::cout << c.GetFoo() << std::endl;
689 #endif
690 return 0;
693 for a in ${cmake_cxx_compilers}; do
694 for b in 1 2 3; do
695 if [ -z "${cmake_cxx_compiler}" ] && \
696 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
697 cmake_cxx_compiler="${a}"
699 done
700 done
701 rm -f "${TMPFILE}.cxx"
703 if [ -z "${cmake_cxx_compiler}" ]; then
704 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
705 Please specify one using environment variable CXX.
706 See cmake_bootstrap.log for compilers attempted."
708 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
710 # Test Make
712 cmake_make_processor=
713 cmake_make_flags=
715 # If MAKE is set, use that for make processor, otherwise use list of known make
716 if [ -n "${MAKE}" ]; then
717 cmake_make_processors="${MAKE}"
718 else
719 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
722 TMPFILE="`cmake_tmp_file`_dir"
723 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
724 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
725 cd "${cmake_bootstrap_dir}/${TMPFILE}"
726 cat>"Makefile"<<EOF
727 test: test.c
728 "${cmake_c_compiler}" -o test test.c
730 cat>"test.c"<<EOF
731 #include <stdio.h>
732 int main(){ printf("1\n"); return 0; }
734 cmake_original_make_flags="${cmake_make_flags}"
735 if [ "x${cmake_parallel_make}" != "x" ]; then
736 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
738 for a in ${cmake_make_processors}; do
739 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
740 cmake_make_processor="${a}"
742 done
743 cmake_full_make_flags="${cmake_make_flags}"
744 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
745 if [ -z "${cmake_make_processor}" ]; then
746 cmake_make_flags="${cmake_original_make_flags}"
747 for a in ${cmake_make_processors}; do
748 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
749 cmake_make_processor="${a}"
751 done
754 cd "${cmake_bootstrap_dir}"
755 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
757 if [ -z "${cmake_make_processor}" ]; then
758 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
759 Please specify one using environment variable MAKE."
761 echo "Makefile processor on this system is: ${cmake_make_processor}"
762 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
763 echo "---------------------------------------------"
764 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
765 echo "---------------------------------------------"
768 # Ok, we have CC, CXX, and MAKE.
770 # Test C++ compiler features
772 # Are we GCC?
774 TMPFILE=`cmake_tmp_file`
775 cat > ${TMPFILE}.cxx <<EOF
776 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
777 #include <iostream>
778 int main() { std::cout << "This is GNU" << std::endl; return 0;}
779 #endif
781 cmake_cxx_compiler_is_gnu=0
782 if cmake_try_run "${cmake_cxx_compiler}" \
783 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
784 cmake_cxx_compiler_is_gnu=1
786 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
787 echo "${cmake_cxx_compiler} is GNU compiler"
788 else
789 echo "${cmake_cxx_compiler} is not GNU compiler"
791 rm -f "${TMPFILE}.cxx"
793 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
794 # Check for non-GNU compiler flags
796 # If we are on IRIX, check for -LANG:std
797 cmake_test_flags="-LANG:std"
798 if [ "x${cmake_system}" = "xIRIX64" ]; then
799 TMPFILE=`cmake_tmp_file`
800 cat > ${TMPFILE}.cxx <<EOF
801 #include <iostream>
802 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
804 cmake_need_lang_std=0
805 if cmake_try_run "${cmake_cxx_compiler}" \
806 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
808 else
809 if cmake_try_run "${cmake_cxx_compiler}" \
810 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
811 cmake_need_lang_std=1
814 if [ "x${cmake_need_lang_std}" = "x1" ]; then
815 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
816 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
817 else
818 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
820 rm -f "${TMPFILE}.cxx"
822 cmake_test_flags=
824 # If we are on OSF, check for -timplicit_local -no_implicit_include
825 cmake_test_flags="-timplicit_local -no_implicit_include"
826 if [ "x${cmake_system}" = "xOSF1" ]; then
827 TMPFILE=`cmake_tmp_file`
828 cat > ${TMPFILE}.cxx <<EOF
829 #include <iostream>
830 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
832 cmake_need_flags=1
833 if cmake_try_run "${cmake_cxx_compiler}" \
834 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
836 else
837 cmake_need_flags=0
839 if [ "x${cmake_need_flags}" = "x1" ]; then
840 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
841 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
842 else
843 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
845 rm -f "${TMPFILE}.cxx"
847 cmake_test_flags=
849 # If we are on OSF, check for -std strict_ansi -nopure_cname
850 cmake_test_flags="-std strict_ansi -nopure_cname"
851 if [ "x${cmake_system}" = "xOSF1" ]; then
852 TMPFILE=`cmake_tmp_file`
853 cat > ${TMPFILE}.cxx <<EOF
854 #include <iostream>
855 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
857 cmake_need_flags=1
858 if cmake_try_run "${cmake_cxx_compiler}" \
859 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
861 else
862 cmake_need_flags=0
864 if [ "x${cmake_need_flags}" = "x1" ]; then
865 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
866 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
867 else
868 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
870 rm -f "${TMPFILE}.cxx"
872 cmake_test_flags=
874 # If we are on HP-UX, check for -Ae for the C compiler.
875 cmake_test_flags="-Ae"
876 if [ "x${cmake_system}" = "xHP-UX" ]; then
877 TMPFILE=`cmake_tmp_file`
878 cat > ${TMPFILE}.c <<EOF
879 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
881 cmake_need_Ae=0
882 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
884 else
885 if cmake_try_run "${cmake_c_compiler}" \
886 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
887 cmake_need_Ae=1
890 if [ "x${cmake_need_Ae}" = "x1" ]; then
891 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
892 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
893 else
894 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
896 rm -f "${TMPFILE}.c"
898 cmake_test_flags=
901 # Test for kwsys features
902 KWSYS_NAME_IS_KWSYS=0
903 KWSYS_BUILD_SHARED=0
904 KWSYS_LFS_AVAILABLE=0
905 KWSYS_LFS_REQUESTED=0
906 KWSYS_IOS_USE_STRSTREAM_H=0
907 KWSYS_IOS_USE_STRSTREA_H=0
908 KWSYS_IOS_HAVE_STD=0
909 KWSYS_IOS_USE_SSTREAM=0
910 KWSYS_IOS_USE_ANSI=0
911 KWSYS_STL_HAVE_STD=0
912 KWSYS_STAT_HAS_ST_MTIM=0
913 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
914 KWSYS_STL_HAS_ITERATOR_TRAITS=0
915 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
916 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
917 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
918 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
919 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
920 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
921 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
922 KWSYS_CXX_HAS_CSTDDEF=0
923 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
924 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
925 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
926 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
928 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
929 KWSYS_STL_STRING_HAVE_ISTREAM=1
930 KWSYS_STL_STRING_HAVE_OSTREAM=1
932 if cmake_try_run "${cmake_cxx_compiler}" \
933 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
934 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
935 KWSYS_STL_HAVE_STD=1
936 echo "${cmake_cxx_compiler} has STL in std:: namespace"
937 else
938 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
941 if cmake_try_run "${cmake_cxx_compiler}" \
942 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
943 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
944 KWSYS_IOS_USE_ANSI=1
945 echo "${cmake_cxx_compiler} has ANSI streams"
946 else
947 echo "${cmake_cxx_compiler} does not have ANSI streams"
950 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
951 if cmake_try_run "${cmake_cxx_compiler}" \
952 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
953 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
954 KWSYS_IOS_HAVE_STD=1
955 echo "${cmake_cxx_compiler} has streams in std:: namespace"
956 else
957 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
959 if cmake_try_run "${cmake_cxx_compiler}" \
960 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
961 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
962 KWSYS_IOS_USE_SSTREAM=1
963 echo "${cmake_cxx_compiler} has sstream"
964 else
965 echo "${cmake_cxx_compiler} does not have sstream"
969 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
970 if cmake_try_run "${cmake_cxx_compiler}" \
971 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
972 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
973 KWSYS_IOS_USE_STRSTREAM_H=1
974 echo "${cmake_cxx_compiler} has strstream.h"
975 else
976 echo "${cmake_cxx_compiler} does not have strstream.h"
978 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
979 if cmake_try_run "${cmake_cxx_compiler}" \
980 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
981 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
982 KWSYS_IOS_USE_STRSTREA_H=1
983 echo "${cmake_cxx_compiler} has strstrea.h"
984 else
985 echo "${cmake_cxx_compiler} does not have strstrea.h"
990 if cmake_try_run "${cmake_cxx_compiler}" \
991 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
992 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
993 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
994 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
995 else
996 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
999 if cmake_try_run "${cmake_cxx_compiler}" \
1000 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1001 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1002 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1003 echo "${cmake_cxx_compiler} has stl iterator_traits"
1004 else
1005 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1008 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1009 if cmake_try_run "${cmake_cxx_compiler}" \
1010 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -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_CATEGORY=1
1013 echo "${cmake_cxx_compiler} has old iterator_category"
1014 else
1015 echo "${cmake_cxx_compiler} does not have old iterator_category"
1017 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1018 if cmake_try_run "${cmake_cxx_compiler}" \
1019 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1020 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1021 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1022 echo "${cmake_cxx_compiler} has old __iterator_category"
1023 else
1024 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1029 if cmake_try_run "${cmake_cxx_compiler}" \
1030 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1031 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1032 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1033 echo "${cmake_cxx_compiler} has standard template allocator"
1034 else
1035 echo "${cmake_cxx_compiler} does not have standard template allocator"
1038 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1039 if cmake_try_run "${cmake_cxx_compiler}" \
1040 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -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_REBIND=1
1043 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1044 else
1045 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1048 if cmake_try_run "${cmake_cxx_compiler}" \
1049 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1050 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1051 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1052 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1053 else
1054 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1056 else
1057 if cmake_try_run "${cmake_cxx_compiler}" \
1058 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1059 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1060 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1061 echo "${cmake_cxx_compiler} has old non-template allocator"
1062 else
1063 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1067 if cmake_try_run "${cmake_cxx_compiler}" \
1068 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -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_OBJECTS=1
1071 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1072 else
1073 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1076 if cmake_try_run "${cmake_cxx_compiler}" \
1077 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1078 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1079 KWSYS_CXX_HAS_CSTDDEF=1
1080 echo "${cmake_cxx_compiler} has header cstddef"
1081 else
1082 echo "${cmake_cxx_compiler} does not have header cstddef"
1085 if cmake_try_run "${cmake_cxx_compiler}" \
1086 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1087 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1088 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1089 else
1090 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1091 echo "${cmake_cxx_compiler} requires template friends to use <>"
1094 if cmake_try_run "${cmake_cxx_compiler}" \
1095 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1096 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1097 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1098 echo "${cmake_cxx_compiler} supports member templates"
1099 else
1100 echo "${cmake_cxx_compiler} does not support member templates"
1103 if cmake_try_run "${cmake_cxx_compiler}" \
1104 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1105 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1106 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1107 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1108 else
1109 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1112 if cmake_try_run "${cmake_cxx_compiler}" \
1113 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1114 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1115 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1116 echo "${cmake_cxx_compiler} has argument dependent lookup"
1117 else
1118 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1121 if cmake_try_run "${cmake_cxx_compiler}" \
1122 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1123 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1124 KWSYS_STAT_HAS_ST_MTIM=1
1125 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1126 else
1127 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1130 # Just to be safe, let us store compiler and flags to the header file
1132 cmake_bootstrap_version='$Revision: 1.113 $'
1133 cmake_compiler_settings_comment="/*
1134 * Generated by ${cmake_source_dir}/bootstrap
1135 * Version: ${cmake_bootstrap_version}
1137 * Source directory: ${cmake_source_dir}
1138 * Binary directory: ${cmake_bootstrap_dir}
1140 * C compiler: ${cmake_c_compiler}
1141 * C flags: ${cmake_c_flags}
1143 * C++ compiler: ${cmake_cxx_compiler}
1144 * C++ flags: ${cmake_cxx_flags}
1146 * Make: ${cmake_make_processor}
1148 * Sources:
1149 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1150 * kwSys Sources:
1151 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}
1155 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
1157 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1158 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
1159 else
1160 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
1163 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1164 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1165 else
1166 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1169 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1170 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1171 else
1172 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1175 # Test for ansi FOR scope
1176 if cmake_try_run "${cmake_cxx_compiler}" \
1177 "${cmake_cxx_flags}" \
1178 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1179 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1180 echo "${cmake_cxx_compiler} has ANSI for scoping"
1181 else
1182 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1183 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1186 # When bootstrapping on MinGW with MSYS we must convert the source
1187 # directory to a windows path.
1188 if ${cmake_system_mingw}; then
1189 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1190 else
1191 cmake_root_dir="${cmake_source_dir}"
1194 # Write CMake version
1195 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1196 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1197 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1198 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1199 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1200 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1202 # Regenerate real cmConfigure.h
1203 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1204 rm -f cmConfigure.h.tmp
1205 else
1206 mv -f cmConfigure.h.tmp cmConfigure.h
1209 # Prepare KWSYS
1210 cmake_kwsys_config_replace_string \
1211 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1212 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1213 "${cmake_compiler_settings_comment}"
1214 cmake_kwsys_config_replace_string \
1215 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1216 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1217 "${cmake_compiler_settings_comment}"
1219 cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
1220 /* Minimal DateStamp header for CMake bootstrap build. */
1221 #ifndef cmsys_DateStamp_h
1222 #define cmsys_DateStamp_h
1223 #define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
1224 #endif
1227 for a in ${KWSYS_FILES}; do
1228 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1229 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1230 done
1232 for a in ${KWSYS_IOS_FILES}; do
1233 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1234 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1235 done
1237 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1238 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1240 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1241 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1243 for a in string vector map algorithm; do
1244 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1245 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1246 done
1248 # Generate Makefile
1249 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1250 objs=""
1251 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do
1252 objs="${objs} ${a}.o"
1253 done
1255 # Generate dependencies for cmBootstrapCommands.cxx
1256 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1257 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1258 done
1259 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1261 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1262 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1265 if [ "x${cmake_c_flags}" != "x" ]; then
1266 cmake_c_flags="${cmake_c_flags} "
1269 if [ "x${cmake_cxx_flags}" != "x" ]; then
1270 cmake_cxx_flags="${cmake_cxx_flags} "
1273 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1274 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1275 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1276 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1277 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1278 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1279 for a in ${CMAKE_CXX_SOURCES}; do
1280 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1281 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1282 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1283 done
1284 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1285 for a in ${CMAKE_C_SOURCES}; do
1286 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1287 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1288 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1289 done
1290 for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
1291 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1292 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1293 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1294 done
1295 for a in ${KWSYS_CXX_SOURCES}; do
1296 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1297 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1298 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1299 done
1300 if ${cmake_system_mingw}; then
1301 src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"`
1302 in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"`
1303 cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"`
1304 a="cmsysProcessFwd9xEnc"
1305 echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile"
1306 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile"
1307 echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile"
1308 echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1309 echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile"
1310 echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile"
1311 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1312 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"
1314 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1315 rebuild_cache:
1316 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1319 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1320 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1321 # Generated by ${cmake_source_dir}/bootstrap
1322 # Default cmake settings. These may be overridden any settings below.
1323 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1324 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1325 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1326 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1329 # Add configuration settings given as command-line options.
1330 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1331 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1332 SET (BUILD_QtDialog ${cmake_bootstrap_qt_gui} CACHE BOOL "Build Qt dialog for CMake" FORCE)
1335 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1336 cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1337 SET (QT_QMAKE_EXECUTABLE "${cmake_bootstrap_qt_qmake}" CACHE FILEPATH "Location of Qt qmake" FORCE)
1341 # Add user-specified settings. Handle relative-path case for
1342 # specification of cmake_init_file.
1344 cd "${cmake_binary_dir}"
1345 if [ -f "${cmake_init_file}" ]; then
1346 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1350 echo "---------------------------------------------"
1352 # Run make to build bootstrap cmake
1353 if [ "x${cmake_parallel_make}" != "x" ]; then
1354 ${cmake_make_processor} ${cmake_make_flags}
1355 else
1356 ${cmake_make_processor}
1358 RES=$?
1359 if [ "${RES}" -ne "0" ]; then
1360 cmake_error 9 "Problem while running ${cmake_make_processor}"
1362 cd "${cmake_binary_dir}"
1364 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1365 # build with same compiler and make
1366 CC="${cmake_c_compiler}"
1367 CXX="${cmake_cxx_compiler}"
1368 MAKE="${cmake_make_processor}"
1369 export CC
1370 export CXX
1371 export MAKE
1373 # Run bootstrap CMake to configure real CMake
1374 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs}
1375 RES=$?
1376 if [ "${RES}" -ne "0" ]; then
1377 cmake_error 11 "Problem while running initial CMake"
1380 echo "---------------------------------------------"
1382 # And we are done. Now just run make
1383 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."