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