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