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