bootstrap 50.2 KB
Newer Older
1
#!/bin/sh
2 3
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
4

5 6 7 8
die() {
  echo "$@" 1>&2 ; exit 1
}

9 10 11
# Compile flag extraction function.
cmake_extract_standard_flags()
{
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 17 18
# Version number extraction function.
cmake_version_component()
{
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 25 26
# Install destination extraction function.
cmake_install_dest_default()
{
27
  sed -n '
28
/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ {
29 30 31 32 33 34 35
  s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/
  s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/
  s/${CMake_VERSION_MINOR}/'"${cmake_version_minor}"'/
  s/${CMake_VERSION_PATCH}/'"${cmake_version_patch}"'/
  p
  q
}
36
' "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake"
37 38
}

39 40
cmake_toupper()
{
41
    echo "$1" | tr '[:lower:]' '[:upper:]'
42 43
}

44 45
# Detect system and directory information.
cmake_system=`uname`
46
cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
47
cmake_binary_dir=`pwd`
48 49

# Load version information.
50 51
cmake_version_major="`cmake_version_component MAJOR`"
cmake_version_minor="`cmake_version_component MINOR`"
52 53
cmake_version_patch="`cmake_version_component PATCH`"
cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
54 55 56 57
cmake_version_rc="`cmake_version_component RC`"
if [ "$cmake_version_rc" != "" ]; then
  cmake_version="${cmake_version}-rc${cmake_version_rc}"
fi
58

59 60
cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`"

61
cmake_bin_dir_keyword="OTHER"
62 63 64
cmake_data_dir_keyword="OTHER"
cmake_doc_dir_keyword="OTHER"
cmake_man_dir_keyword="OTHER"
65
cmake_xdgdata_dir_keyword="OTHER"
66
cmake_bin_dir=""
67 68 69
cmake_data_dir=""
cmake_doc_dir=""
cmake_man_dir=""
70
cmake_xdgdata_dir=""
71
cmake_init_file=""
72
cmake_bootstrap_system_libs=""
73 74
cmake_bootstrap_qt_gui=""
cmake_bootstrap_qt_qmake=""
75
cmake_sphinx_info=""
76 77
cmake_sphinx_man=""
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 86
  cmake_doc_dir_keyword="CYGWIN"
  cmake_man_dir_keyword="CYGWIN"
87 88 89 90
else
  cmake_system_cygwin=false
fi

91
# Determine whether this is a MinGW environment.
92
if echo "${cmake_system}" | grep 'MINGW\|MSYS' >/dev/null 2>&1; then
93 94 95 96 97
  cmake_system_mingw=true
else
  cmake_system_mingw=false
fi

98
# Determine whether this is OS X
99
if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
100 101 102 103 104
  cmake_system_darwin=true
else
  cmake_system_darwin=false
fi

105
# Determine whether this is BeOS
106
if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
107
  cmake_system_beos=true
108 109
  cmake_doc_dir_keyword="HAIKU"
  cmake_man_dir_keyword="HAIKU"
110 111 112 113
else
  cmake_system_beos=false
fi

114
# Determine whether this is Haiku
115
if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
116
  cmake_system_haiku=true
117 118
  cmake_doc_dir_keyword="HAIKU"
  cmake_man_dir_keyword="HAIKU"
119 120 121 122
else
  cmake_system_haiku=false
fi

123
# Determine whether this is OpenVMS
124
if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
125 126 127 128 129
  cmake_system_openvms=true
else
  cmake_system_openvms=false
fi

130
# Determine whether this is HP-UX
131
if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then
132 133 134 135 136
  die 'CMake no longer compiles on HP-UX.  See

  https://gitlab.kitware.com/cmake/cmake/issues/17137

Use CMake 3.9 or lower instead.'
137 138 139 140 141
  cmake_system_hpux=true
else
  cmake_system_hpux=false
fi

142
# Determine whether this is Linux
143
if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
144
  cmake_system_linux=true
145 146 147 148 149 150 151 152 153
else
  cmake_system_linux=false
 fi

# Determine whether this is a PA-RISC machine
# This only works for Linux or HP-UX, not other PA-RISC OSs (BSD maybe?). Also
# may falsely detect parisc on HP-UX m68k
cmake_machine_parisc=false
if ${cmake_system_linux}; then
154
  if uname -m | grep parisc >/dev/null 2>&1; then
155 156
    cmake_machine_parisc=true
  fi
157
elif ${cmake_system_hpux}; then
158
  if uname -m | grep ia64 >/dev/null 2>&1; then : ; else
159 160
    cmake_machine_parisc=true
  fi
161 162
fi

163 164 165 166 167 168 169 170 171
# Choose the generator to use for bootstrapping.
if ${cmake_system_mingw}; then
  # Bootstrapping from an MSYS prompt.
  cmake_bootstrap_generator="MSYS Makefiles"
else
  # Bootstrapping from a standard UNIX prompt.
  cmake_bootstrap_generator="Unix Makefiles"
fi

172 173 174 175 176 177 178 179 180 181 182 183 184 185
# Choose tools and extensions for this platform.
if ${cmake_system_openvms}; then
  _tmp="_tmp"
  _cmk="_cmk"
  _diff=`which diff`
else
  _tmp=".tmp"
  _cmk=".cmk"
  _diff="diff"
fi

# Construct bootstrap directory name.
cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"

186
# Helper function to fix windows paths.
187 188 189 190 191 192 193 194 195 196 197 198 199 200
case "${cmake_system}" in
*MINGW*)
  cmake_fix_slashes()
  {
    cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
  }
  ;;
*)
  cmake_fix_slashes()
  {
    echo "$1" | sed 's/\\/\//g'
  }
  ;;
esac
201 202 203 204 205 206 207 208 209 210 211 212 213 214

# Choose the default install prefix.
if ${cmake_system_mingw}; then
  if [ "x${PROGRAMFILES}" != "x" ]; then
    cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
  elif [ "x${ProgramFiles}" != "x" ]; then
    cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
  elif [ "x${SYSTEMDRIVE}" != "x" ]; then
    cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
  elif [ "x${SystemDrive}" != "x" ]; then
    cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
  else
    cmake_default_prefix="c:/Program Files/CMake"
  fi
215
elif ${cmake_system_haiku}; then
216
  cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
217 218 219 220
else
  cmake_default_prefix="/usr/local"
fi

221
# Lookup default install destinations.
222
cmake_bin_dir_default="`cmake_install_dest_default BIN ${cmake_bin_dir_keyword}`"
223 224 225
cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`"
cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`"
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 229
CMAKE_KNOWN_C_COMPILERS="cc gcc clang xlc icc tcc"
CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ clang++ c++ icc como "
Bill Hoffman's avatar
Bill Hoffman committed
230
CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
231

232 233 234 235 236
CMAKE_PROBLEMATIC_FILES="\
  CMakeCache.txt \
  CMakeSystem.cmake \
  CMakeCCompiler.cmake \
  CMakeCXXCompiler.cmake \
237 238 239
  */CMakeSystem.cmake \
  */CMakeCCompiler.cmake \
  */CMakeCXXCompiler.cmake \
240 241 242 243 244 245
  Source/cmConfigure.h \
  Source/CTest/Curl/config.h \
  Utilities/cmexpat/expatConfig.h \
  Utilities/cmexpat/expatDllConfig.h \
  "

246 247 248 249 250 251 252 253
CMAKE_UNUSED_SOURCES="\
  cmGlobalXCodeGenerator \
  cmLocalXCodeGenerator \
  cmXCodeObject \
  cmXCode21Object \
  cmSourceGroup \
"

254
CMAKE_CXX_SOURCES="\
255 256 257 258 259 260 261 262
  cmAddCustomCommandCommand \
  cmAddCustomTargetCommand \
  cmAddDefinitionsCommand \
  cmAddDependenciesCommand \
  cmAddExecutableCommand \
  cmAddLibraryCommand \
  cmAddSubDirectoryCommand \
  cmAddTestCommand \
wahikihiki's avatar
wahikihiki committed
263
  cmArgumentParser \
264 265 266 267 268 269 270 271 272 273 274
  cmBinUtilsLinker \
  cmBinUtilsLinuxELFGetRuntimeDependenciesTool \
  cmBinUtilsLinuxELFLinker \
  cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool \
  cmBinUtilsMacOSMachOGetRuntimeDependenciesTool \
  cmBinUtilsMacOSMachOLinker \
  cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool \
  cmBinUtilsWindowsPEGetRuntimeDependenciesTool \
  cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool \
  cmBinUtilsWindowsPELinker \
  cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool \
275 276 277 278
  cmBreakCommand \
  cmBuildCommand \
  cmCMakeMinimumRequired \
  cmCMakePolicyCommand \
279 280
  cmCPackPropertiesGenerator \
  cmCacheManager \
281
  cmCommand \
282 283 284 285 286 287 288 289
  cmCommandArgumentParserHelper \
  cmCommands \
  cmCommonTargetGenerator \
  cmComputeComponentGraph \
  cmComputeLinkDepends \
  cmComputeLinkInformation \
  cmComputeTargetDepends \
  cmConditionEvaluator \
290 291 292 293
  cmConfigureFileCommand \
  cmContinueCommand \
  cmCoreTryCompile \
  cmCreateTestSourceList \
294 295
  cmCustomCommand \
  cmCustomCommandGenerator \
296
  cmDefinePropertyCommand \
297 298 299
  cmDefinitions \
  cmDepends \
  cmDependsC \
300
  cmDisallowedCommand \
301
  cmDocumentationFormatter \
302 303 304 305
  cmEnableLanguageCommand \
  cmEnableTestingCommand \
  cmExecProgramCommand \
  cmExecuteProcessCommand \
306 307 308 309 310 311 312 313 314
  cmExpandedCommandArgument \
  cmExportBuildFileGenerator \
  cmExportFileGenerator \
  cmExportInstallFileGenerator \
  cmExportSet \
  cmExportSetMap \
  cmExportTryCompileFileGenerator \
  cmExprParserHelper \
  cmExternalMakefileProjectGenerator \
315
  cmFileCommand \
316 317
  cmFileCopier \
  cmFileInstaller \
Sebastian Holtermann's avatar
Sebastian Holtermann committed
318
  cmFileTime \
319
  cmFileTimeCache \
320
  cmFileTimes \
321 322 323 324 325 326 327 328
  cmFindBase \
  cmFindCommon \
  cmFindFileCommand \
  cmFindLibraryCommand \
  cmFindPackageCommand \
  cmFindPathCommand \
  cmFindProgramCommand \
  cmForEachCommand \
329
  cmFunctionBlocker \
330
  cmFunctionCommand \
331
  cmFSPermissions \
332 333 334 335 336 337 338 339 340 341
  cmGeneratedFileStream \
  cmGeneratorExpression \
  cmGeneratorExpressionContext \
  cmGeneratorExpressionDAGChecker \
  cmGeneratorExpressionEvaluationFile \
  cmGeneratorExpressionEvaluator \
  cmGeneratorExpressionLexer \
  cmGeneratorExpressionNode \
  cmGeneratorExpressionParser \
  cmGeneratorTarget \
342 343 344
  cmGetCMakePropertyCommand \
  cmGetDirectoryPropertyCommand \
  cmGetFilenameComponentCommand \
345
  cmGetPipes \
346 347 348 349
  cmGetPropertyCommand \
  cmGetSourceFilePropertyCommand \
  cmGetTargetPropertyCommand \
  cmGetTestPropertyCommand \
350 351 352
  cmGlobalCommonGenerator \
  cmGlobalGenerator \
  cmGlobalUnixMakefileGenerator3 \
353
  cmGlobVerificationManager \
354 355 356
  cmHexFileConverter \
  cmIfCommand \
  cmIncludeCommand \
357
  cmIncludeGuardCommand \
358 359 360 361
  cmIncludeDirectoryCommand \
  cmIncludeRegularExpressionCommand \
  cmInstallCommand \
  cmInstallCommandArguments \
362 363
  cmInstallDirectoryGenerator \
  cmInstallExportGenerator \
364
  cmInstallFilesCommand \
365 366 367
  cmInstallFilesGenerator \
  cmInstallGenerator \
  cmInstallScriptGenerator \
368
  cmInstallSubdirectoryGenerator \
369
  cmInstallTargetGenerator \
370
  cmInstallTargetsCommand \
371
  cmInstalledFile \
372 373
  cmLDConfigLDConfigTool \
  cmLDConfigTool \
374
  cmLinkDirectoriesCommand \
375
  cmLinkItem \
376
  cmLinkLineComputer \
377
  cmLinkLineDeviceComputer \
378
  cmListCommand \
379 380 381 382 383
  cmListFileCache \
  cmLocalCommonGenerator \
  cmLocalGenerator \
  cmLocalUnixMakefileGenerator3 \
  cmMSVC60LinkLineComputer \
384 385
  cmMacroCommand \
  cmMakeDirectoryCommand \
386 387 388 389 390
  cmMakefile \
  cmMakefileExecutableTargetGenerator \
  cmMakefileLibraryTargetGenerator \
  cmMakefileTargetGenerator \
  cmMakefileUtilityTargetGenerator \
391 392 393
  cmMarkAsAdvancedCommand \
  cmMathCommand \
  cmMessageCommand \
394 395 396
  cmMessenger \
  cmNewLineStyle \
  cmOSXBundleGenerator \
397
  cmOptionCommand \
398 399 400 401 402
  cmOrderDirectories \
  cmOutputConverter \
  cmParseArgumentsCommand \
  cmPathLabel \
  cmPolicies \
403
  cmProcessOutput \
404
  cmProjectCommand \
405 406 407
  cmPropertyDefinition \
  cmPropertyDefinitionMap \
  cmPropertyMap \
408
  cmReturnCommand \
409
  cmRulePlaceholderExpander \
410
  cmRuntimeDependencyArchive \
411 412
  cmScriptGenerator \
  cmSearchPath \
413 414 415 416 417 418 419 420
  cmSeparateArgumentsCommand \
  cmSetCommand \
  cmSetDirectoryPropertiesCommand \
  cmSetPropertyCommand \
  cmSetSourceFilesPropertiesCommand \
  cmSetTargetPropertiesCommand \
  cmSetTestsPropertiesCommand \
  cmSiteNameCommand \
421 422 423 424 425
  cmSourceFile \
  cmSourceFileLocation \
  cmState \
  cmStateDirectory \
  cmStateSnapshot \
426
  cmStringAlgorithms \
427
  cmStringReplaceHelper \
428
  cmStringCommand \
wahikihiki's avatar
wahikihiki committed
429
  cmSubcommandTable \
430
  cmSubdirCommand \
431 432
  cmSystemTools \
  cmTarget \
433 434 435 436
  cmTargetCompileDefinitionsCommand \
  cmTargetCompileFeaturesCommand \
  cmTargetCompileOptionsCommand \
  cmTargetIncludeDirectoriesCommand \
437
  cmTargetLinkLibrariesCommand \
438
  cmTargetPropCommandBase \
439
  cmTargetPropertyComputer \
440
  cmTargetSourcesCommand \
441 442
  cmTest \
  cmTestGenerator \
443 444 445 446
  cmTimestamp \
  cmTryCompileCommand \
  cmTryRunCommand \
  cmUnsetCommand \
447
  cmUVHandlePtr \
448
  cmUVProcessChain \
449
  cmVersion \
450
  cmWhileCommand \
451
  cmWorkingDirectory \
452 453 454
  cmake  \
  cmakemain \
  cmcmd  \
455
  cm_string_view \
456
"
457

458 459 460
if ${cmake_system_mingw}; then
  CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
    cmGlobalMSYSMakefileGenerator \
461 462 463
    cmGlobalMinGWMakefileGenerator \
    cmVSSetupHelper \
  "
464 465
fi

466 467 468 469 470 471 472 473 474 475
LexerParser_CXX_SOURCES="\
  cmCommandArgumentLexer \
  cmCommandArgumentParser \
  cmExprLexer \
  cmExprParser \
"

LexerParser_C_SOURCES="\
  cmListFileLexer \
"
476

477 478
if ${cmake_system_mingw}; then
  KWSYS_C_SOURCES="\
479
    EncodingC \
480
    ProcessWin32 \
481
    String \
482 483
    System \
    Terminal"
484 485
else
  KWSYS_C_SOURCES="\
486
    EncodingC \
487
    ProcessUNIX \
488
    String \
489 490
    System \
    Terminal"
491
fi
492 493

KWSYS_CXX_SOURCES="\
Brad King's avatar
Brad King committed
494
  Directory \
495
  EncodingCXX \
496
  FStream \
Andy Cedilnik's avatar
Andy Cedilnik committed
497
  Glob \
Brad King's avatar
Brad King committed
498 499 500 501 502
  RegularExpression \
  SystemTools"

KWSYS_FILES="\
  Directory.hxx \
503 504 505
  Encoding.h \
  Encoding.hxx \
  FStream.hxx \
Andy Cedilnik's avatar
Andy Cedilnik committed
506
  Glob.hxx \
Brad King's avatar
Brad King committed
507 508
  Process.h \
  RegularExpression.hxx \
509
  String.h \
510
  String.hxx \
511
  System.h \
512 513
  SystemTools.hxx \
  Terminal.h"
Brad King's avatar
Brad King committed
514

515 516 517
if ${cmake_system_mingw}; then
  LIBUV_C_SOURCES="\
    src/fs-poll.c \
518
    src/idna.c
519 520
    src/inet.c \
    src/threadpool.c \
521 522
    src/strscpy.c \
    src/timer.c \
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    src/uv-common.c \
    src/win/async.c \
    src/win/core.c \
    src/win/detect-wakeup.c \
    src/win/dl.c \
    src/win/error.c \
    src/win/fs-event.c \
    src/win/fs.c \
    src/win/getaddrinfo.c \
    src/win/getnameinfo.c \
    src/win/handle.c \
    src/win/loop-watcher.c \
    src/win/pipe.c \
    src/win/poll.c \
    src/win/process-stdio.c \
    src/win/process.c \
    src/win/signal.c \
    src/win/stream.c \
    src/win/tcp.c \
    src/win/thread.c \
    src/win/tty.c \
    src/win/udp.c \
    src/win/util.c \
    src/win/winapi.c \
    src/win/winsock.c \
    "
else
  LIBUV_C_SOURCES="\
551 552
    src/strscpy.c \
    src/timer.c \
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
    src/uv-common.c \
    src/unix/cmake-bootstrap.c \
    src/unix/core.c \
    src/unix/fs.c \
    src/unix/loop.c \
    src/unix/loop-watcher.c \
    src/unix/no-fsevents.c \
    src/unix/pipe.c \
    src/unix/poll.c \
    src/unix/posix-hrtime.c \
    src/unix/posix-poll.c \
    src/unix/process.c \
    src/unix/signal.c \
    src/unix/stream.c \
    "
fi

570
# Display CMake bootstrap usage
571 572
cmake_usage()
{
573
echo '
574
Usage: '"$0"' [<options>...] [-- <cmake-options>...]
575 576 577
Options: [defaults in brackets after descriptions]
Configuration:
  --help                  print this message
578
  --version               only print version information
579
  --verbose               display more information
580 581
  --parallel=n            bootstrap cmake in parallel, where n is
                          number of nodes [1]
582
  --enable-ccache         Enable ccache when building cmake
583
  --init=FILE             load FILE as script to populate cache
584
  --system-libs           use all system-installed third-party libraries
585
                          (for use only by package maintainers)
586
  --no-system-libs        use all cmake-provided third-party libraries
587
                          (default)
588 589 590 591
  --system-curl           use system-installed curl library
  --no-system-curl        use cmake-provided curl library (default)
  --system-expat          use system-installed expat library
  --no-system-expat       use cmake-provided expat library (default)
592 593
  --system-jsoncpp        use system-installed jsoncpp library
  --no-system-jsoncpp     use cmake-provided jsoncpp library (default)
594 595 596 597
  --system-zlib           use system-installed zlib library
  --no-system-zlib        use cmake-provided zlib library (default)
  --system-bzip2          use system-installed bzip2 library
  --no-system-bzip2       use cmake-provided bzip2 library (default)
598 599
  --system-liblzma        use system-installed liblzma library
  --no-system-liblzma     use cmake-provided liblzma library (default)
600 601
  --system-zstd           use system-installed zstd library
  --no-system-zstd        use cmake-provided zstd library (default)
602 603
  --system-libarchive     use system-installed libarchive library
  --no-system-libarchive  use cmake-provided libarchive library (default)
604 605
  --system-librhash       use system-installed librhash library
  --no-system-librhash    use cmake-provided librhash library (default)
606 607
  --system-libuv          use system-installed libuv library
  --no-system-libuv       use cmake-provided libuv library (default)
608

609 610 611
  --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
  --no-qt-gui             do not build the Qt-based GUI (default)
  --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt
612

613
  --sphinx-info           build Info manual with Sphinx
614 615
  --sphinx-man            build man pages with Sphinx
  --sphinx-html           build html help with Sphinx
616
  --sphinx-qthelp         build qch help with Sphinx
617
  --sphinx-build=<sb>     use <sb> as the sphinx-build executable
618
  --sphinx-flags=<flags>  pass <flags> to sphinx-build executable
619

620
Directory and file names:
621
  --prefix=PREFIX         install files in tree rooted at PREFIX
622
                          ['"${cmake_default_prefix}"']
623 624
  --bindir=DIR            install binaries in PREFIX/DIR
                          ['"${cmake_bin_dir_default}"']
625
  --datadir=DIR           install data files in PREFIX/DIR
626
                          ['"${cmake_data_dir_default}"']
627
  --docdir=DIR            install documentation files in PREFIX/DIR
628
                          ['"${cmake_doc_dir_default}"']
629
  --mandir=DIR            install man pages files in PREFIX/DIR/manN
630
                          ['"${cmake_man_dir_default}"']
631 632
  --xdgdatadir=DIR        install XDG specific files in PREFIX/DIR
                          ['"${cmake_xdgdata_dir_default}"']
633
'
634 635 636
  exit 10
}

637
# Display CMake bootstrap usage
638
cmake_version_display()
639
{
640
  echo "CMake ${cmake_version}, ${cmake_copyright}"
641 642 643
}

# Display CMake bootstrap error, display the log file and exit
644 645
cmake_error()
{
646 647
  res=$1
  shift 1
648
  echo "---------------------------------------------"
649
  echo "Error when bootstrapping CMake:"
650 651 652
  echo "$*"
  echo "---------------------------------------------"
  if [ -f cmake_bootstrap.log ]; then
653 654
    echo "Log of errors: `pwd`/cmake_bootstrap.log"
    #cat cmake_bootstrap.log
655 656
    echo "---------------------------------------------"
  fi
657
  exit ${res}
658
}
659

660 661 662 663 664 665 666 667 668 669 670 671
cmake_generate_file ()
{
  OUTFILE="$1"
  CONTENT="$2"
  echo "$CONTENT" > "$OUTFILE.tmp"
  if "${_diff}" "$OUTFILE.tmp" "$OUTFILE" > /dev/null 2> /dev/null ; then
    rm -f "$OUTFILE.tmp"
  else
    mv -f "$OUTFILE.tmp" "$OUTFILE"
  fi
}

672 673 674 675 676 677 678
# Replace KWSYS_NAMESPACE with cmsys
cmake_replace_string ()
{
  INFILE="$1"
  OUTFILE="$2"
  SEARCHFOR="$3"
  REPLACEWITH="$4"
679
  if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
680
    sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" "${INFILE}" > "${OUTFILE}${_tmp}"
681 682
    if [ -f "${OUTFILE}${_tmp}" ]; then
      if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
683
        #echo "Files are the same"
684
        rm -f "${OUTFILE}${_tmp}"
685
      else
686
        mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
687 688
      fi
    fi
Brad King's avatar
Brad King committed
689
  else
690
    cmake_error 1 "Cannot find file ${INFILE}"
691 692 693
  fi
}

694 695 696 697 698 699
cmake_kwsys_config_replace_string ()
{
  INFILE="$1"
  OUTFILE="$2"
  shift 2
  APPEND="$*"
700 701
  if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
    echo "${APPEND}" > "${OUTFILE}${_tmp}"
702 703 704 705 706 707 708
    sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
              s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
              s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
              s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
              s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
              s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
              s/@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@/${KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H}/g;
709
              s/@KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP@/${KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP}/g;
710
             }" "${INFILE}" >> "${OUTFILE}${_tmp}"
711 712
    if [ -f "${OUTFILE}${_tmp}" ]; then
      if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
713
        #echo "Files are the same"
714
        rm -f "${OUTFILE}${_tmp}"
715
      else
716
        mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
717 718 719 720 721 722
      fi
    fi
  else
    cmake_error 2 "Cannot find file ${INFILE}"
  fi
}
723
# Write string into a file
724 725 726 727 728 729 730
cmake_report ()
{
  FILE=$1
  shift
  echo "$*" >> ${FILE}
}

731
# Escape spaces in strings
732 733 734 735 736
cmake_escape ()
{
  echo $1 | sed "s/ /\\\\ /g"
}

737 738 739 740 741 742
# Encode object file names.
cmake_obj ()
{
  echo $1 | sed 's/\//-/g' | sed 's/$/\.o/'
}

743 744 745 746 747 748
# Strip prefix from argument
cmake_arg ()
{
  echo "$1" | sed "s/^${2-[^=]*=}//"
}

749
# Write message to the log
750 751 752 753 754
cmake_log ()
{
  echo "$*" >> cmake_bootstrap.log
}

755
# Return temp file
756 757
cmake_tmp_file ()
{
758
  echo "cmake_bootstrap_$$_test"
759 760
}

761 762
# Run a compiler test. First argument is compiler, second one are compiler
# flags, third one is test source file to be compiled
763 764 765 766 767 768 769 770 771 772 773
cmake_try_run ()
{
  COMPILER=$1
  FLAGS=$2
  TESTFILE=$3
  if [ ! -f "${TESTFILE}" ]; then
    echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
    exit 4
  fi
  TMPFILE=`cmake_tmp_file`
  echo "Try: ${COMPILER}"
774 775
  echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
  echo "----------  file   -----------------------"
776
  cat "${TESTFILE}"
777
  echo "------------------------------------------"
778 779 780
  "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
  RES=$?
  if [ "${RES}" -ne "0" ]; then
781 782
    echo "Test failed to compile"
    return 1
783 784
  fi
  if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
785
    echo "Test failed to produce executable"
786 787 788 789 790 791
    return 2
  fi
  ./${TMPFILE}
  RES=$?
  rm -f "${TMPFILE}"
  if [ "${RES}" -ne "0" ]; then
792
    echo "Test produced non-zero return code"
793 794
    return 3
  fi
795
  echo "Test succeeded"
796 797 798
  return 0
}

799
# Run a make test. First argument is the make interpreter.
800 801
cmake_try_make ()
{
802 803
  MAKE_PROC="$1"
  MAKE_FLAGS="$2"
804
  echo "Try: ${MAKE_PROC}"
805
  "${MAKE_PROC}" ${MAKE_FLAGS}
806 807
  RES=$?
  if [ "${RES}" -ne "0" ]; then
808 809
    echo "${MAKE_PROC} does not work"
    return 1
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
  fi
  if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
    echo "${COMPILER} does not produce output"
    return 2
  fi
  ./test
  RES=$?
  rm -f "test"
  if [ "${RES}" -ne "0" ]; then
    echo "${MAKE_PROC} produces strange executable"
    return 3
  fi
  echo "${MAKE_PROC} works"
  return 0
}

826
# Parse arguments
827
cmake_verbose=
828
cmake_parallel_make=
829
cmake_ccache_enabled=
830
cmake_prefix_dir="${cmake_default_prefix}"
831 832
while test $# != 0; do
  case "$1" in
833 834 835
  --prefix=*) dir=`cmake_arg "$1"`
              cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
  --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
836
  --bindir=*) cmake_bin_dir=`cmake_arg "$1"` ;;
837 838 839
  --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
  --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
  --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
840
  --xdgdatadir=*) cmake_xdgdata_dir=`cmake_arg "$1"` ;;
841
  --init=*) cmake_init_file=`cmake_arg "$1"` ;;
842 843
  --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
  --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
844
  --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-librhash|--system-zlib|--system-liblzma|--system-zstd|--system-libuv)
845 846
    lib=`cmake_arg "$1" "--system-"`
    cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
847
  --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)
848 849
    lib=`cmake_arg "$1" "--no-system-"`
    cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
850 851
  --qt-gui) cmake_bootstrap_qt_gui="1" ;;
  --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
852
  --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
853
  --sphinx-info) cmake_sphinx_info="1" ;;
854 855
  --sphinx-man) cmake_sphinx_man="1" ;;
  --sphinx-html) cmake_sphinx_html="1" ;;
856
  --sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
857
  --sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
858
  --sphinx-flags=*) cmake_sphinx_flags=`cmake_arg "$1"` ;;
859 860 861 862
  --help) cmake_usage ;;
  --version) cmake_version_display ; exit 2 ;;
  --verbose) cmake_verbose=TRUE ;;
  --enable-ccache) cmake_ccache_enabled=TRUE ;;
863 864 865 866 867
  CC=*) CC=`cmake_arg "$1"` ;;
  CXX=*) CXX=`cmake_arg "$1"` ;;
  CFLAGS=*) CFLAGS=`cmake_arg "$1"` ;;
  CXXFLAGS=*) CXXFLAGS=`cmake_arg "$1"` ;;
  LDFLAGS=*) LDFLAGS=`cmake_arg "$1"` ;;
868
  --) shift; break ;;
869 870 871
  *) die "Unknown option: $1" ;;
  esac
  shift
872 873
done

874
# If verbose, display some information about bootstrap
875 876 877 878 879 880
if [ -n "${cmake_verbose}" ]; then
  echo "---------------------------------------------"
  echo "Source directory: ${cmake_source_dir}"
  echo "Binary directory: ${cmake_binary_dir}"
  echo "Prefix directory: ${cmake_prefix_dir}"
  echo "System:           ${cmake_system}"
881 882 883 884
  if [ "x${cmake_parallel_make}" != "x" ]; then
    echo "Doing parallel make: ${cmake_parallel_make}"
  fi
  echo ""
885 886 887
fi

echo "---------------------------------------------"
888
# Get CMake version
889
echo "`cmake_version_display`"
890

891 892 893 894 895 896 897 898 899 900 901 902 903
# Check for in-source build
cmake_in_source_build=
if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
     -f "${cmake_binary_dir}/Source/cmake.h" ]; then
  if [ -n "${cmake_verbose}" ]; then
    echo "Warning: This is an in-source build"
  fi
  cmake_in_source_build=TRUE
fi

# If this is not an in-source build, then Bootstrap stuff should not exist.
if [ -z "${cmake_in_source_build}" ]; then
  # Did somebody bootstrap in the source tree?
904 905
  if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
    cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
906
Looks like somebody did bootstrap CMake in the source tree, but now you are
907
trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
908 909 910 911
directory from the source tree."
  fi
  # Is there a cache in the source tree?
  for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
Will Schroeder's avatar
Will Schroeder committed
912
    if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
913 914 915 916 917 918 919 920
      cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
Looks like somebody tried to build CMake in the source tree, but now you are
trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
from the source tree."
    fi
  done
fi

921
# Make bootstrap directory
922 923
[ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
if [ ! -d "${cmake_bootstrap_dir}" ]; then
924
  cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
925 926 927
fi
cd "${cmake_bootstrap_dir}"

Brad King's avatar
Brad King committed
928 929
[ -d "cmsys" ] || mkdir "cmsys"
if [ ! -d "cmsys" ]; then
930
  cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
Brad King's avatar
Brad King committed
931 932
fi

933
# Delete all the bootstrap files
934
rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
935 936
rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
937

938 939 940 941 942 943
# If building in-source, remove any cmConfigure.h that may
# have been created by a previous run of the bootstrap cmake.
if [ -n "${cmake_in_source_build}" ]; then
  rm -f "${cmake_source_dir}/Source/cmConfigure.h"
fi

944
# If exist compiler flags, set them
945 946
cmake_c_flags=${CFLAGS}
cmake_cxx_flags=${CXXFLAGS}
Bill Hoffman's avatar
Bill Hoffman committed
947
cmake_ld_flags=${LDFLAGS}
948

949 950 951 952 953
# Add Cygwin-specific flags
if ${cmake_system_cygwin}; then
  cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
fi

954
# Add CoreFoundation framework on Darwin
955
if ${cmake_system_darwin}; then
956
  cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
957 958
fi

959 960 961 962 963
# Add BeOS toolkits...
if ${cmake_system_beos}; then
  cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi

964 965 966 967 968
# Add Haiku toolkits...
if ${cmake_system_haiku}; then
  cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi

969 970 971 972 973 974
#-----------------------------------------------------------------------------
# Detect known toolchains on some platforms.
cmake_toolchains=''
case "${cmake_system}" in
  *AIX*)   cmake_toolchains='XL GNU' ;;
  *CYGWIN*) cmake_toolchains='GNU' ;;
975
  *Darwin*) cmake_toolchains='Clang GNU' ;;
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023