Imported Upstream version 3.10.3
[platform/upstream/cmake.git] / bootstrap
1 #!/bin/sh
2 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
3 # file Copyright.txt or https://cmake.org/licensing for details.
4
5 die() {
6   echo "$@" 1>&2 ; exit 1
7 }
8
9 # Compile flag extraction function.
10 cmake_extract_standard_flags()
11 {
12   sed -n "s/ *set *( *CMAKE_${2}${3}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
13     "${cmake_source_dir}/Modules/Compiler/"${1:-*}-${2}.cmake 2>/dev/null | tr ';' ' '
14 }
15
16 # Version number extraction function.
17 cmake_version_component()
18 {
19   sed -n "
20 /^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
21 " "${cmake_source_dir}/Source/CMakeVersion.cmake"
22 }
23
24 # Install destination extraction function.
25 cmake_install_dest_default()
26 {
27   sed -n '
28 /^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ {
29   s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/
30   s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/
31   s/${CMake_VERSION_MINOR}/'"${cmake_version_minor}"'/
32   s/${CMake_VERSION_PATCH}/'"${cmake_version_patch}"'/
33   p
34   q
35 }
36 ' "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake"
37 }
38
39 cmake_toupper()
40 {
41     echo "$1" | tr '[:lower:]' '[:upper:]'
42 }
43
44 # Detect system and directory information.
45 cmake_system=`uname`
46 cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
47 cmake_binary_dir=`pwd`
48
49 # Load version information.
50 cmake_version_major="`cmake_version_component MAJOR`"
51 cmake_version_minor="`cmake_version_component MINOR`"
52 cmake_version_patch="`cmake_version_component PATCH`"
53 cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
54 cmake_version_rc="`cmake_version_component RC`"
55 if [ "$cmake_version_rc" != "" ]; then
56   cmake_version="${cmake_version}-rc${cmake_version_rc}"
57 fi
58
59 cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`"
60
61 cmake_bin_dir_keyword="OTHER"
62 cmake_data_dir_keyword="OTHER"
63 cmake_doc_dir_keyword="OTHER"
64 cmake_man_dir_keyword="OTHER"
65 cmake_xdgdata_dir_keyword="OTHER"
66 cmake_bin_dir=""
67 cmake_data_dir=""
68 cmake_doc_dir=""
69 cmake_man_dir=""
70 cmake_xdgdata_dir=""
71 cmake_init_file=""
72 cmake_bootstrap_system_libs=""
73 cmake_bootstrap_qt_gui=""
74 cmake_bootstrap_qt_qmake=""
75 cmake_sphinx_man=""
76 cmake_sphinx_html=""
77 cmake_sphinx_qthelp=""
78 cmake_sphinx_build=""
79 cmake_sphinx_flags=""
80
81 # Determine whether this is a Cygwin environment.
82 if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
83   cmake_system_cygwin=true
84   cmake_doc_dir_keyword="CYGWIN"
85   cmake_man_dir_keyword="CYGWIN"
86 else
87   cmake_system_cygwin=false
88 fi
89
90 # Determine whether this is a MinGW environment.
91 if echo "${cmake_system}" | grep 'MINGW\|MSYS' >/dev/null 2>&1; then
92   cmake_system_mingw=true
93 else
94   cmake_system_mingw=false
95 fi
96
97 # Determine whether this is OS X
98 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
99   cmake_system_darwin=true
100 else
101   cmake_system_darwin=false
102 fi
103
104 # Determine whether this is BeOS
105 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
106   cmake_system_beos=true
107   cmake_doc_dir_keyword="HAIKU"
108   cmake_man_dir_keyword="HAIKU"
109 else
110   cmake_system_beos=false
111 fi
112
113 # Determine whether this is Haiku
114 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
115   cmake_system_haiku=true
116   cmake_doc_dir_keyword="HAIKU"
117   cmake_man_dir_keyword="HAIKU"
118 else
119   cmake_system_haiku=false
120 fi
121
122 # Determine whether this is OpenVMS
123 if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
124   cmake_system_openvms=true
125 else
126   cmake_system_openvms=false
127 fi
128
129 # Determine whether this is HP-UX
130 if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then
131   die 'CMake no longer compiles on HP-UX.  See
132
133   https://gitlab.kitware.com/cmake/cmake/issues/17137
134
135 Use CMake 3.9 or lower instead.'
136   cmake_system_hpux=true
137 else
138   cmake_system_hpux=false
139 fi
140
141 # Determine whether this is Linux
142 if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
143   cmake_system_linux=true
144 else
145   cmake_system_linux=false
146  fi
147
148 # Determine whether this is a PA-RISC machine
149 # This only works for Linux or HP-UX, not other PA-RISC OSs (BSD maybe?). Also
150 # may falsely detect parisc on HP-UX m68k
151 cmake_machine_parisc=false
152 if ${cmake_system_linux}; then
153   if uname -m | grep parisc >/dev/null 2>&1; then
154     cmake_machine_parisc=true
155   fi
156 elif ${cmake_system_hpux}; then
157   if uname -m | grep ia64 >/dev/null 2>&1; then : ; else
158     cmake_machine_parisc=true
159   fi
160 fi
161
162 # Choose the generator to use for bootstrapping.
163 if ${cmake_system_mingw}; then
164   # Bootstrapping from an MSYS prompt.
165   cmake_bootstrap_generator="MSYS Makefiles"
166 else
167   # Bootstrapping from a standard UNIX prompt.
168   cmake_bootstrap_generator="Unix Makefiles"
169 fi
170
171 # Choose tools and extensions for this platform.
172 if ${cmake_system_openvms}; then
173   _tmp="_tmp"
174   _cmk="_cmk"
175   _diff=`which diff`
176 else
177   _tmp=".tmp"
178   _cmk=".cmk"
179   _diff="diff"
180 fi
181
182 # Construct bootstrap directory name.
183 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
184
185 # Helper function to fix windows paths.
186 case "${cmake_system}" in
187 *MINGW*)
188   cmake_fix_slashes()
189   {
190     cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
191   }
192   ;;
193 *)
194   cmake_fix_slashes()
195   {
196     echo "$1" | sed 's/\\/\//g'
197   }
198   ;;
199 esac
200
201 # Choose the default install prefix.
202 if ${cmake_system_mingw}; then
203   if [ "x${PROGRAMFILES}" != "x" ]; then
204     cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
205   elif [ "x${ProgramFiles}" != "x" ]; then
206     cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
207   elif [ "x${SYSTEMDRIVE}" != "x" ]; then
208     cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
209   elif [ "x${SystemDrive}" != "x" ]; then
210     cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
211   else
212     cmake_default_prefix="c:/Program Files/CMake"
213   fi
214 elif ${cmake_system_haiku}; then
215   cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
216 else
217   cmake_default_prefix="/usr/local"
218 fi
219
220 # Lookup default install destinations.
221 cmake_bin_dir_default="`cmake_install_dest_default BIN ${cmake_bin_dir_keyword}`"
222 cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`"
223 cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`"
224 cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`"
225 cmake_xdgdata_dir_default="`cmake_install_dest_default XDGDATA ${cmake_xdgdata_dir_keyword}`"
226
227 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
228 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
229 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
230
231 CMAKE_PROBLEMATIC_FILES="\
232   CMakeCache.txt \
233   CMakeSystem.cmake \
234   CMakeCCompiler.cmake \
235   CMakeCXXCompiler.cmake \
236   */CMakeSystem.cmake \
237   */CMakeCCompiler.cmake \
238   */CMakeCXXCompiler.cmake \
239   Source/cmConfigure.h \
240   Source/CTest/Curl/config.h \
241   Utilities/cmexpat/expatConfig.h \
242   Utilities/cmexpat/expatDllConfig.h \
243   "
244
245 CMAKE_UNUSED_SOURCES="\
246   cmGlobalXCodeGenerator \
247   cmLocalXCodeGenerator \
248   cmXCodeObject \
249   cmXCode21Object \
250   cmSourceGroup \
251 "
252
253 CMAKE_CXX_SOURCES="\
254   cmAddCustomCommandCommand \
255   cmAddCustomTargetCommand \
256   cmAddDefinitionsCommand \
257   cmAddDependenciesCommand \
258   cmAddExecutableCommand \
259   cmAddLibraryCommand \
260   cmAddSubDirectoryCommand \
261   cmAddTestCommand \
262   cmBreakCommand \
263   cmBuildCommand \
264   cmCMakeMinimumRequired \
265   cmCMakePolicyCommand \
266   cmCPackPropertiesGenerator \
267   cmCacheManager \
268   cmCommand \
269   cmCommandArgumentParserHelper \
270   cmCommandArgumentsHelper \
271   cmCommands \
272   cmCommonTargetGenerator \
273   cmComputeComponentGraph \
274   cmComputeLinkDepends \
275   cmComputeLinkInformation \
276   cmComputeTargetDepends \
277   cmConditionEvaluator \
278   cmConfigureFileCommand \
279   cmContinueCommand \
280   cmCoreTryCompile \
281   cmCreateTestSourceList \
282   cmCustomCommand \
283   cmCustomCommandGenerator \
284   cmDefinePropertyCommand \
285   cmDefinitions \
286   cmDepends \
287   cmDependsC \
288   cmDisallowedCommand \
289   cmDocumentationFormatter \
290   cmEnableLanguageCommand \
291   cmEnableTestingCommand \
292   cmExecProgramCommand \
293   cmExecuteProcessCommand \
294   cmExpandedCommandArgument \
295   cmExportBuildFileGenerator \
296   cmExportFileGenerator \
297   cmExportInstallFileGenerator \
298   cmExportSet \
299   cmExportSetMap \
300   cmExportTryCompileFileGenerator \
301   cmExprParserHelper \
302   cmExternalMakefileProjectGenerator \
303   cmFileCommand \
304   cmFileTimeComparison \
305   cmFindBase \
306   cmFindCommon \
307   cmFindFileCommand \
308   cmFindLibraryCommand \
309   cmFindPackageCommand \
310   cmFindPathCommand \
311   cmFindProgramCommand \
312   cmForEachCommand \
313   cmFunctionCommand \
314   cmGeneratedFileStream \
315   cmGeneratorExpression \
316   cmGeneratorExpressionContext \
317   cmGeneratorExpressionDAGChecker \
318   cmGeneratorExpressionEvaluationFile \
319   cmGeneratorExpressionEvaluator \
320   cmGeneratorExpressionLexer \
321   cmGeneratorExpressionNode \
322   cmGeneratorExpressionParser \
323   cmGeneratorTarget \
324   cmGetCMakePropertyCommand \
325   cmGetDirectoryPropertyCommand \
326   cmGetFilenameComponentCommand \
327   cmGetPropertyCommand \
328   cmGetSourceFilePropertyCommand \
329   cmGetTargetPropertyCommand \
330   cmGetTestPropertyCommand \
331   cmGlobalCommonGenerator \
332   cmGlobalGenerator \
333   cmGlobalUnixMakefileGenerator3 \
334   cmHexFileConverter \
335   cmIfCommand \
336   cmIncludeCommand \
337   cmIncludeGuardCommand \
338   cmIncludeDirectoryCommand \
339   cmIncludeRegularExpressionCommand \
340   cmInstallCommand \
341   cmInstallCommandArguments \
342   cmInstallDirectoryGenerator \
343   cmInstallExportGenerator \
344   cmInstallFilesCommand \
345   cmInstallFilesGenerator \
346   cmInstallGenerator \
347   cmInstallScriptGenerator \
348   cmInstallTargetGenerator \
349   cmInstallTargetsCommand \
350   cmInstalledFile \
351   cmLinkDirectoriesCommand \
352   cmLinkLineComputer \
353   cmListCommand \
354   cmListFileCache \
355   cmLocalCommonGenerator \
356   cmLocalGenerator \
357   cmLocalUnixMakefileGenerator3 \
358   cmMSVC60LinkLineComputer \
359   cmMacroCommand \
360   cmMakeDirectoryCommand \
361   cmMakefile \
362   cmMakefileExecutableTargetGenerator \
363   cmMakefileLibraryTargetGenerator \
364   cmMakefileTargetGenerator \
365   cmMakefileUtilityTargetGenerator \
366   cmMarkAsAdvancedCommand \
367   cmMathCommand \
368   cmMessageCommand \
369   cmMessenger \
370   cmNewLineStyle \
371   cmOSXBundleGenerator \
372   cmOptionCommand \
373   cmOrderDirectories \
374   cmOutputConverter \
375   cmParseArgumentsCommand \
376   cmPathLabel \
377   cmPolicies \
378   cmProcessOutput \
379   cmProjectCommand \
380   cmProperty \
381   cmPropertyDefinition \
382   cmPropertyDefinitionMap \
383   cmPropertyMap \
384   cmReturnCommand \
385   cmRulePlaceholderExpander \
386   cmScriptGenerator \
387   cmSearchPath \
388   cmSeparateArgumentsCommand \
389   cmSetCommand \
390   cmSetDirectoryPropertiesCommand \
391   cmSetPropertyCommand \
392   cmSetSourceFilesPropertiesCommand \
393   cmSetTargetPropertiesCommand \
394   cmSetTestsPropertiesCommand \
395   cmSiteNameCommand \
396   cmSourceFile \
397   cmSourceFileLocation \
398   cmState \
399   cmStateDirectory \
400   cmStateSnapshot \
401   cmStringCommand \
402   cmSubdirCommand \
403   cmSystemTools \
404   cmTarget \
405   cmTargetCompileDefinitionsCommand \
406   cmTargetCompileFeaturesCommand \
407   cmTargetCompileOptionsCommand \
408   cmTargetIncludeDirectoriesCommand \
409   cmTargetLinkLibrariesCommand \
410   cmTargetPropCommandBase \
411   cmTargetPropertyComputer \
412   cmTargetSourcesCommand \
413   cmTest \
414   cmTestGenerator \
415   cmTimestamp \
416   cmTryCompileCommand \
417   cmTryRunCommand \
418   cmUnexpectedCommand \
419   cmUnsetCommand \
420   cmVersion \
421   cmWhileCommand \
422   cmWorkingDirectory \
423   cmake  \
424   cmakemain \
425   cmcmd  \
426 "
427
428 if ${cmake_system_mingw}; then
429   CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
430     cmGlobalMSYSMakefileGenerator \
431     cmGlobalMinGWMakefileGenerator"
432 fi
433
434 LexerParser_CXX_SOURCES="\
435   cmCommandArgumentLexer \
436   cmCommandArgumentParser \
437   cmExprLexer \
438   cmExprParser \
439 "
440
441 LexerParser_C_SOURCES="\
442   cmListFileLexer \
443 "
444
445 if ${cmake_system_mingw}; then
446   KWSYS_C_SOURCES="\
447     EncodingC \
448     ProcessWin32 \
449     String \
450     System \
451     Terminal"
452 else
453   KWSYS_C_SOURCES="\
454     EncodingC \
455     ProcessUNIX \
456     String \
457     System \
458     Terminal"
459 fi
460
461 KWSYS_CXX_SOURCES="\
462   Directory \
463   EncodingCXX \
464   FStream \
465   Glob \
466   RegularExpression \
467   SystemTools"
468
469 KWSYS_FILES="\
470   Directory.hxx \
471   Encoding.h \
472   Encoding.hxx \
473   FStream.hxx \
474   Glob.hxx \
475   Process.h \
476   RegularExpression.hxx \
477   String.h \
478   String.hxx \
479   System.h \
480   SystemTools.hxx \
481   Terminal.h"
482
483 if ${cmake_system_mingw}; then
484   LIBUV_C_SOURCES="\
485     src/fs-poll.c \
486     src/inet.c \
487     src/threadpool.c \
488     src/uv-common.c \
489     src/win/async.c \
490     src/win/core.c \
491     src/win/detect-wakeup.c \
492     src/win/dl.c \
493     src/win/error.c \
494     src/win/fs-event.c \
495     src/win/fs.c \
496     src/win/getaddrinfo.c \
497     src/win/getnameinfo.c \
498     src/win/handle.c \
499     src/win/loop-watcher.c \
500     src/win/pipe.c \
501     src/win/poll.c \
502     src/win/process-stdio.c \
503     src/win/process.c \
504     src/win/req.c \
505     src/win/signal.c \
506     src/win/stream.c \
507     src/win/tcp.c \
508     src/win/thread.c \
509     src/win/timer.c \
510     src/win/tty.c \
511     src/win/udp.c \
512     src/win/util.c \
513     src/win/winapi.c \
514     src/win/winsock.c \
515     "
516 else
517   LIBUV_C_SOURCES="\
518     src/uv-common.c \
519     src/unix/cmake-bootstrap.c \
520     src/unix/core.c \
521     src/unix/fs.c \
522     src/unix/loop.c \
523     src/unix/loop-watcher.c \
524     src/unix/no-fsevents.c \
525     src/unix/pipe.c \
526     src/unix/poll.c \
527     src/unix/posix-hrtime.c \
528     src/unix/posix-poll.c \
529     src/unix/process.c \
530     src/unix/signal.c \
531     src/unix/stream.c \
532     src/unix/timer.c \
533     "
534 fi
535
536 # Display CMake bootstrap usage
537 cmake_usage()
538 {
539 echo '
540 Usage: '"$0"' [<options>...] [-- <cmake-options>...]
541 Options: [defaults in brackets after descriptions]
542 Configuration:
543   --help                  print this message
544   --version               only print version information
545   --verbose               display more information
546   --parallel=n            bootstrap cmake in parallel, where n is
547                           number of nodes [1]
548   --enable-ccache         Enable ccache when building cmake
549   --init=FILE             load FILE as script to populate cache
550   --system-libs           use all system-installed third-party libraries
551                           (for use only by package maintainers)
552   --no-system-libs        use all cmake-provided third-party libraries
553                           (default)
554   --system-curl           use system-installed curl library
555   --no-system-curl        use cmake-provided curl library (default)
556   --system-expat          use system-installed expat library
557   --no-system-expat       use cmake-provided expat library (default)
558   --system-jsoncpp        use system-installed jsoncpp library
559   --no-system-jsoncpp     use cmake-provided jsoncpp library (default)
560   --system-zlib           use system-installed zlib library
561   --no-system-zlib        use cmake-provided zlib library (default)
562   --system-bzip2          use system-installed bzip2 library
563   --no-system-bzip2       use cmake-provided bzip2 library (default)
564   --system-liblzma        use system-installed liblzma library
565   --no-system-liblzma     use cmake-provided liblzma library (default)
566   --system-libarchive     use system-installed libarchive library
567   --no-system-libarchive  use cmake-provided libarchive library (default)
568   --system-librhash       use system-installed librhash library
569   --no-system-librhash    use cmake-provided librhash library (default)
570
571   --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
572   --no-qt-gui             do not build the Qt-based GUI (default)
573   --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt
574
575   --sphinx-man            build man pages with Sphinx
576   --sphinx-html           build html help with Sphinx
577   --sphinx-qthelp         build qch help with Sphinx
578   --sphinx-build=<sb>     use <sb> as the sphinx-build executable
579   --sphinx-flags=<flags>  pass <flags> to sphinx-build executable
580
581 Directory and file names:
582   --prefix=PREFIX         install files in tree rooted at PREFIX
583                           ['"${cmake_default_prefix}"']
584   --bindir=DIR            install binaries in PREFIX/DIR
585                           ['"${cmake_bin_dir_default}"']
586   --datadir=DIR           install data files in PREFIX/DIR
587                           ['"${cmake_data_dir_default}"']
588   --docdir=DIR            install documentation files in PREFIX/DIR
589                           ['"${cmake_doc_dir_default}"']
590   --mandir=DIR            install man pages files in PREFIX/DIR/manN
591                           ['"${cmake_man_dir_default}"']
592   --xdgdatadir=DIR        install XDG specific files in PREFIX/DIR
593                           ['"${cmake_xdgdata_dir_default}"']
594 '
595   exit 10
596 }
597
598 # Display CMake bootstrap usage
599 cmake_version_display()
600 {
601   echo "CMake ${cmake_version}, ${cmake_copyright}"
602 }
603
604 # Display CMake bootstrap error, display the log file and exit
605 cmake_error()
606 {
607   res=$1
608   shift 1
609   echo "---------------------------------------------"
610   echo "Error when bootstrapping CMake:"
611   echo "$*"
612   echo "---------------------------------------------"
613   if [ -f cmake_bootstrap.log ]; then
614     echo "Log of errors: `pwd`/cmake_bootstrap.log"
615     #cat cmake_bootstrap.log
616     echo "---------------------------------------------"
617   fi
618   exit ${res}
619 }
620
621 cmake_generate_file ()
622 {
623   OUTFILE="$1"
624   CONTENT="$2"
625   echo "$CONTENT" > "$OUTFILE.tmp"
626   if "${_diff}" "$OUTFILE.tmp" "$OUTFILE" > /dev/null 2> /dev/null ; then
627     rm -f "$OUTFILE.tmp"
628   else
629     mv -f "$OUTFILE.tmp" "$OUTFILE"
630   fi
631 }
632
633 # Replace KWSYS_NAMESPACE with cmsys
634 cmake_replace_string ()
635 {
636   INFILE="$1"
637   OUTFILE="$2"
638   SEARCHFOR="$3"
639   REPLACEWITH="$4"
640   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
641     sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" "${INFILE}" > "${OUTFILE}${_tmp}"
642     if [ -f "${OUTFILE}${_tmp}" ]; then
643       if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
644         #echo "Files are the same"
645         rm -f "${OUTFILE}${_tmp}"
646       else
647         mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
648       fi
649     fi
650   else
651     cmake_error 1 "Cannot find file ${INFILE}"
652   fi
653 }
654
655 cmake_kwsys_config_replace_string ()
656 {
657   INFILE="$1"
658   OUTFILE="$2"
659   shift 2
660   APPEND="$*"
661   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
662     echo "${APPEND}" > "${OUTFILE}${_tmp}"
663     sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
664               s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
665               s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
666               s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
667               s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
668               s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
669               s/@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@/${KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H}/g;
670              }" "${INFILE}" >> "${OUTFILE}${_tmp}"
671     if [ -f "${OUTFILE}${_tmp}" ]; then
672       if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
673         #echo "Files are the same"
674         rm -f "${OUTFILE}${_tmp}"
675       else
676         mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
677       fi
678     fi
679   else
680     cmake_error 2 "Cannot find file ${INFILE}"
681   fi
682 }
683 # Write string into a file
684 cmake_report ()
685 {
686   FILE=$1
687   shift
688   echo "$*" >> ${FILE}
689 }
690
691 # Escape spaces in strings
692 cmake_escape ()
693 {
694   echo $1 | sed "s/ /\\\\ /g"
695 }
696
697 # Encode object file names.
698 cmake_obj ()
699 {
700   echo $1 | sed 's/\//-/g' | sed 's/$/\.o/'
701 }
702
703 # Strip prefix from argument
704 cmake_arg ()
705 {
706   echo "$1" | sed "s/^${2-[^=]*=}//"
707 }
708
709 # Write message to the log
710 cmake_log ()
711 {
712   echo "$*" >> cmake_bootstrap.log
713 }
714
715 # Return temp file
716 cmake_tmp_file ()
717 {
718   echo "cmake_bootstrap_$$_test"
719 }
720
721 # Run a compiler test. First argument is compiler, second one are compiler
722 # flags, third one is test source file to be compiled
723 cmake_try_run ()
724 {
725   COMPILER=$1
726   FLAGS=$2
727   TESTFILE=$3
728   if [ ! -f "${TESTFILE}" ]; then
729     echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
730     exit 4
731   fi
732   TMPFILE=`cmake_tmp_file`
733   echo "Try: ${COMPILER}"
734   echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
735   echo "----------  file   -----------------------"
736   cat "${TESTFILE}"
737   echo "------------------------------------------"
738   "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
739   RES=$?
740   if [ "${RES}" -ne "0" ]; then
741     echo "Test failed to compile"
742     return 1
743   fi
744   if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
745     echo "Test failed to produce executable"
746     return 2
747   fi
748   ./${TMPFILE}
749   RES=$?
750   rm -f "${TMPFILE}"
751   if [ "${RES}" -ne "0" ]; then
752     echo "Test produced non-zero return code"
753     return 3
754   fi
755   echo "Test succeeded"
756   return 0
757 }
758
759 # Run a make test. First argument is the make interpreter.
760 cmake_try_make ()
761 {
762   MAKE_PROC="$1"
763   MAKE_FLAGS="$2"
764   echo "Try: ${MAKE_PROC}"
765   "${MAKE_PROC}" ${MAKE_FLAGS}
766   RES=$?
767   if [ "${RES}" -ne "0" ]; then
768     echo "${MAKE_PROC} does not work"
769     return 1
770   fi
771   if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
772     echo "${COMPILER} does not produce output"
773     return 2
774   fi
775   ./test
776   RES=$?
777   rm -f "test"
778   if [ "${RES}" -ne "0" ]; then
779     echo "${MAKE_PROC} produces strange executable"
780     return 3
781   fi
782   echo "${MAKE_PROC} works"
783   return 0
784 }
785
786 # Parse arguments
787 cmake_verbose=
788 cmake_parallel_make=
789 cmake_ccache_enabled=
790 cmake_prefix_dir="${cmake_default_prefix}"
791 while test $# != 0; do
792   case "$1" in
793   --prefix=*) dir=`cmake_arg "$1"`
794               cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
795   --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
796   --bindir=*) cmake_bin_dir=`cmake_arg "$1"` ;;
797   --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
798   --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
799   --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
800   --xdgdatadir=*) cmake_xdgdata_dir=`cmake_arg "$1"` ;;
801   --init=*) cmake_init_file=`cmake_arg "$1"` ;;
802   --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
803   --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
804   --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-librhash|--system-zlib|--system-liblzma)
805     lib=`cmake_arg "$1" "--system-"`
806     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
807   --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-librhash|--no-system-zlib|--no-system-liblzma)
808     lib=`cmake_arg "$1" "--no-system-"`
809     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
810   --qt-gui) cmake_bootstrap_qt_gui="1" ;;
811   --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
812   --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
813   --sphinx-man) cmake_sphinx_man="1" ;;
814   --sphinx-html) cmake_sphinx_html="1" ;;
815   --sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
816   --sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
817   --sphinx-flags=*) cmake_sphinx_flags=`cmake_arg "$1"` ;;
818   --help) cmake_usage ;;
819   --version) cmake_version_display ; exit 2 ;;
820   --verbose) cmake_verbose=TRUE ;;
821   --enable-ccache) cmake_ccache_enabled=TRUE ;;
822   --) shift; break ;;
823   *) die "Unknown option: $1" ;;
824   esac
825   shift
826 done
827
828 # If verbose, display some information about bootstrap
829 if [ -n "${cmake_verbose}" ]; then
830   echo "---------------------------------------------"
831   echo "Source directory: ${cmake_source_dir}"
832   echo "Binary directory: ${cmake_binary_dir}"
833   echo "Prefix directory: ${cmake_prefix_dir}"
834   echo "System:           ${cmake_system}"
835   if [ "x${cmake_parallel_make}" != "x" ]; then
836     echo "Doing parallel make: ${cmake_parallel_make}"
837   fi
838   echo ""
839 fi
840
841 echo "---------------------------------------------"
842 # Get CMake version
843 echo "`cmake_version_display`"
844
845 # Check for in-source build
846 cmake_in_source_build=
847 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
848      -f "${cmake_binary_dir}/Source/cmake.h" ]; then
849   if [ -n "${cmake_verbose}" ]; then
850     echo "Warning: This is an in-source build"
851   fi
852   cmake_in_source_build=TRUE
853 fi
854
855 # If this is not an in-source build, then Bootstrap stuff should not exist.
856 if [ -z "${cmake_in_source_build}" ]; then
857   # Did somebody bootstrap in the source tree?
858   if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
859     cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
860 Looks like somebody did bootstrap CMake in the source tree, but now you are
861 trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
862 directory from the source tree."
863   fi
864   # Is there a cache in the source tree?
865   for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
866     if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
867       cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
868 Looks like somebody tried to build CMake in the source tree, but now you are
869 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
870 from the source tree."
871     fi
872   done
873 fi
874
875 # Make bootstrap directory
876 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
877 if [ ! -d "${cmake_bootstrap_dir}" ]; then
878   cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
879 fi
880 cd "${cmake_bootstrap_dir}"
881
882 [ -d "cmsys" ] || mkdir "cmsys"
883 if [ ! -d "cmsys" ]; then
884   cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
885 fi
886
887 # Delete all the bootstrap files
888 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
889 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
890 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
891
892 # If building in-source, remove any cmConfigure.h that may
893 # have been created by a previous run of the bootstrap cmake.
894 if [ -n "${cmake_in_source_build}" ]; then
895   rm -f "${cmake_source_dir}/Source/cmConfigure.h"
896 fi
897
898 # If exist compiler flags, set them
899 cmake_c_flags=${CFLAGS}
900 cmake_cxx_flags=${CXXFLAGS}
901 cmake_ld_flags=${LDFLAGS}
902
903 # Add Cygwin-specific flags
904 if ${cmake_system_cygwin}; then
905   cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
906 fi
907
908 # Add CoreFoundation framework on Darwin
909 if ${cmake_system_darwin}; then
910   cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
911 fi
912
913 # Add BeOS toolkits...
914 if ${cmake_system_beos}; then
915   cmake_ld_flags="${LDFLAGS} -lroot -lbe"
916 fi
917
918 # Add Haiku toolkits...
919 if ${cmake_system_haiku}; then
920   cmake_ld_flags="${LDFLAGS} -lroot -lbe"
921 fi
922
923 #-----------------------------------------------------------------------------
924 # Detect known toolchains on some platforms.
925 cmake_toolchains=''
926 case "${cmake_system}" in
927   *AIX*)   cmake_toolchains='XL GNU' ;;
928   *CYGWIN*) cmake_toolchains='GNU' ;;
929   *Darwin*) cmake_toolchains='Clang GNU' ;;
930   *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
931   *MINGW*) cmake_toolchains='GNU' ;;
932 esac
933
934 # Toolchain compiler name table.
935 cmake_toolchain_Clang_CC='clang'
936 cmake_toolchain_Clang_CXX='clang++'
937 cmake_toolchain_GNU_CC='gcc'
938 cmake_toolchain_GNU_CXX='g++'
939 cmake_toolchain_PGI_CC='pgcc'
940 cmake_toolchain_PGI_CXX='pgCC'
941 cmake_toolchain_PathScale_CC='pathcc'
942 cmake_toolchain_PathScale_CXX='pathCC'
943 cmake_toolchain_XL_CC='xlc'
944 cmake_toolchain_XL_CXX='xlC'
945
946 cmake_toolchain_try()
947 {
948   tc="$1"
949   TMPFILE=`cmake_tmp_file`
950
951   eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
952   echo 'int main() { return 0; }' > "${TMPFILE}.c"
953   cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
954   tc_result_CC="$?"
955   rm -f "${TMPFILE}.c"
956   test "${tc_result_CC}" = "0" || return 1
957
958   eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
959   echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
960   cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
961   tc_result_CXX="$?"
962   rm -f "${TMPFILE}.cpp"
963   test "${tc_result_CXX}" = "0" || return 1
964
965   cmake_toolchain="$tc"
966 }
967
968 cmake_toolchain_detect()
969 {
970   cmake_toolchain=
971   for tc in ${cmake_toolchains}; do
972     echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
973     cmake_toolchain_try "$tc" &&
974     echo "Found $tc toolchain" &&
975     break
976   done
977 }
978
979 if [ -z "${CC}" -a -z "${CXX}" ]; then
980   cmake_toolchain_detect
981 fi
982
983 #-----------------------------------------------------------------------------
984 # Test C compiler
985 cmake_c_compiler=
986
987 # If CC is set, use that for compiler, otherwise use list of known compilers
988 if [ -n "${cmake_toolchain}" ]; then
989   eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
990 elif [ -n "${CC}" ]; then
991   cmake_c_compilers="${CC}"
992 else
993   cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
994 fi
995
996 # Check if C compiler works
997 TMPFILE=`cmake_tmp_file`
998 echo '
999 #ifdef __cplusplus
1000 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
1001 #endif
1002
1003 #if defined(__sun) && __STDC_VERSION__ < 199901L
1004 #error "On Solaris we need C99."
1005 #endif
1006
1007 #include <stdio.h>
1008
1009 int main(int argc, char* argv[])
1010 {
1011   printf("%d%c", (argv != 0), (char)0x0a);
1012   return argc - 1;
1013 }
1014 ' > "${TMPFILE}.c"
1015 for std in 11 99 90; do
1016   try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
1017   for compiler in ${cmake_c_compilers}; do
1018     for flag in '' $try_flags; do
1019       echo "Checking whether '${compiler} ${cmake_c_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1
1020       if cmake_try_run "${compiler}" "${cmake_c_flags} ${flag}" \
1021         "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
1022         cmake_c_compiler="${compiler}"
1023         cmake_c_flags="${cmake_c_flags} ${flag}"
1024         break 3
1025       fi
1026     done
1027   done
1028 done
1029 rm -f "${TMPFILE}.c"
1030
1031 if [ -z "${cmake_c_compiler}" ]; then
1032   cmake_error 6 "Cannot find appropriate C compiler on this system.
1033 Please specify one using environment variable CC.
1034 See cmake_bootstrap.log for compilers attempted.
1035 "
1036 fi
1037 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
1038
1039 #-----------------------------------------------------------------------------
1040 # Test CXX compiler
1041 cmake_cxx_compiler=
1042
1043 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
1044
1045 # If CC is set, use that for compiler, otherwise use list of known compilers
1046 if [ -n "${cmake_toolchain}" ]; then
1047   eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
1048 elif [ -n "${CXX}" ]; then
1049   cmake_cxx_compilers="${CXX}"
1050 else
1051   cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
1052 fi
1053
1054 # Check if C++ compiler works
1055 TMPFILE=`cmake_tmp_file`
1056 echo '
1057 #include <iostream>
1058 #include <memory>
1059 #include <unordered_map>
1060
1061 #if __cplusplus < 201103L
1062 #error "Compiler is not in a mode aware of C++11."
1063 #endif
1064
1065 #if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
1066 #error "SunPro <= 5.13 mode not supported due to bug in move semantics."
1067 #endif
1068
1069 class Class
1070 {
1071 public:
1072   int Get() const { return this->Member; }
1073 private:
1074   int Member = 1;
1075 };
1076 int main()
1077 {
1078   auto const c = std::unique_ptr<Class>(new Class);
1079   std::cout << c->Get() << std::endl;
1080   return 0;
1081 }
1082 ' > "${TMPFILE}.cxx"
1083 for std in 17 14 11; do
1084   try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`"
1085   for compiler in ${cmake_cxx_compilers}; do
1086     for flag in '' $try_flags; do
1087       echo "Checking whether '${compiler} ${cmake_cxx_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1
1088       if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${flag}" \
1089         "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
1090         cmake_cxx_compiler="${compiler}"
1091         cmake_cxx_flags="${cmake_cxx_flags} ${flag} "
1092         break 3
1093       fi
1094     done
1095   done
1096 done
1097 rm -f "${TMPFILE}.cxx"
1098
1099 if [ -z "${cmake_cxx_compiler}" ]; then
1100 cmake_error 7 "Cannot find a C++ compiler supporting C++11 on this system.
1101 Please specify one using environment variable CXX.
1102 See cmake_bootstrap.log for compilers attempted."
1103 fi
1104 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
1105
1106 #-----------------------------------------------------------------------------
1107 # Test Make
1108
1109 cmake_make_processor=
1110 cmake_make_flags=
1111
1112 # If MAKE is set, use that for make processor, otherwise use list of known make
1113 if [ -n "${MAKE}" ]; then
1114   cmake_make_processors="${MAKE}"
1115 else
1116   cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
1117 fi
1118
1119 TMPFILE="`cmake_tmp_file`_dir"
1120 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
1121 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
1122 cd "${cmake_bootstrap_dir}/${TMPFILE}"
1123 echo '
1124 test: test.c
1125         "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
1126 '>"Makefile"
1127 echo '
1128 #include <stdio.h>
1129 int main(){ printf("1%c", (char)0x0a); return 0; }
1130 ' > "test.c"
1131 cmake_original_make_flags="${cmake_make_flags}"
1132 if [ "x${cmake_parallel_make}" != "x" ]; then
1133   cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
1134 fi
1135 for a in ${cmake_make_processors}; do
1136   if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
1137     cmake_make_processor="${a}"
1138   fi
1139 done
1140 cmake_full_make_flags="${cmake_make_flags}"
1141 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
1142   if [ -z "${cmake_make_processor}" ]; then
1143     cmake_make_flags="${cmake_original_make_flags}"
1144     for a in ${cmake_make_processors}; do
1145       if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
1146         cmake_make_processor="${a}"
1147       fi
1148     done
1149   fi
1150 fi
1151 cd "${cmake_bootstrap_dir}"
1152
1153 if [ -z "${cmake_make_processor}" ]; then
1154   cmake_error 8 "Cannot find appropriate Makefile processor on this system.
1155 Please specify one using environment variable MAKE."
1156 fi
1157 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
1158 echo "Makefile processor on this system is: ${cmake_make_processor}"
1159 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
1160   echo "---------------------------------------------"
1161   echo "Makefile processor ${cmake_make_processor} does not support parallel build"
1162   echo "---------------------------------------------"
1163 fi
1164
1165 # Test for kwsys features
1166 KWSYS_NAME_IS_KWSYS=0
1167 KWSYS_BUILD_SHARED=0
1168 KWSYS_LFS_AVAILABLE=0
1169 KWSYS_LFS_REQUESTED=0
1170 KWSYS_STL_HAS_WSTRING=0
1171 KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H=0
1172 KWSYS_CXX_HAS_SETENV=0
1173 KWSYS_CXX_HAS_UNSETENV=0
1174 KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
1175 KWSYS_CXX_HAS_UTIMENSAT=0
1176 KWSYS_CXX_HAS_UTIMES=0
1177
1178 if cmake_try_run "${cmake_cxx_compiler}" \
1179   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
1180   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1181   KWSYS_CXX_HAS_SETENV=1
1182   echo "${cmake_cxx_compiler} has setenv"
1183 else
1184   echo "${cmake_cxx_compiler} does not have setenv"
1185 fi
1186
1187 if cmake_try_run "${cmake_cxx_compiler}" \
1188   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
1189   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1190   KWSYS_CXX_HAS_UNSETENV=1
1191   echo "${cmake_cxx_compiler} has unsetenv"
1192 else
1193   echo "${cmake_cxx_compiler} does not have unsetenv"
1194 fi
1195
1196 if cmake_try_run "${cmake_cxx_compiler}" \
1197   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
1198   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1199   KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
1200   echo "${cmake_cxx_compiler} has environ in stdlib.h"
1201 else
1202   echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
1203 fi
1204
1205 if cmake_try_run "${cmake_cxx_compiler}" \
1206   "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_WSTRING" \
1207   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1208   KWSYS_STL_HAS_WSTRING=1
1209   echo "${cmake_cxx_compiler} has stl wstring"
1210 else
1211   echo "${cmake_cxx_compiler} does not have stl wstring"
1212 fi
1213
1214 if cmake_try_run "${cmake_cxx_compiler}" \
1215   "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H" \
1216   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1217   KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H=1
1218   echo "${cmake_cxx_compiler} has <ext/stdio_filebuf.h>"
1219 else
1220   echo "${cmake_cxx_compiler} does not have <ext/stdio_filebuf.h>"
1221 fi
1222
1223 # Just to be safe, let us store compiler and flags to the header file
1224
1225 cmake_bootstrap_version='$Revision$'
1226 cmake_compiler_settings_comment="/*
1227  * Generated by ${cmake_source_dir}/bootstrap
1228  * Version:     ${cmake_bootstrap_version}
1229  *
1230  * Source directory: ${cmake_source_dir}
1231  * Binary directory: ${cmake_bootstrap_dir}
1232  *
1233  * C compiler:   ${cmake_c_compiler}
1234  * C flags:      ${cmake_c_flags}
1235  *
1236  * C++ compiler: ${cmake_cxx_compiler}
1237  * C++ flags:    ${cmake_cxx_flags}
1238  *
1239  * Make:         ${cmake_make_processor}
1240  *
1241  * Sources:
1242  * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1243  * LexerParser Sources:
1244  * ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES}
1245  * kwSys Sources:
1246  * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
1247  * libuv Sources:
1248  * ${LIBUV_C_SOURCES}
1249  */
1250 "
1251
1252 cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
1253
1254 # When bootstrapping on MinGW with MSYS we must convert the source
1255 # directory to a windows path.
1256 if ${cmake_system_mingw}; then
1257     CMAKE_BOOTSTRAP_SOURCE_DIR=`cd "${cmake_source_dir}"; pwd -W`
1258     CMAKE_BOOTSTRAP_BINARY_DIR=`cd "${cmake_binary_dir}"; pwd -W`
1259 else
1260     CMAKE_BOOTSTRAP_SOURCE_DIR="${cmake_source_dir}"
1261     CMAKE_BOOTSTRAP_BINARY_DIR="${cmake_binary_dir}"
1262 fi
1263
1264 # Write CMake version
1265 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1266 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1267 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1268 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
1269 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
1270 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
1271 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\""
1272 cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
1273 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
1274 cmake_report cmConfigure.h${_tmp} "#define CM_FALLTHROUGH"
1275 cmake_report cmConfigure.h${_tmp} "#define CM_DISABLE_COPY(Class)"
1276
1277 # Regenerate configured headers
1278 for h in Configure VersionConfig; do
1279   if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
1280     rm -f cm${h}.h${_tmp}
1281   else
1282     mv -f cm${h}.h${_tmp} cm${h}.h
1283   fi
1284 done
1285
1286 # Prepare KWSYS
1287 cmake_kwsys_config_replace_string \
1288   "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1289   "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1290   "${cmake_compiler_settings_comment}"
1291 cmake_kwsys_config_replace_string \
1292   "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1293   "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1294   "${cmake_compiler_settings_comment}"
1295
1296 for a in ${KWSYS_FILES}; do
1297   cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1298      "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1299 done
1300
1301 cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" ""
1302
1303 # Generate Makefile
1304 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1305 objs=""
1306 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
1307   objs="${objs} ${a}.o"
1308 done
1309 for a in ${LIBUV_C_SOURCES}; do
1310   objs="${objs} uv-`cmake_obj ${a}`"
1311 done
1312
1313 libs=""
1314
1315 uv_c_flags=""
1316 if ${cmake_system_mingw}; then
1317   uv_c_flags="${uv_c_flags} -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600"
1318   libs="${libs} -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv"
1319 else
1320   uv_c_flags="${uv_c_flags} -DCMAKE_BOOTSTRAP"
1321   case "${cmake_system}" in
1322     *AIX*)
1323       uv_c_flags="${uv_c_flags} -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT -D_THREAD_SAFE"
1324       libs="${libs} -lperfstat"
1325       ;;
1326     *Darwin*)
1327       uv_c_flags="${uv_c_flags} -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1"
1328       ;;
1329     *Linux*)
1330       uv_c_flags="${uv_c_flags} -D_GNU_SOURCE"
1331       libs="${libs} -ldl -lrt"
1332       ;;
1333     *BSD*)
1334       libs="${libs} -lkvm"
1335       ;;
1336     *SunOS*)
1337       # Normally libuv uses '-D_XOPEN_SOURCE=500 -std=c90' on Solaris 5.10,
1338       # but we do not need to do that because we bootstrap using POSIX APIs.
1339       uv_c_flags="${uv_c_flags} -D__EXTENSIONS__ -D_XOPEN_SOURCE=600"
1340       libs="${libs} -lkstat -lnsl -lsendfile -lsocket -lrt"
1341       ;;
1342   esac
1343 fi
1344 uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/include"`"
1345 if ${cmake_system_mingw}; then
1346   uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/win"`"
1347 else
1348   uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/unix"`"
1349 fi
1350 uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src"`"
1351
1352 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1353   cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1354 fi
1355
1356 if [ "x${cmake_c_flags}" != "x" ]; then
1357   cmake_c_flags="${cmake_c_flags} "
1358 fi
1359
1360 if [ "x${cmake_cxx_flags}" != "x" ]; then
1361   cmake_cxx_flags="${cmake_cxx_flags} "
1362 fi
1363
1364 cmake_c_flags_String="-DKWSYS_STRING_C"
1365 if ${cmake_system_mingw}; then
1366   cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP"
1367   cmake_cxx_flags_EncodingCXX="${cmake_c_flags_EncodingC}"
1368   cmake_cxx_flags_cmProcessOutput="${cmake_c_flags_EncodingC}"
1369 fi
1370 cmake_cxx_flags_SystemTools="
1371   -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
1372   -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
1373   -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
1374   -DKWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
1375   -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
1376 "
1377 cmake_c_flags="${cmake_c_flags} \
1378   -I`cmake_escape \"${cmake_bootstrap_dir}\"` \
1379   -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1380   -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \
1381   -I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
1382 cmake_cxx_flags="${cmake_cxx_flags} \
1383   -I`cmake_escape \"${cmake_bootstrap_dir}\"` \
1384   -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1385   -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \
1386   -I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
1387 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1388 echo "  ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1389 for a in ${CMAKE_CXX_SOURCES}; do
1390   src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1391   src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
1392   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1393   echo "        ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1394 done
1395 for a in ${CMAKE_C_SOURCES}; do
1396   src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1397   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1398   echo "        ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1399 done
1400 for a in ${LexerParser_CXX_SOURCES}; do
1401   src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.cxx"`
1402   src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
1403   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1404   echo "        ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1405 done
1406 for a in ${LexerParser_C_SOURCES}; do
1407   src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.c"`
1408   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1409   echo "        ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1410 done
1411 for a in ${KWSYS_C_SOURCES}; do
1412   src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1413   src_flags=`eval echo \\${cmake_c_flags_\${a}}`
1414   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1415   echo "        ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1416 done
1417 for a in ${KWSYS_CXX_SOURCES}; do
1418   src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1419   src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
1420   echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1421   echo "        ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1422 done
1423 for a in ${LIBUV_C_SOURCES}; do
1424   src=`cmake_escape "${cmake_source_dir}/Utilities/cmlibuv/${a}"`
1425   echo "uv-`cmake_obj ${a}` : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1426   echo "        ${cmake_c_compiler} ${cmake_c_flags} ${uv_c_flags} -c ${src} -o uv-`cmake_obj ${a}`" >> "${cmake_bootstrap_dir}/Makefile"
1427 done
1428 echo '
1429 rebuild_cache:
1430         cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1431 ' >> "${cmake_bootstrap_dir}/Makefile"
1432
1433 # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
1434 echo '
1435 # Generated by '"${cmake_source_dir}"'/bootstrap
1436 # Default cmake settings.  These may be overridden any settings below.
1437 set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1438 set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1439 set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1440 set (CMAKE_BIN_DIR "'"${cmake_bin_dir}"'" CACHE PATH "Install location for binaries (relative to prefix)." FORCE)
1441 set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1442 set (CMAKE_XDGDATA_DIR "'"${cmake_xdgdata_dir}"'" CACHE PATH "Install location for XDG specific files (relative to prefix)." FORCE)
1443 ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1444
1445 # Add configuration settings given as command-line options.
1446 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1447   echo '
1448 set (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
1449 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1450 fi
1451 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1452   echo '
1453 set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
1454 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1455 fi
1456 if [ "x${cmake_sphinx_man}" != "x" ]; then
1457   echo '
1458 set (SPHINX_MAN "'"${cmake_sphinx_man}"'" CACHE BOOL "Build man pages with Sphinx" FORCE)
1459 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1460 fi
1461 if [ "x${cmake_sphinx_html}" != "x" ]; then
1462   echo '
1463 set (SPHINX_HTML "'"${cmake_sphinx_html}"'" CACHE BOOL "Build html help with Sphinx" FORCE)
1464 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1465 fi
1466 if [ "x${cmake_sphinx_qthelp}" != "x" ]; then
1467   echo '
1468 set (SPHINX_QTHELP "'"${cmake_sphinx_qthelp}"'" CACHE BOOL "Build qch help with Sphinx" FORCE)
1469 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1470 fi
1471 if [ "x${cmake_sphinx_build}" != "x" ]; then
1472   echo '
1473 set (SPHINX_EXECUTABLE "'"${cmake_sphinx_build}"'" CACHE FILEPATH "Location of Qt sphinx-build" FORCE)
1474 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1475 fi
1476 if [ "x${cmake_sphinx_flags}" != "x" ]; then
1477   echo '
1478 set (SPHINX_FLAGS [==['"${cmake_sphinx_flags}"']==] CACHE STRING "Flags to pass to sphinx-build" FORCE)
1479 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1480 fi
1481
1482 # Add user-specified settings.  Handle relative-path case for
1483 # specification of cmake_init_file.
1484 (
1485 cd "${cmake_binary_dir}"
1486 if [ -f "${cmake_init_file}" ]; then
1487   cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1488 fi
1489 )
1490
1491 echo "---------------------------------------------"
1492
1493 # Run make to build bootstrap cmake
1494 if [ "x${cmake_parallel_make}" != "x" ]; then
1495   ${cmake_make_processor} ${cmake_make_flags}
1496 else
1497   ${cmake_make_processor}
1498 fi
1499 RES=$?
1500 if [ "${RES}" -ne "0" ]; then
1501   cmake_error 9 "Problem while running ${cmake_make_processor}"
1502 fi
1503 cd "${cmake_binary_dir}"
1504
1505 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1506 # build with same compiler and make
1507 CC="${cmake_c_compiler}"
1508 CXX="${cmake_cxx_compiler}"
1509 if [ -n "${cmake_ccache_enabled}" ]; then
1510   CC="ccache ${CC}"
1511   CXX="ccache ${CXX}"
1512 fi
1513 MAKE="${cmake_make_processor}"
1514 export CC
1515 export CXX
1516 export MAKE
1517
1518 # Run bootstrap CMake to configure real CMake
1519 cmake_options="-DCMAKE_BOOTSTRAP=1"
1520 if [ -n "${cmake_verbose}" ]; then
1521   cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1"
1522 fi
1523 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@"
1524 RES=$?
1525 if [ "${RES}" -ne "0" ]; then
1526   cmake_error 11 "Problem while running initial CMake"
1527 fi
1528
1529 echo "---------------------------------------------"
1530
1531 # And we are done. Now just run make
1532 echo "CMake has bootstrapped.  Now run ${cmake_make_processor}."