Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / bootstrap
1 #!/bin/sh
2 #=============================================================================
3 # CMake - Cross Platform Makefile Generator
4 # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
5 #
6 # Distributed under the OSI-approved BSD License (the "License");
7 # see accompanying file Copyright.txt for details.
8 #
9 # This software is distributed WITHOUT ANY WARRANTY; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the License for more information.
12 #=============================================================================
13
14 die() {
15   echo "$@" 1>&2 ; exit 1
16 }
17
18 # Version number extraction function.
19 cmake_version_component()
20 {
21   cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
22 /^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
23 "
24 }
25
26 cmake_toupper()
27 {
28     echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
29 }
30
31 # Detect system and directory information.
32 cmake_system=`uname`
33 cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
34 cmake_binary_dir=`pwd`
35
36 # Load version information.
37 cmake_version_major="`cmake_version_component MAJOR`"
38 cmake_version_minor="`cmake_version_component MINOR`"
39 cmake_version_patch="`cmake_version_component PATCH`"
40 cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
41 cmake_version_tweak="`cmake_version_component TWEAK`"
42 if [ "$cmake_version_tweak" != "0" ]; then
43   cmake_version="${cmake_version}.${cmake_version_tweak}"
44 fi
45
46 cmake_data_dir="share/cmake-${cmake_version_major}.${cmake_version_minor}"
47 cmake_doc_dir="doc/cmake-${cmake_version_major}.${cmake_version_minor}"
48 cmake_man_dir="man"
49 cmake_init_file=""
50 cmake_bootstrap_system_libs=""
51 cmake_bootstrap_qt_gui=""
52 cmake_bootstrap_qt_qmake=""
53
54 # Determine whether this is a Cygwin environment.
55 if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
56   cmake_system_cygwin=true
57 else
58   cmake_system_cygwin=false
59 fi
60
61 # Determine whether this is a MinGW environment.
62 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
63   cmake_system_mingw=true
64 else
65   cmake_system_mingw=false
66 fi
67
68 # Determine whether this is OS X
69 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
70   cmake_system_darwin=true
71 else
72   cmake_system_darwin=false
73 fi
74
75 # Determine whether this is BeOS
76 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
77   cmake_system_beos=true
78 else
79   cmake_system_beos=false
80 fi
81
82 # Determine whether this is Haiku
83 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
84   cmake_system_haiku=true
85 else
86   cmake_system_haiku=false
87 fi
88
89 # Determine whether this is OpenVMS
90 if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
91   cmake_system_openvms=true
92 else
93   cmake_system_openvms=false
94 fi
95
96 # Determine whether this is Linux
97 if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
98   cmake_system_linux=true
99   # find out if it is a HP PA-RISC machine
100   if uname -m | grep parisc >/dev/null 2>&1; then
101     cmake_machine_parisc=true
102   else
103     cmake_machine_parisc=false
104   fi
105 else
106   cmake_system_linux=false
107 fi
108
109 # Choose the generator to use for bootstrapping.
110 if ${cmake_system_mingw}; then
111   # Bootstrapping from an MSYS prompt.
112   cmake_bootstrap_generator="MSYS Makefiles"
113 else
114   # Bootstrapping from a standard UNIX prompt.
115   cmake_bootstrap_generator="Unix Makefiles"
116 fi
117
118 # Choose tools and extensions for this platform.
119 if ${cmake_system_openvms}; then
120   _tmp="_tmp"
121   _cmk="_cmk"
122   _diff=`which diff`
123 else
124   _tmp=".tmp"
125   _cmk=".cmk"
126   _diff="diff"
127 fi
128
129 # Construct bootstrap directory name.
130 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
131
132 # Helper function to fix windows paths.
133 case "${cmake_system}" in
134 *MINGW*)
135   cmake_fix_slashes()
136   {
137     cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
138   }
139   ;;
140 *)
141   cmake_fix_slashes()
142   {
143     echo "$1" | sed 's/\\/\//g'
144   }
145   ;;
146 esac
147
148 # Choose the default install prefix.
149 if ${cmake_system_mingw}; then
150   if [ "x${PROGRAMFILES}" != "x" ]; then
151     cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
152   elif [ "x${ProgramFiles}" != "x" ]; then
153     cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
154   elif [ "x${SYSTEMDRIVE}" != "x" ]; then
155     cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
156   elif [ "x${SystemDrive}" != "x" ]; then
157     cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
158   else
159     cmake_default_prefix="c:/Program Files/CMake"
160   fi
161 elif ${cmake_system_haiku}; then
162   cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
163   cmake_man_dir="documentation/man"
164   cmake_doc_dir="documentation/doc/cmake-${cmake_version}"
165 else
166   cmake_default_prefix="/usr/local"
167 fi
168
169 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
170 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
171 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
172
173 CMAKE_PROBLEMATIC_FILES="\
174   CMakeCache.txt \
175   CMakeSystem.cmake \
176   CMakeCCompiler.cmake \
177   CMakeCXXCompiler.cmake \
178   */CMakeSystem.cmake \
179   */CMakeCCompiler.cmake \
180   */CMakeCXXCompiler.cmake \
181   Source/cmConfigure.h \
182   Source/CTest/Curl/config.h \
183   Utilities/cmexpat/expatConfig.h \
184   Utilities/cmexpat/expatDllConfig.h \
185   "
186
187 CMAKE_UNUSED_SOURCES="\
188   cmGlobalXCodeGenerator \
189   cmLocalXCodeGenerator \
190   cmXCodeObject \
191   cmXCode21Object \
192   cmSourceGroup \
193 "
194
195 CMAKE_CXX_SOURCES="\
196   cmStandardIncludes \
197   cmake  \
198   cmakemain \
199   cmakewizard  \
200   cmCommandArgumentLexer \
201   cmCommandArgumentParser \
202   cmCommandArgumentParserHelper \
203   cmDefinitions \
204   cmDepends \
205   cmDependsC \
206   cmDocumentationFormatter \
207   cmDocumentationFormatterText \
208   cmPolicies \
209   cmProperty \
210   cmPropertyMap \
211   cmPropertyDefinition \
212   cmPropertyDefinitionMap \
213   cmMakeDepend \
214   cmMakefile \
215   cmExportFileGenerator \
216   cmExportInstallFileGenerator \
217   cmExportTryCompileFileGenerator \
218   cmExportSet \
219   cmExportSetMap \
220   cmInstallDirectoryGenerator \
221   cmGeneratedFileStream \
222   cmGeneratorTarget \
223   cmGeneratorExpressionDAGChecker \
224   cmGeneratorExpressionEvaluator \
225   cmGeneratorExpressionLexer \
226   cmGeneratorExpressionParser \
227   cmGeneratorExpression \
228   cmGlobalGenerator \
229   cmLocalGenerator \
230   cmInstallGenerator \
231   cmInstallExportGenerator \
232   cmInstallFilesGenerator \
233   cmInstallScriptGenerator \
234   cmInstallTargetGenerator \
235   cmScriptGenerator \
236   cmSourceFile \
237   cmSourceFileLocation \
238   cmSystemTools \
239   cmTestGenerator \
240   cmVersion \
241   cmFileTimeComparison \
242   cmGlobalUnixMakefileGenerator3 \
243   cmLocalUnixMakefileGenerator3 \
244   cmMakefileExecutableTargetGenerator \
245   cmMakefileLibraryTargetGenerator \
246   cmMakefileTargetGenerator \
247   cmMakefileUtilityTargetGenerator \
248   cmOSXBundleGenerator \
249   cmNewLineStyle \
250   cmBootstrapCommands1 \
251   cmBootstrapCommands2 \
252   cmCommands \
253   cmTarget \
254   cmTest \
255   cmCustomCommand \
256   cmCustomCommandGenerator \
257   cmDocumentVariables \
258   cmCacheManager \
259   cmListFileCache \
260   cmComputeLinkDepends \
261   cmComputeLinkInformation \
262   cmOrderDirectories \
263   cmComputeTargetDepends \
264   cmComputeComponentGraph \
265   cmExprLexer \
266   cmExprParser \
267   cmExprParserHelper \
268   cmGlobalNinjaGenerator \
269   cmLocalNinjaGenerator \
270   cmNinjaTargetGenerator \
271   cmNinjaNormalTargetGenerator \
272   cmNinjaUtilityTargetGenerator \
273 "
274
275 if ${cmake_system_mingw}; then
276   CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
277     cmGlobalMSYSMakefileGenerator \
278     cmGlobalMinGWMakefileGenerator \
279     cmWin32ProcessExecution"
280 fi
281
282 CMAKE_C_SOURCES="\
283   cmListFileLexer \
284   "
285
286 if ${cmake_system_mingw}; then
287   KWSYS_C_SOURCES="\
288     ProcessWin32 \
289     String \
290     System"
291 else
292   KWSYS_C_SOURCES="\
293     ProcessUNIX \
294     String \
295     System"
296 fi
297
298 KWSYS_CXX_SOURCES="\
299   Directory \
300   Glob \
301   RegularExpression \
302   SystemTools"
303
304 KWSYS_FILES="\
305   auto_ptr.hxx \
306   Directory.hxx \
307   Glob.hxx \
308   Process.h \
309   RegularExpression.hxx \
310   String.h \
311   String.hxx \
312   System.h \
313   SystemTools.hxx"
314
315 KWSYS_IOS_FILES="
316   fstream \
317   iosfwd \
318   iostream \
319   sstream"
320
321 # Display CMake bootstrap usage
322 cmake_usage()
323 {
324 echo '
325 Usage: '"$0"' [<options>...] [-- <cmake-options>...]
326 Options: [defaults in brackets after descriptions]
327 Configuration:
328   --help                  print this message
329   --version               only print version information
330   --verbose               display more information
331   --parallel=n            bootstrap cmake in parallel, where n is
332                           number of nodes [1]
333   --enable-ccache         Enable ccache when building cmake
334   --init=FILE             load FILE as script to populate cache
335   --system-libs           use all system-installed third-party libraries
336                           (for use only by package maintainers)
337   --no-system-libs        use all cmake-provided third-party libraries
338                           (default)
339   --system-curl           use system-installed curl library
340   --no-system-curl        use cmake-provided curl library (default)
341   --system-expat          use system-installed expat library
342   --no-system-expat       use cmake-provided expat library (default)
343   --system-zlib           use system-installed zlib library
344   --no-system-zlib        use cmake-provided zlib library (default)
345   --system-bzip2          use system-installed bzip2 library
346   --no-system-bzip2       use cmake-provided bzip2 library (default)
347   --system-libarchive     use system-installed libarchive library
348   --no-system-libarchive  use cmake-provided libarchive library (default)
349
350   --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
351   --no-qt-gui             do not build the Qt-based GUI (default)
352   --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt
353
354 Directory and file names:
355   --prefix=PREFIX         install files in tree rooted at PREFIX
356                           ['"${cmake_default_prefix}"']
357   --datadir=DIR           install data files in PREFIX/DIR
358                           ['"${cmake_data_dir}"']
359   --docdir=DIR            install documentation files in PREFIX/DIR
360                           ['"${cmake_doc_dir}"']
361   --mandir=DIR            install man pages files in PREFIX/DIR/manN
362                           ['"${cmake_man_dir}"']
363 '
364   exit 10
365 }
366
367 # Display CMake bootstrap usage
368 cmake_version_display()
369 {
370   echo "CMake ${cmake_version}, Copyright 2000-2012 Kitware, Inc."
371 }
372
373 # Display CMake bootstrap error, display the log file and exit
374 cmake_error()
375 {
376   res=$1
377   shift 1
378   echo "---------------------------------------------"
379   echo "Error when bootstrapping CMake:"
380   echo "$*"
381   echo "---------------------------------------------"
382   if [ -f cmake_bootstrap.log ]; then
383     echo "Log of errors: `pwd`/cmake_bootstrap.log"
384     #cat cmake_bootstrap.log
385     echo "---------------------------------------------"
386   fi
387   exit ${res}
388 }
389
390 # Replace KWSYS_NAMESPACE with cmsys
391 cmake_replace_string ()
392 {
393   INFILE="$1"
394   OUTFILE="$2"
395   SEARCHFOR="$3"
396   REPLACEWITH="$4"
397   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
398     cat "${INFILE}" |
399       sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
400     if [ -f "${OUTFILE}${_tmp}" ]; then
401       if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
402         #echo "Files are the same"
403         rm -f "${OUTFILE}${_tmp}"
404       else
405         mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
406       fi
407     fi
408   else
409     cmake_error 1 "Cannot find file ${INFILE}"
410   fi
411 }
412
413 cmake_kwsys_config_replace_string ()
414 {
415   INFILE="$1"
416   OUTFILE="$2"
417   shift 2
418   APPEND="$*"
419   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
420     echo "${APPEND}" > "${OUTFILE}${_tmp}"
421     cat "${INFILE}" |
422       sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
423                 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
424                 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
425                 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
426                 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
427                 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
428                 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
429                 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
430                 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
431                 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
432                 s/@KWSYS_IOS_HAVE_BINARY@/${KWSYS_IOS_HAVE_BINARY}/g;
433                 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
434                 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
435                 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
436                 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
437                 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
438                 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
439                 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
440                 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
441                 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
442                 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
443                 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
444                 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
445                 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
446                 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
447                 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
448                 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
449                 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
450                 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}"
451     if [ -f "${OUTFILE}${_tmp}" ]; then
452       if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
453         #echo "Files are the same"
454         rm -f "${OUTFILE}${_tmp}"
455       else
456         mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
457       fi
458     fi
459   else
460     cmake_error 2 "Cannot find file ${INFILE}"
461   fi
462 }
463 # Write string into a file
464 cmake_report ()
465 {
466   FILE=$1
467   shift
468   echo "$*" >> ${FILE}
469 }
470
471 # Escape spaces in strings
472 cmake_escape ()
473 {
474   echo $1 | sed "s/ /\\\\ /g"
475 }
476
477 # Strip prefix from argument
478 cmake_arg ()
479 {
480   echo "$1" | sed "s/^${2-[^=]*=}//"
481 }
482
483 # Write message to the log
484 cmake_log ()
485 {
486   echo "$*" >> cmake_bootstrap.log
487 }
488
489 # Return temp file
490 cmake_tmp_file ()
491 {
492   echo "cmake_bootstrap_$$_test"
493 }
494
495 # Run a compiler test. First argument is compiler, second one are compiler
496 # flags, third one is test source file to be compiled
497 cmake_try_run ()
498 {
499   COMPILER=$1
500   FLAGS=$2
501   TESTFILE=$3
502   if [ ! -f "${TESTFILE}" ]; then
503     echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
504     exit 4
505   fi
506   TMPFILE=`cmake_tmp_file`
507   echo "Try: ${COMPILER}"
508   echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
509   echo "----------  file   -----------------------"
510   cat "${TESTFILE}"
511   echo "------------------------------------------"
512   "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
513   RES=$?
514   if [ "${RES}" -ne "0" ]; then
515     echo "Test failed to compile"
516     return 1
517   fi
518   if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
519     echo "Test failed to produce executable"
520     return 2
521   fi
522   ./${TMPFILE}
523   RES=$?
524   rm -f "${TMPFILE}"
525   if [ "${RES}" -ne "0" ]; then
526     echo "Test produced non-zero return code"
527     return 3
528   fi
529   echo "Test succeded"
530   return 0
531 }
532
533 # Run a make test. First argument is the make interpreter.
534 cmake_try_make ()
535 {
536   MAKE_PROC="$1"
537   MAKE_FLAGS="$2"
538   echo "Try: ${MAKE_PROC}"
539   "${MAKE_PROC}" ${MAKE_FLAGS}
540   RES=$?
541   if [ "${RES}" -ne "0" ]; then
542     echo "${MAKE_PROC} does not work"
543     return 1
544   fi
545   if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
546     echo "${COMPILER} does not produce output"
547     return 2
548   fi
549   ./test
550   RES=$?
551   rm -f "test"
552   if [ "${RES}" -ne "0" ]; then
553     echo "${MAKE_PROC} produces strange executable"
554     return 3
555   fi
556   echo "${MAKE_PROC} works"
557   return 0
558 }
559
560 # Parse arguments
561 cmake_verbose=
562 cmake_parallel_make=
563 cmake_ccache_enabled=
564 cmake_prefix_dir="${cmake_default_prefix}"
565 while test $# != 0; do
566   case "$1" in
567   --prefix=*) dir=`cmake_arg "$1"`
568               cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
569   --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
570   --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
571   --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
572   --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
573   --init=*) cmake_init_file=`cmake_arg "$1"` ;;
574   --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
575   --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
576   --system-bzip2|--system-curl|--system-expat|--system-libarchive|--system-zlib)
577     lib=`cmake_arg "$1" "--system-"`
578     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
579   --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-libarchive|--no-system-zlib)
580     lib=`cmake_arg "$1" "--no-system-"`
581     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
582   --qt-gui) cmake_bootstrap_qt_gui="1" ;;
583   --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
584   --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
585   --help) cmake_usage ;;
586   --version) cmake_version_display ; exit 2 ;;
587   --verbose) cmake_verbose=TRUE ;;
588   --enable-ccache) cmake_ccache_enabled=TRUE ;;
589   --) shift; break ;;
590   *) die "Unknown option: $1" ;;
591   esac
592   shift
593 done
594
595 # If verbose, display some information about bootstrap
596 if [ -n "${cmake_verbose}" ]; then
597   echo "---------------------------------------------"
598   echo "Source directory: ${cmake_source_dir}"
599   echo "Binary directory: ${cmake_binary_dir}"
600   echo "Prefix directory: ${cmake_prefix_dir}"
601   echo "System:           ${cmake_system}"
602   if [ "x${cmake_parallel_make}" != "x" ]; then
603     echo "Doing parallel make: ${cmake_parallel_make}"
604   fi
605   echo ""
606 fi
607
608 echo "---------------------------------------------"
609 # Get CMake version
610 echo "`cmake_version_display`"
611
612 # Check for in-source build
613 cmake_in_source_build=
614 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
615      -f "${cmake_binary_dir}/Source/cmake.h" ]; then
616   if [ -n "${cmake_verbose}" ]; then
617     echo "Warning: This is an in-source build"
618   fi
619   cmake_in_source_build=TRUE
620 fi
621
622 # If this is not an in-source build, then Bootstrap stuff should not exist.
623 if [ -z "${cmake_in_source_build}" ]; then
624   # Did somebody bootstrap in the source tree?
625   if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
626     cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
627 Looks like somebody did bootstrap CMake in the source tree, but now you are
628 trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
629 directory from the source tree."
630   fi
631   # Is there a cache in the source tree?
632   for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
633     if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
634       cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
635 Looks like somebody tried to build CMake in the source tree, but now you are
636 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
637 from the source tree."
638     fi
639   done
640 fi
641
642 # Make bootstrap directory
643 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
644 if [ ! -d "${cmake_bootstrap_dir}" ]; then
645   cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
646 fi
647 cd "${cmake_bootstrap_dir}"
648
649 [ -d "cmsys" ] || mkdir "cmsys"
650 if [ ! -d "cmsys" ]; then
651   cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
652 fi
653
654 for a in stl ios; do
655   [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
656   if [ ! -d "cmsys/${a}" ]; then
657     cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
658   fi
659 done
660
661 # Delete all the bootstrap files
662 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
663 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
664 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
665
666 # If exist compiler flags, set them
667 cmake_c_flags=${CFLAGS}
668 cmake_cxx_flags=${CXXFLAGS}
669 cmake_ld_flags=${LDFLAGS}
670
671 # Add Cygwin-specific flags
672 if ${cmake_system_cygwin}; then
673   cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
674 fi
675
676 # Add CoreFoundation framework on Darwin
677 if ${cmake_system_darwin}; then
678   cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
679 fi
680
681 # Add BeOS toolkits...
682 if ${cmake_system_beos}; then
683   cmake_ld_flags="${LDFLAGS} -lroot -lbe"
684 fi
685
686 # Add Haiku toolkits...
687 if ${cmake_system_haiku}; then
688   cmake_ld_flags="${LDFLAGS} -lroot -lbe"
689 fi
690
691 if ${cmake_system_linux}; then
692   # avoid binutils problem with large binaries, e.g. when building CMake in debug mode
693   # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230
694   if ${cmake_machine_parisc}; then
695     # if -O[s23] is given the effect is inverted, so do not use the flag then
696     if [ "`echo "${CXXFLAGS}" | sed -r '/^(.* )?(-O[s234])( .*)?$/s/.*/-Os/'`" != "-Os" ]; then
697       cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text.*"
698     fi
699   fi
700 fi
701
702 #-----------------------------------------------------------------------------
703 # Detect known toolchains on some platforms.
704 cmake_toolchains=''
705 case "${cmake_system}" in
706   *AIX*)   cmake_toolchains='XL GNU' ;;
707   *CYGWIN*) cmake_toolchains='GNU' ;;
708   *Darwin*) cmake_toolchains='GNU Clang' ;;
709   *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
710   *MINGW*) cmake_toolchains='GNU' ;;
711 esac
712
713 # Toolchain compiler name table.
714 cmake_toolchain_Clang_CC='clang'
715 cmake_toolchain_Clang_CXX='clang++'
716 cmake_toolchain_GNU_CC='gcc'
717 cmake_toolchain_GNU_CXX='g++'
718 cmake_toolchain_PGI_CC='pgcc'
719 cmake_toolchain_PGI_CXX='pgCC'
720 cmake_toolchain_PathScale_CC='pathcc'
721 cmake_toolchain_PathScale_CXX='pathCC'
722 cmake_toolchain_XL_CC='xlc'
723 cmake_toolchain_XL_CXX='xlC'
724
725 cmake_toolchain_try()
726 {
727   tc="$1"
728   TMPFILE=`cmake_tmp_file`
729
730   eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
731   echo 'int main() { return 0; }' > "${TMPFILE}.c"
732   cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
733   tc_result_CC="$?"
734   rm -f "${TMPFILE}.c"
735   test "${tc_result_CC}" = "0" || return 1
736
737   eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
738   echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
739   cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
740   tc_result_CXX="$?"
741   rm -f "${TMPFILE}.cpp"
742   test "${tc_result_CXX}" = "0" || return 1
743
744   cmake_toolchain="$tc"
745 }
746
747 cmake_toolchain_detect()
748 {
749   cmake_toolchain=
750   for tc in ${cmake_toolchains}; do
751     echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
752     cmake_toolchain_try "$tc" &&
753     echo "Found $tc toolchain" &&
754     break
755   done
756 }
757
758 if [ -z "${CC}" -a -z "${CXX}" ]; then
759   cmake_toolchain_detect
760 fi
761
762 #-----------------------------------------------------------------------------
763 # Test C compiler
764 cmake_c_compiler=
765
766 # If CC is set, use that for compiler, otherwise use list of known compilers
767 if [ -n "${cmake_toolchain}" ]; then
768   eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
769 elif [ -n "${CC}" ]; then
770   cmake_c_compilers="${CC}"
771 else
772   cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
773 fi
774
775 # Check if C compiler works
776 TMPFILE=`cmake_tmp_file`
777 echo '
778 #ifdef __cplusplus
779 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
780 #endif
781
782 #include<stdio.h>
783
784 #if defined(__CLASSIC_C__)
785 int main(argc, argv)
786   int argc;
787   char* argv[];
788 #else
789 int main(int argc, char* argv[])
790 #endif
791 {
792   printf("%d%c", (argv != 0), (char)0x0a);
793   return argc-1;
794 }
795 ' > "${TMPFILE}.c"
796 for a in ${cmake_c_compilers}; do
797   if [ -z "${cmake_c_compiler}" ] && \
798     cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
799     cmake_c_compiler="${a}"
800   fi
801 done
802 rm -f "${TMPFILE}.c"
803
804 if [ -z "${cmake_c_compiler}" ]; then
805   cmake_error 6 "Cannot find appropriate C compiler on this system.
806 Please specify one using environment variable CC.
807 See cmake_bootstrap.log for compilers attempted.
808 "
809 fi
810 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
811
812 #-----------------------------------------------------------------------------
813 # Test CXX compiler
814 cmake_cxx_compiler=
815
816 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
817
818 # If CC is set, use that for compiler, otherwise use list of known compilers
819 if [ -n "${cmake_toolchain}" ]; then
820   eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
821 elif [ -n "${CXX}" ]; then
822   cmake_cxx_compilers="${CXX}"
823 else
824   cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
825 fi
826
827 # Check if C++ compiler works
828 TMPFILE=`cmake_tmp_file`
829 echo '
830 #if defined(TEST1)
831 # include <iostream>
832 #else
833 # include <iostream.h>
834 #endif
835
836 class NeedCXX
837 {
838 public:
839   NeedCXX() { this->Foo = 1; }
840   int GetFoo() { return this->Foo; }
841 private:
842   int Foo;
843 };
844 int main()
845 {
846   NeedCXX c;
847 #ifdef TEST3
848   cout << c.GetFoo() << endl;
849 #else
850   std::cout << c.GetFoo() << std::endl;
851 #endif
852   return 0;
853 }
854 ' > "${TMPFILE}.cxx"
855 for a in ${cmake_cxx_compilers}; do
856   for b in 1 2 3; do
857     if [ -z "${cmake_cxx_compiler}" ] && \
858       cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
859       cmake_cxx_compiler="${a}"
860     fi
861   done
862 done
863 rm -f "${TMPFILE}.cxx"
864
865 if [ -z "${cmake_cxx_compiler}" ]; then
866   cmake_error 7 "Cannot find appropriate C++ compiler on this system.
867 Please specify one using environment variable CXX.
868 See cmake_bootstrap.log for compilers attempted."
869 fi
870 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
871
872 #-----------------------------------------------------------------------------
873 # Test Make
874
875 cmake_make_processor=
876 cmake_make_flags=
877
878 # If MAKE is set, use that for make processor, otherwise use list of known make
879 if [ -n "${MAKE}" ]; then
880   cmake_make_processors="${MAKE}"
881 else
882   cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
883 fi
884
885 TMPFILE="`cmake_tmp_file`_dir"
886 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
887 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
888 cd "${cmake_bootstrap_dir}/${TMPFILE}"
889 echo '
890 test: test.c
891         "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
892 '>"Makefile"
893 echo '
894 #include <stdio.h>
895 int main(){ printf("1%c", (char)0x0a); return 0; }
896 ' > "test.c"
897 cmake_original_make_flags="${cmake_make_flags}"
898 if [ "x${cmake_parallel_make}" != "x" ]; then
899   cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
900 fi
901 for a in ${cmake_make_processors}; do
902   if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
903     cmake_make_processor="${a}"
904   fi
905 done
906 cmake_full_make_flags="${cmake_make_flags}"
907 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
908   if [ -z "${cmake_make_processor}" ]; then
909     cmake_make_flags="${cmake_original_make_flags}"
910     for a in ${cmake_make_processors}; do
911       if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
912         cmake_make_processor="${a}"
913       fi
914     done
915   fi
916 fi
917 cd "${cmake_bootstrap_dir}"
918
919 if [ -z "${cmake_make_processor}" ]; then
920   cmake_error 8 "Cannot find appropriate Makefile processor on this system.
921 Please specify one using environment variable MAKE."
922 fi
923 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
924 echo "Makefile processor on this system is: ${cmake_make_processor}"
925 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
926   echo "---------------------------------------------"
927   echo "Makefile processor ${cmake_make_processor} does not support parallel build"
928   echo "---------------------------------------------"
929 fi
930
931 # Ok, we have CC, CXX, and MAKE.
932
933 # Test C++ compiler features
934
935 # Are we GCC?
936
937 TMPFILE=`cmake_tmp_file`
938 echo '
939 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
940 #include <iostream>
941 int main() { std::cout << "This is GNU" << std::endl; return 0;}
942 #endif
943 ' > ${TMPFILE}.cxx
944 cmake_cxx_compiler_is_gnu=0
945 if cmake_try_run "${cmake_cxx_compiler}" \
946   "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
947   cmake_cxx_compiler_is_gnu=1
948 fi
949 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
950   echo "${cmake_cxx_compiler} is GNU compiler"
951 else
952   echo "${cmake_cxx_compiler} is not GNU compiler"
953 fi
954 rm -f "${TMPFILE}.cxx"
955
956 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
957   # Check for non-GNU compiler flags
958
959   # If we are on IRIX, check for -LANG:std
960   cmake_test_flags="-LANG:std"
961   if [ "x${cmake_system}" = "xIRIX64" ]; then
962     TMPFILE=`cmake_tmp_file`
963     echo '
964     #include <iostream>
965     int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
966 ' > ${TMPFILE}.cxx
967     cmake_need_lang_std=0
968     if cmake_try_run "${cmake_cxx_compiler}" \
969       "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
970       :
971     else
972       if cmake_try_run "${cmake_cxx_compiler}" \
973         "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
974         cmake_need_lang_std=1
975       fi
976     fi
977     if [ "x${cmake_need_lang_std}" = "x1" ]; then
978       cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
979       echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
980     else
981       echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
982     fi
983     rm -f "${TMPFILE}.cxx"
984   fi
985   cmake_test_flags=
986
987   # If we are on OSF, check for -timplicit_local -no_implicit_include
988   cmake_test_flags="-timplicit_local -no_implicit_include"
989   if [ "x${cmake_system}" = "xOSF1" ]; then
990     TMPFILE=`cmake_tmp_file`
991     echo '
992     #include <iostream>
993     int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
994 ' > ${TMPFILE}.cxx
995     cmake_need_flags=1
996     if cmake_try_run "${cmake_cxx_compiler}" \
997       "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
998       :
999     else
1000       cmake_need_flags=0
1001     fi
1002     if [ "x${cmake_need_flags}" = "x1" ]; then
1003       cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
1004       echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
1005     else
1006       echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
1007     fi
1008     rm -f "${TMPFILE}.cxx"
1009   fi
1010   cmake_test_flags=
1011
1012   # If we are on OSF, check for -std strict_ansi -nopure_cname
1013   cmake_test_flags="-std strict_ansi -nopure_cname"
1014   if [ "x${cmake_system}" = "xOSF1" ]; then
1015     TMPFILE=`cmake_tmp_file`
1016     echo '
1017     #include <iostream>
1018     int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
1019 ' > ${TMPFILE}.cxx
1020     cmake_need_flags=1
1021     if cmake_try_run "${cmake_cxx_compiler}" \
1022       "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
1023       :
1024     else
1025       cmake_need_flags=0
1026     fi
1027     if [ "x${cmake_need_flags}" = "x1" ]; then
1028       cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
1029       echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
1030     else
1031       echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
1032     fi
1033     rm -f "${TMPFILE}.cxx"
1034   fi
1035   cmake_test_flags=
1036
1037   # If we are on HP-UX, check for -Ae for the C compiler.
1038   cmake_test_flags="-Ae"
1039   if [ "x${cmake_system}" = "xHP-UX" ]; then
1040     TMPFILE=`cmake_tmp_file`
1041     echo '
1042     int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
1043 ' > ${TMPFILE}.c
1044     cmake_need_Ae=0
1045     if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
1046       :
1047     else
1048       if cmake_try_run "${cmake_c_compiler}" \
1049         "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
1050         cmake_need_Ae=1
1051       fi
1052     fi
1053     if [ "x${cmake_need_Ae}" = "x1" ]; then
1054       cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
1055       echo "${cmake_c_compiler} needs ${cmake_test_flags}"
1056     else
1057       echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
1058     fi
1059     rm -f "${TMPFILE}.c"
1060   fi
1061   cmake_test_flags=
1062 fi
1063
1064 # Test for kwsys features
1065 KWSYS_NAME_IS_KWSYS=0
1066 KWSYS_BUILD_SHARED=0
1067 KWSYS_LFS_AVAILABLE=0
1068 KWSYS_LFS_REQUESTED=0
1069 KWSYS_IOS_USE_STRSTREAM_H=0
1070 KWSYS_IOS_USE_STRSTREA_H=0
1071 KWSYS_IOS_HAVE_STD=0
1072 KWSYS_IOS_USE_SSTREAM=0
1073 KWSYS_IOS_USE_ANSI=0
1074 KWSYS_IOS_HAVE_BINARY=0
1075 KWSYS_STL_HAVE_STD=0
1076 KWSYS_STAT_HAS_ST_MTIM=0
1077 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
1078 KWSYS_STL_HAS_ITERATOR_TRAITS=0
1079 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
1080 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
1081 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
1082 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
1083 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
1084 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
1085 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
1086 KWSYS_CXX_HAS_SETENV=0
1087 KWSYS_CXX_HAS_UNSETENV=0
1088 KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
1089 KWSYS_CXX_HAS_UTIMENSAT=0
1090 KWSYS_CXX_HAS_UTIMES=0
1091 KWSYS_CXX_HAS_CSTDDEF=0
1092 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
1093 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
1094 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
1095 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
1096
1097 # Hardcode these kwsys features.  They work on all known UNIX compilers anyway.
1098 KWSYS_STL_STRING_HAVE_ISTREAM=1
1099 KWSYS_STL_STRING_HAVE_OSTREAM=1
1100
1101 if cmake_try_run "${cmake_cxx_compiler}" \
1102   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
1103   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1104   KWSYS_CXX_HAS_SETENV=1
1105   echo "${cmake_cxx_compiler} has setenv"
1106 else
1107   echo "${cmake_cxx_compiler} does not have setenv"
1108 fi
1109
1110 if cmake_try_run "${cmake_cxx_compiler}" \
1111   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
1112   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1113   KWSYS_CXX_HAS_UNSETENV=1
1114   echo "${cmake_cxx_compiler} has unsetenv"
1115 else
1116   echo "${cmake_cxx_compiler} does not have unsetenv"
1117 fi
1118
1119 if cmake_try_run "${cmake_cxx_compiler}" \
1120   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
1121   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1122   KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
1123   echo "${cmake_cxx_compiler} has environ in stdlib.h"
1124 else
1125   echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
1126 fi
1127
1128 if cmake_try_run "${cmake_cxx_compiler}" \
1129   "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
1130   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1131   KWSYS_STL_HAVE_STD=1
1132   echo "${cmake_cxx_compiler} has STL in std:: namespace"
1133 else
1134   echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
1135 fi
1136
1137 if cmake_try_run "${cmake_cxx_compiler}" \
1138   "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
1139   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1140   KWSYS_IOS_USE_ANSI=1
1141   echo "${cmake_cxx_compiler} has ANSI streams"
1142 else
1143   echo "${cmake_cxx_compiler} does not have ANSI streams"
1144 fi
1145
1146 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1147   if cmake_try_run "${cmake_cxx_compiler}" \
1148     "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
1149     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1150     KWSYS_IOS_HAVE_STD=1
1151     echo "${cmake_cxx_compiler} has streams in std:: namespace"
1152   else
1153     echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
1154   fi
1155   if cmake_try_run "${cmake_cxx_compiler}" \
1156     "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
1157     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1158     KWSYS_IOS_USE_SSTREAM=1
1159     echo "${cmake_cxx_compiler} has sstream"
1160   else
1161     echo "${cmake_cxx_compiler} does not have sstream"
1162   fi
1163 fi
1164
1165 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
1166   if cmake_try_run "${cmake_cxx_compiler}" \
1167     "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
1168     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1169     KWSYS_IOS_USE_STRSTREAM_H=1
1170     echo "${cmake_cxx_compiler} has strstream.h"
1171   else
1172     echo "${cmake_cxx_compiler} does not have strstream.h"
1173   fi
1174   if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
1175     if cmake_try_run "${cmake_cxx_compiler}" \
1176       "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
1177       "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1178       KWSYS_IOS_USE_STRSTREA_H=1
1179       echo "${cmake_cxx_compiler} has strstrea.h"
1180     else
1181       echo "${cmake_cxx_compiler} does not have strstrea.h"
1182     fi
1183   fi
1184 fi
1185
1186 if cmake_try_run "${cmake_cxx_compiler}" \
1187   "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1188   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1189   KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1190   echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1191 else
1192   echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1193 fi
1194
1195 if cmake_try_run "${cmake_cxx_compiler}" \
1196   "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1197   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1198   KWSYS_STL_HAS_ITERATOR_TRAITS=1
1199   echo "${cmake_cxx_compiler} has stl iterator_traits"
1200 else
1201   echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1202 fi
1203
1204 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1205   if cmake_try_run "${cmake_cxx_compiler}" \
1206     "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1207     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1208     KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1209     echo "${cmake_cxx_compiler} has old iterator_category"
1210   else
1211     echo "${cmake_cxx_compiler} does not have old iterator_category"
1212   fi
1213   if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1214     if cmake_try_run "${cmake_cxx_compiler}" \
1215       "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1216       "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1217       KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1218       echo "${cmake_cxx_compiler} has old __iterator_category"
1219     else
1220       echo "${cmake_cxx_compiler} does not have old __iterator_category"
1221     fi
1222   fi
1223 fi
1224
1225 if cmake_try_run "${cmake_cxx_compiler}" \
1226   "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1227   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1228   KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1229   echo "${cmake_cxx_compiler} has standard template allocator"
1230 else
1231   echo "${cmake_cxx_compiler} does not have standard template allocator"
1232 fi
1233
1234 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1235   if cmake_try_run "${cmake_cxx_compiler}" \
1236     "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1237     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1238     KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1239     echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1240   else
1241     echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1242   fi
1243
1244   if cmake_try_run "${cmake_cxx_compiler}" \
1245     "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1246     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1247     KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1248     echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1249   else
1250     echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1251   fi
1252 else
1253   if cmake_try_run "${cmake_cxx_compiler}" \
1254     "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1255     "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1256     KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1257     echo "${cmake_cxx_compiler} has old non-template allocator"
1258   else
1259     echo "${cmake_cxx_compiler} does not have old non-template allocator"
1260   fi
1261 fi
1262
1263 if cmake_try_run "${cmake_cxx_compiler}" \
1264   "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1265   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1266   KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1267   echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1268 else
1269   echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1270 fi
1271
1272 if cmake_try_run "${cmake_cxx_compiler}" \
1273   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1274   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1275   KWSYS_CXX_HAS_CSTDDEF=1
1276   echo "${cmake_cxx_compiler} has header cstddef"
1277 else
1278   echo "${cmake_cxx_compiler} does not have header cstddef"
1279 fi
1280
1281 if cmake_try_run "${cmake_cxx_compiler}" \
1282   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1283   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1284   echo "${cmake_cxx_compiler} does not require template friends to use <>"
1285 else
1286   KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1287   echo "${cmake_cxx_compiler} requires template friends to use <>"
1288 fi
1289
1290 if cmake_try_run "${cmake_cxx_compiler}" \
1291   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1292   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1293   KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1294   echo "${cmake_cxx_compiler} supports member templates"
1295 else
1296   echo "${cmake_cxx_compiler} does not support member templates"
1297 fi
1298
1299 if cmake_try_run "${cmake_cxx_compiler}" \
1300   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1301   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1302   KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1303   echo "${cmake_cxx_compiler} has standard template specialization syntax"
1304 else
1305   echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1306 fi
1307
1308 if cmake_try_run "${cmake_cxx_compiler}" \
1309   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1310   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1311   KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1312   echo "${cmake_cxx_compiler} has argument dependent lookup"
1313 else
1314   echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1315 fi
1316
1317 if cmake_try_run "${cmake_cxx_compiler}" \
1318   "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1319   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1320   KWSYS_STAT_HAS_ST_MTIM=1
1321   echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1322 else
1323   echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1324 fi
1325
1326 if cmake_try_run "${cmake_cxx_compiler}" \
1327   "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_BINARY -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}" \
1328   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1329   KWSYS_IOS_HAVE_BINARY=1
1330   echo "${cmake_cxx_compiler} has ios::binary openmode"
1331 else
1332   echo "${cmake_cxx_compiler} does not have ios::binary openmode"
1333 fi
1334
1335 # Just to be safe, let us store compiler and flags to the header file
1336
1337 cmake_bootstrap_version='$Revision$'
1338 cmake_compiler_settings_comment="/*
1339  * Generated by ${cmake_source_dir}/bootstrap
1340  * Version:     ${cmake_bootstrap_version}
1341  *
1342  * Source directory: ${cmake_source_dir}
1343  * Binary directory: ${cmake_bootstrap_dir}
1344  *
1345  * C compiler:   ${cmake_c_compiler}
1346  * C flags:      ${cmake_c_flags}
1347  *
1348  * C++ compiler: ${cmake_cxx_compiler}
1349  * C++ flags:    ${cmake_cxx_flags}
1350  *
1351  * Make:         ${cmake_make_processor}
1352  *
1353  * Sources:
1354  * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1355  * kwSys Sources:
1356  * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
1357  */
1358 "
1359
1360 cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
1361
1362 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1363   cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_STD_NAMESPACE */"
1364 else
1365   cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_STD_NAMESPACE 1"
1366 fi
1367
1368 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1369   cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1370 else
1371   cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1372 fi
1373
1374 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1375   cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1376 else
1377   cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1378 fi
1379
1380 # Test for ansi FOR scope
1381 if cmake_try_run "${cmake_cxx_compiler}" \
1382   "${cmake_cxx_flags}" \
1383   "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1384   cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1385   echo "${cmake_cxx_compiler} has ANSI for scoping"
1386 else
1387   cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1388   echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1389 fi
1390
1391 # When bootstrapping on MinGW with MSYS we must convert the source
1392 # directory to a windows path.
1393 if ${cmake_system_mingw}; then
1394     cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1395 else
1396     cmake_root_dir="${cmake_source_dir}"
1397 fi
1398
1399 # Write CMake version
1400 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1401 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1402 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1403 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}"
1404 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
1405 cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1406 cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/${cmake_data_dir}\""
1407 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
1408
1409 # Regenerate configured headers
1410 for h in Configure VersionConfig; do
1411   if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
1412     rm -f cm${h}.h${_tmp}
1413   else
1414     mv -f cm${h}.h${_tmp} cm${h}.h
1415   fi
1416 done
1417
1418 # Prepare KWSYS
1419 cmake_kwsys_config_replace_string \
1420   "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1421   "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1422   "${cmake_compiler_settings_comment}"
1423 cmake_kwsys_config_replace_string \
1424   "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1425   "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1426   "${cmake_compiler_settings_comment}"
1427
1428 for a in ${KWSYS_FILES}; do
1429   cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1430      "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1431 done
1432
1433 for a in ${KWSYS_IOS_FILES}; do
1434   cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1435      "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1436 done
1437
1438 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1439    "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" KWSYS_STL_HEADER_EXTRA ""
1440
1441 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" \
1442    "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" KWSYS_NAMESPACE cmsys
1443
1444 for a in string vector set map algorithm; do
1445   cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" \
1446     "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1447 done
1448
1449 # Generate Makefile
1450 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1451 objs=""
1452 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
1453   objs="${objs} ${a}.o"
1454 done
1455
1456 # Generate dependencies for cmBootstrapCommands1.cxx
1457 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands1.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1458   cmBootstrapCommands1Deps="${cmBootstrapCommands1Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1459 done
1460 cmBootstrapCommands1Deps=`echo $cmBootstrapCommands1Deps`
1461 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands2.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1462   cmBootstrapCommands2Deps="${cmBootstrapCommands2Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1463 done
1464 cmBootstrapCommands2Deps=`echo $cmBootstrapCommands2Deps`
1465
1466 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1467   cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1468 fi
1469
1470 if [ "x${cmake_c_flags}" != "x" ]; then
1471   cmake_c_flags="${cmake_c_flags} "
1472 fi
1473
1474 if [ "x${cmake_cxx_flags}" != "x" ]; then
1475   cmake_cxx_flags="${cmake_cxx_flags} "
1476 fi
1477
1478 cmake_c_flags_String="-DKWSYS_STRING_C"
1479 cmake_cxx_flags_SystemTools="
1480   -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
1481   -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
1482   -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
1483   -DKWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
1484   -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
1485 "
1486 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1487   -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1488 cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1489   -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1490 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1491 echo "  ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1492 for a in ${CMAKE_CXX_SOURCES}; do
1493   src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1494   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1495   echo "        ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1496 done
1497 echo "cmBootstrapCommands1.o : $cmBootstrapCommands1Deps" >> "${cmake_bootstrap_dir}/Makefile"
1498 echo "cmBootstrapCommands2.o : $cmBootstrapCommands2Deps" >> "${cmake_bootstrap_dir}/Makefile"
1499 for a in ${CMAKE_C_SOURCES}; do
1500   src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1501   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1502   echo "        ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1503 done
1504 for a in ${KWSYS_C_SOURCES}; do
1505   src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1506   src_flags=`eval echo \\${cmake_c_flags_\${a}}`
1507   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1508   echo "        ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1509 done
1510 for a in ${KWSYS_CXX_SOURCES}; do
1511   src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1512   src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
1513   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1514   echo "        ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1515 done
1516 echo '
1517 rebuild_cache:
1518         cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1519 ' >> "${cmake_bootstrap_dir}/Makefile"
1520
1521 # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
1522 echo '
1523 # Generated by '"${cmake_source_dir}"'/bootstrap
1524 # Default cmake settings.  These may be overridden any settings below.
1525 set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1526 set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1527 set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1528 set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1529 ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1530
1531 # Add configuration settings given as command-line options.
1532 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1533   echo '
1534 set (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
1535 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1536 fi
1537 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1538   echo '
1539 set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
1540 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1541 fi
1542
1543 # Add user-specified settings.  Handle relative-path case for
1544 # specification of cmake_init_file.
1545 (
1546 cd "${cmake_binary_dir}"
1547 if [ -f "${cmake_init_file}" ]; then
1548   cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1549 fi
1550 )
1551
1552 echo "---------------------------------------------"
1553
1554 # Run make to build bootstrap cmake
1555 if [ "x${cmake_parallel_make}" != "x" ]; then
1556   ${cmake_make_processor} ${cmake_make_flags}
1557 else
1558   ${cmake_make_processor}
1559 fi
1560 RES=$?
1561 if [ "${RES}" -ne "0" ]; then
1562   cmake_error 9 "Problem while running ${cmake_make_processor}"
1563 fi
1564 cd "${cmake_binary_dir}"
1565
1566 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1567 # build with same compiler and make
1568 CC="${cmake_c_compiler}"
1569 CXX="${cmake_cxx_compiler}"
1570 if [ -n "${cmake_ccache_enabled}" ]; then
1571   CC="ccache ${CC}"
1572   CXX="ccache ${CXX}"
1573 fi
1574 MAKE="${cmake_make_processor}"
1575 export CC
1576 export CXX
1577 export MAKE
1578
1579 # Run bootstrap CMake to configure real CMake
1580 cmake_options="-DCMAKE_BOOTSTRAP=1"
1581 if [ -n "${cmake_verbose}" ]; then
1582   cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1"
1583 fi
1584 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@"
1585 RES=$?
1586 if [ "${RES}" -ne "0" ]; then
1587   cmake_error 11 "Problem while running initial CMake"
1588 fi
1589
1590 echo "---------------------------------------------"
1591
1592 # And we are done. Now just run make
1593 echo "CMake has bootstrapped.  Now run ${cmake_make_processor}."