3 # configure [ <options> ]
15 --bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo>
16 Prepare for a bootstrap build. No pre-built
17 packages will be used, instead they will be built
18 from the sources (in several phases).
19 <haikuporter> is the path to the haikuporter tool
20 suitable for the host platform.
21 <HaikuPorts cross repo> is the path to a checked
22 out HaikuPorts cross-compilation repository.
23 <HaikuPorts repo> is the path to a checked out
24 HaikuPorts repository.
25 --build-cross-tools <arch> [ <build tools dir> ]
26 Assume cross compilation. <build tools dir>
27 defines the location of the build tools sources.
28 They will be compiled and placed in the output
29 directory under "cross-tools". The HAIKU_* tools
30 variables will be set accordingly.
31 <arch> specifies the target architecture, either
32 "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm"
33 This option and --cross-tools-prefix can be
34 specified multiple times. The first cross tools
35 specify the primary tools, the subsequent ones the
36 secondary tools (for "hybrid" images).
37 For the first --build-cross-tools the
38 <build tools dir> argument must be specified and
39 for the subsequent ones it must be omitted.
40 --cross-tools-prefix <prefix>
41 Assume cross compilation. <prefix> should be a
42 path to the directory where the cross
43 compilation tools are located, plus the platform
44 prefix, e.g. "/path/to/tools/i586-pc-haiku-".
45 This overrides the HAIKU_* tool variables.
46 --distro-compatibility <level>
47 The distribution's level of compatibility with
48 the official Haiku distribution. The generated
49 files will contain the respective trademarks
51 official -- the official Haiku distribution.
52 compatible -- a Haiku Compatible (tm) distro.
53 default -- any other distro (default value).
54 --help Prints out this help.
55 --host-only Configure for building tools for the build host
56 only. Haiku cannot be built when configured like
58 --include-patented-code Enable code that is known to implemented patented
59 ideas and techniques. If this option is not
60 specified, the resulting distribution may still
61 implement patented ideas and techniques. This
62 option only disables code that is currently known
64 --include-sources Includes the source code of projects that require
65 either an offer of source code or a copy of the
66 patched sources. This is preferable when
67 distributing on physical mediums.
68 --include-3rdparty Include 3rdparty/ in the build system.
69 -j<n> Only relevant for --build-cross-tools. Is passed
70 on to the make building the build tools.
71 --no-downloads Do not download anything. Useful when trying to
72 bootstrap and build Haiku from source only.
73 --target=TARGET Select build target platform.
74 [default=${TARGET_PLATFORM}]
75 valid targets=r5,bone,dano,haiku
76 --target-arch <arch> Haiku only: Specify the target architecture to
77 build for. Must be one of the architectures of the
78 host system. The installed build tools for that
79 architecture will be used.
80 This option can be specified multiple times. The
81 first occurrence specifies the primary
82 architecture of the Haiku to build, subsequent
83 ones the secondary architectures.
84 --update re-runs last configure invocation [must be given
86 --use-clang <arch> Build with host Clang instead of GCC cross
87 compiler, targeting <arch>
88 --use-gcc-pipe Build with GCC option -pipe. Speeds up the build
89 process, but uses more memory.
90 --use-gcc-graphite Build with GCC Graphite engine for loop
91 optimizations. Only for gcc 4.
92 --use-32bit Use -m32 flag on 64bit host gcc compiler.
93 --use-xattr Use Linux xattr respectively *BSD extattr support
94 for BeOS attribute emulation. Warning: Make sure
95 your file system supports sufficient attribute
96 sizes (4 KB per file for all attributes won't
98 --use-xattr-ref Use the generic BeOS attribute emulation, but use
99 Linux xattr respectively *BSD extattr support to
100 make it more robust (i.e. attribute mix-ups become
102 --with-gdb <gdb sources dir>
103 specify the path to a GDB source dir, to build
104 GDB for each arch we build the cross-tools for.
106 environment variables:
107 CC The host compiler. Defaults to "gcc".
108 HAIKU_AR_<arch> The static library archiver for <arch>.
110 HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc".
111 HAIKU_LD_<arch> The <arch> linker. Defaults to "ld".
112 HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to
114 HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults
116 HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip".
117 HAIKU_NASM The nasm assembler (x86 and x86_64 only).
118 HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture
119 <arch>. Defaults to "".
120 HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>.
122 HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>.
124 HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>.
126 HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target
127 architecture <arch> for archiving. Defaults to
129 HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target
130 architecture <arch> for unarchiving. Defaults to
133 Non-default output directories:
134 By default all objects, build configuration, and other related files are
135 stored in /path/to/haiku_source/generated. To store objects in a non-default
136 location, run "../../relative/path/to/haiku_source/configure <options>" from
137 within your non-default location. "jam [ options ] targets" can then be run
138 directly inside your non-default location. Another option is to invoke "jam
139 [ options ] targets" from within haiku_source. This can be accomplished by
140 either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
141 jam or by creating a symlink of haiku_source/generated pointing to your
142 non-default location and running jam.
150 # Checks whether at least one parameter is left.
154 if [ $2 -lt 2 ]; then
155 echo $0: \
`$1\': Parameter expected.
162 # Checks whether at least a certain number of parameters is left.
166 if [ $3 -le $2 ]; then
167 echo $0: \`$1\': Not enough parameters.
174 # returns the absolute path of a given path.
178 if [ "x$1" != "x${1#/}" ]; then
187 # check if a directory exists or not
200 # check if a file exists or not
213 # returns the realpath of a symbolic link.
217 perl
-MCwd=realpath
-e'print realpath($ARGV[0]), "\n"' "$1"
220 # standard_gcc_settings
222 # Sets the variables for a GCC platform.
224 standard_gcc_settings
()
228 if which greadlink
> /dev
/null
2>&1; then
229 readlink
="greadlink -e"
230 elif which realpath
> /dev
/null
2>&1; then
232 elif readlink
-e / > /dev
/null
2>&1; then
233 readlink
="readlink -e"
239 local gcclib
=`$gcc -print-libgcc-file-name`
240 local gccdir
=`dirname ${gcclib}`
242 local gccRawVersion
=`$gcc -dumpversion`
243 local gccMachine
=`$gcc -dumpmachine`
245 # determine architecture from machine triple
247 arm-
*) targetCpu
=arm
;;
248 i?
86-*) targetCpu
=x86
;;
249 m68k-
*) targetCpu
=m68k
;;
250 powerpc-
*) targetCpu
=ppc
;;
251 x86_64-
*) targetCpu
=x86_64
;;
253 echo "Unsupported gcc target machine: $gccMachine" >&2
258 local targetArch
=$targetCpu
260 case $gccRawVersion in
262 # check for correct (most up-to-date) legacy compiler and complain
263 # if an older one is installed
264 if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then
265 echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
266 echo "Please download it from www.haiku-os.org...";
279 # Boot loader is 32-bit, need the 32-bit libs and c++ config
280 bootLibgcc
=`$gcc -m32 -print-file-name=libgcc.a`
281 bootLibSupCxx
=`$gcc -m32 -print-file-name=libsupc++.a`
283 local headersBase
=$gccdir/..
/..
/..
/..
284 local headers
=$headersBase/$gccMachine/include
/c
++/$gccRawVersion
285 if [ ! -d $headers ]; then
286 headers
=$headersBase/include
/c
++/$gccRawVersion
288 bootCxxHeaders
="$headers/$gccMachine/32"
292 # determine whether graphite loop optimization should/can be used
293 local useGraphite
=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu`
294 if [ -z "$useGraphite" ]; then
295 useGraphite
=$useGccGraphiteDefault
298 if [ "$useGraphite" != 0 ]; then
299 UNUSED
=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1`
301 echo "GCC Graphite loop optimizations cannot be used on $targetArch"
306 set_variable HAIKU_CPU_
$targetArch $targetCpu
308 get_build_tool_path CC_
$targetArch "$gcc"
309 set_variable HAIKU_CC_IS_CLANG_
$targetArch $useClang
310 set_variable HAIKU_GCC_RAW_VERSION_
$targetArch $gccRawVersion
311 set_variable HAIKU_GCC_MACHINE_
$targetArch $gccMachine
312 set_variable HAIKU_GCC_LIB_DIR_
$targetArch $gccdir
313 set_variable HAIKU_BOOT_CXX_HEADERS_DIR_
$targetArch "$bootCxxHeaders"
314 set_variable HAIKU_BOOT_LIBSUPCXX_
$targetArch "$bootLibSupCxx"
315 set_variable HAIKU_BOOT_LIBGCC_
$targetArch $bootLibgcc
316 set_variable HAIKU_USE_GCC_GRAPHITE_
$targetArch $useGraphite
318 standard_gcc_settings_targetArch
=$targetArch
323 # Set the value of a variable.
332 # Echo the value of a variable.
341 # Set the value for a variable, if no value is set yet.
348 # get_build_tool_path
350 # Gets a usable absolute path of a build tool.
352 get_build_tool_path
()
355 local varval
="`get_variable $var`"
358 if [ ! -z "$varval" ]; then
359 # this variable is already set (probably by user) so grab its contents
363 local path
=${cmd%% *}
365 if [ -f "$path" ]; then
366 # get absolute path from relative path
368 cd "`dirname "$path"`"
369 path
="`pwd`/`basename "$path"`"
372 which "$path" > /dev
/null
2>&1 ||
{
373 echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2
378 if test "${cmd#* }" != "$cmd"; then
379 # $cmd contains arguments, so preserve them (and only them)
382 # $cmd does not contain arguments, so unset it
385 eval "$var=\"$path $cmd\""
391 for element
in $2; do
392 if [ "$1" = "$element" ]; then
399 # check for --help or -h and show usage immediately
400 if [ "$1" = "--help" ] ||
[ "$1" = "-h" ]; then
404 # ensure umask is not too restrictive
405 if [ $
(umask) -gt 22 ]; then
406 echo "Your umask is too restrictive (should be: <= 0022; is actually:" $
(umask)")"
410 # get cwd and the source directory
416 # backup the passed arguments
419 # internal default parameter values
422 platformMachine
=`uname -m`
425 buildCrossToolsScript
="$sourceDir/build/scripts/build_cross_tools"
428 useGccGraphiteDefault
=0
433 if [ -z "$CC" ]; then
437 # exported (BuildSetup) default parameter values
439 HOST_GCC_RAW_VERSION
=`$CC -dumpversion`
440 HOST_GCC_MACHINE
=`$CC -dumpmachine`
441 HAIKU_INCLUDE_PATENTED_CODE
=0
442 HAIKU_INCLUDE_SOURCES
=0
443 HAIKU_INCLUDE_3RDPARTY
=0
444 HAIKU_DISTRO_COMPATIBILITY
=default
445 TARGET_PLATFORM
=haiku
447 HAIKU_HOST_USE_32BIT
=0
448 HAIKU_HOST_USE_XATTR
=0
449 HAIKU_HOST_USE_XATTR_REF
=0
450 HAIKU_HOST_BUILD_ONLY
=0
451 HOST_EXTENDED_REGEX_SED
="sed -r"
452 HOST_GCC_LD
=`$CC -print-prog-name=ld`
453 HOST_GCC_OBJCOPY
=`$CC -print-prog-name=objcopy`
462 HAIKU_PACKAGING_ARCHS
=
464 set_default_value HAIKU_NASM nasm
466 if sha256sum
< /dev
/null
> /dev
/null
2>&1; then
467 HOST_SHA256
=sha256sum
468 elif sha256
< /dev
/null
> /dev
/null
2>&1; then
469 HOST_SHA256
="sha256 -q"
470 elif shasum
< /dev
/null
> /dev
/null
2>&1; then
471 HOST_SHA256
="shasum -a 256"
473 echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2
477 haikuRequiredLegacyGCCVersion
="2.95.3-haiku-2017_07_20"
478 export haikuRequiredLegacyGCCVersion
479 # version of legacy gcc required to build haiku
480 supportedTargetArchs
="
489 # determine output directory
490 if [ "$currentDir" = "$sourceDir" ]; then
491 outputDir
=$currentDir/generated
493 outputDir
=$currentDir
495 buildOutputDir
="$outputDir/build"
496 HAIKU_BUILD_ATTRIBUTES_DIR
="$outputDir/attributes"
497 buildConfigFile
="$buildOutputDir/BuildConfig"
499 # check for update request
500 if [ "$1" = "--update" ]; then
501 if ! [ -e "$buildConfigFile" ]; then
502 echo $0 --update: \'$buildConfigFile\' not found
- updating not possible.
505 if ! type perl
>/dev
/null
2>&1; then
506 echo $0 --update: \'perl
\' not found
- updating not possible.
509 # convert BuildConfig from jam format to shell format and evaluate it
510 shellConfigFile
="${buildConfigFile}.shell"
511 perl
"$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
512 <"$buildConfigFile" >"$shellConfigFile"
514 rm "$shellConfigFile"
520 while [ $# -gt 0 ] ; do
523 assertparams
"$1" 3 $#
524 HOST_HAIKU_PORTER
="`absolute_path $2`"
525 HAIKU_PORTS_CROSS
="`absolute_path $3`"
526 HAIKU_PORTS
="`absolute_path $4`"
529 check_file_exists
"$HOST_HAIKU_PORTER" ||
(
530 echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2
533 check_dir_exists
"$HAIKU_PORTS" ||
(
534 echo "Non-existent directory $HAIKU_PORTS" >&2
537 check_dir_exists
"$HAIKU_PORTS_CROSS" ||
(
538 echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2
544 if [ -z "$buildCrossTools" ]; then
545 assertparams
"$1" 2 $#
554 case "$targetArch" in
555 x86_gcc2
) targetMachine
=i586-pc-haiku
;;
556 x86
) targetMachine
=i586-pc-haiku
;;
557 x86_64
) targetMachine
=x86_64-unknown-haiku
;;
558 ppc
) targetMachine
=powerpc-apple-haiku
;;
559 m68k
) targetMachine
=m68k-unknown-haiku
;;
560 arm
) targetMachine
=arm-unknown-haiku
;;
562 echo "Unsupported target architecture: $2" >&2
566 set_variable buildCrossToolsMachine_
$targetArch $targetMachine
567 targetArchs
="$targetArchs $targetArch"
568 HAIKU_PACKAGING_ARCHS
=
570 --cross-tools-prefix)
572 targetArch
=unknown
${unknownArchIndex}
573 set_variable crossToolsPrefix_
$targetArch "$2"
574 targetArchs
="$targetArchs $targetArch"
575 HAIKU_PACKAGING_ARCHS
=
576 unknownArchIndex
=$
(($unknownArchIndex + 1))
579 --distro-compatibility)
581 HAIKU_DISTRO_COMPATIBILITY
=$2
582 case "$HAIKU_DISTRO_COMPATIBILITY" in
586 *) echo "Invalid distro compatibility" \
587 "level: $HAIKU_DISTRO_COMPATIBILITY"
592 --host-only) HAIKU_HOST_BUILD_ONLY
=1; shift 1;;
593 --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE
=1; shift 1;;
594 --include-sources) HAIKU_INCLUDE_SOURCES
=1; shift 1;;
595 --include-3rdparty) HAIKU_INCLUDE_3RDPARTY
=1; shift 1;;
596 -j*) buildCrossToolsJobs
="$1"; shift 1;;
597 --no-downloads) HAIKU_NO_DOWNLOADS
=1; shift 1;;
598 --target=*) TARGET_PLATFORM
=`echo $1 | cut -d'=' -f2-`; shift 1;;
603 if [ ! "$platform" = Haiku
]; then
604 echo "--target-arch can only be specified on Haiku." >&2
607 is_in_list
"$targetArch" "$supportedTargetArchs" ||
(
608 echo "Unsupported target architecture: \"$targetArch\"" >&2
611 haikuTargetArchs
="$haikuTargetArchs $targetArch"
617 case "$targetArch" in
618 x86
) targetMachine
=i586-pc-haiku
;;
619 x86_64
) targetMachine
=x86_64-unknown-haiku
;;
621 echo "Unsupported target architecture: $2" >&2
625 get_build_tool_path clang clang
626 if [ -n "crossToolsPrefix_$targetArch" ]; then
627 set_variable crossToolsPrefix_
$targetArch llvm-
629 targetArchs
="$targetArchs $targetArch"
630 HAIKU_PACKAGING_ARCHS
=
633 --use-gcc-pipe) HAIKU_USE_GCC_PIPE
=1; shift 1;;
634 --use-gcc-graphite) useGccGraphiteDefault
=1; shift 1;;
635 --use-32bit) HAIKU_HOST_USE_32BIT
=1; shift 1;;
636 --use-xattr) HAIKU_HOST_USE_XATTR
=1; shift 1;;
637 --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF
=1; shift 1;;
638 --with-gdb) gdbSources
=$2; shift 2;;
639 *) echo Invalid argument
: \
`$1\'; exit 1;;
643 # detect the build platform
644 case "${platform}" in
645 Darwin) HOST_PLATFORM=darwin ;;
646 FreeBSD) HOST_PLATFORM=freebsd
647 if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then
648 echo Unsupported platform: FreeBSD ${platformMachine}
651 Haiku) HOST_PLATFORM=haiku_host ;;
652 Linux) HOST_PLATFORM=linux ;;
653 OpenBSD) HOST_PLATFORM=openbsd ;;
654 SunOS) HOST_PLATFORM=sunos ;;
655 CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
656 *) echo Unsupported platform: ${platform}
660 # check for case-sensitive filesystem
661 mkdir haikuCaseTest 2>/dev/null
662 mkdir haikucasetest 2>/dev/null
664 rmdir haikuCaseTest haikucasetest 2>/dev/null
665 if [ $caseInsensitive != 0 ]; then
666 echo "You need a case-sensitive file-system to build Haiku."
667 if [ $HOST_PLATFORM = "darwin" ]; then
668 echo "You can create a case-sensitive disk image using Disk Utility."
673 # determine how to invoke sed with extended regexp support for non-GNU sed
674 if [ $HOST_PLATFORM = "darwin" ]; then
675 HOST_EXTENDED_REGEX_SED="sed -E"
678 # check if nasm can actually output ELF files
679 # (the stock version in OSX can't)
680 # XXX: should probably only test for x86* arch
681 if [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then
682 echo "$HAIKU_NASM cannot generate ELF files. Please install a working version."
683 if [ $HOST_PLATFORM = "darwin" ]; then
684 echo "You can install it from Mac Ports."
685 echo "Mac Ports is available at: http://www.macports.org/"
690 # create output directory
691 mkdir -p "$buildOutputDir" || exit 1
693 if [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
694 invalidCommand=$sourceDir/build/scripts/host_build_only
695 HAIKU_AR=$invalidCommand
696 HAIKU_CC=$invalidCommand
697 HAIKU_LD=$invalidCommand
698 HAIKU_OBJCOPY=$invalidCommand
699 HAIKU_RANLIB=$invalidCommand
700 HAIKU_ELFEDIT=$invalidCommand
701 HAIKU_NASM=$invalidCommand
702 HAIKU_STRIP=$invalidCommand
704 if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then
705 targetArchs="$HAIKU_PACKAGING_ARCHS"
707 HAIKU_PACKAGING_ARCHS=
709 # On Haiku determine target architectures and tools automatically.
710 if [ -z "$targetArchs" ]; then
711 if [ $HOST_PLATFORM != haiku_host ]; then
712 echo "Please specify the build tools to use or build (via" \
713 "--cross-tools-prefix or --build-cross-tools) or specify a" \
714 "host-only build (--host-only)." >&2
715 echo "For more info, invoke $0 --help"
719 # determine primary architecture
720 targetArch=`package list
-i /system
/packages
/haiku-
*.hpkg \
721 |
sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'`
722 is_in_list "$targetArch" "$supportedTargetArchs" || (
723 echo "Unsupported target architecture: \"$targetArch\"" >&2
726 targetArchs=$targetArch
728 set_default_value HAIKU_AR_$targetArch ar
729 set_default_value HAIKU_CC_$targetArch gcc
730 set_default_value HAIKU_LD_$targetArch ld
731 set_default_value HAIKU_OBJCOPY_$targetArch objcopy
732 set_default_value HAIKU_RANLIB_$targetArch ranlib
733 set_default_value HAIKU_ELFEDIT_$targetArch elfedit
734 set_default_value HAIKU_STRIP_$targetArch strip
736 # determine secondary architectures
737 for targetArch in $supportedTargetArchs; do
738 if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then
739 targetArchs="$targetArchs $targetArch"
740 set_default_value HAIKU_AR_$targetArch ar-$targetArch
741 set_default_value HAIKU_CC_$targetArch gcc-$targetArch
742 set_default_value HAIKU_LD_$targetArch ld-$targetArch
743 set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch
744 set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch
745 set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch
746 set_default_value HAIKU_STRIP_$targetArch strip-$targetArch
750 # The target architectures might have been specified explicitly.
751 if [ -n "$haikuTargetArchs" ]; then
752 for targetArch in $haikuTargetArchs; do
753 is_in_list "$targetArch" "$targetArchs" || (
754 echo "Unsupported target architecture: \"$targetArch\"." \
755 "Only native architectures of the host platform can" \
760 targetArchs="$haikuTargetArchs"
765 for targetArch in $targetArchs; do
766 # Note: targetArch is "unknown<n>" at this point, if a cross-tools
767 # prefix was specified. The standard_gcc_settings call below will get
768 # the actual architecture.
770 crossToolsPrefix=`get_variable crossToolsPrefix_
$targetArch`
772 # build cross tools from sources
773 if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then
774 crossToolsDir="$outputDir/cross-tools-$targetArch"
775 targetMachine=`get_variable buildCrossToolsMachine_
$targetArch`
776 script="$buildCrossToolsScript"
778 if [ $targetArch != x86_gcc2 ]; then
779 script="${script}_gcc4"
780 scriptArgs="$targetMachine"
781 set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \
782 $useGccGraphiteDefault
785 if [ -z "$isPrimaryArch" ]; then
786 secondaryArch=$targetArch
789 case $HOST_PLATFORM in
790 freebsd|openbsd) MAKE=gmake;;
795 SECONDARY_ARCH=$secondaryArch \
796 HAIKU_USE_GCC_GRAPHITE=`get_variable \
797 HAIKU_USE_GCC_GRAPHITE_
$targetArch` \
798 HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
799 HAIKU_USE_GDB="$gdbSources" \
800 "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
801 "$crossToolsDir" $buildCrossToolsJobs || exit 1
802 crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
805 # prepare gcc settings and get the actual target architecture
806 if [ $useClang = 1 ]; then
807 gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as"
809 # Clang's compiler intrinsics are not compatible with GCC's or even
810 # across versions of Clang, so we must collect them for use in the build.
811 mkdir -p "$outputDir/clang_headers" || exit 1
812 clangHeadersDir=`$gcc -print-resource-dir`/include/
813 cp $clangHeadersDir/*intrin* $clangHeadersDir/mm3* "$outputDir/clang_headers" || exit 1
814 elif [ -z "${crossToolsPrefix}" ]; then
815 gcc=`get_variable HAIKU_CC_
$targetArch`
817 gcc="${crossToolsPrefix}gcc"
819 standard_gcc_settings "$gcc"
820 targetArch=$standard_gcc_settings_targetArch
822 # set default values for flags
823 set_default_value HAIKU_CPPFLAGS_$targetArch ""
824 set_default_value HAIKU_CCFLAGS_$targetArch ""
825 set_default_value HAIKU_CXXFLAGS_$targetArch ""
826 set_default_value HAIKU_LDFLAGS_$targetArch ""
827 set_default_value HAIKU_ARFLAGS_$targetArch cru
828 set_default_value HAIKU_UNARFLAGS_$targetArch x
830 # Override the cross tools variables, if the tools were built or a
831 # prefix was specified.
832 if [ -n "$crossToolsPrefix" ]; then
833 get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar
834 get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld
835 get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy
836 get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib
837 get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip
839 case `get_variable HAIKU_GCC_RAW_VERSION_
$targetArch` in
841 get_build_tool_path ELFEDIT_$targetArch \
842 ${crossToolsPrefix}elfedit
847 # check whether the Haiku compiler really targets Haiku
848 targetMachine=`get_variable HAIKU_GCC_MACHINE_
$targetArch`
849 case "$targetMachine" in
852 echo The compiler specified as Haiku target compiler is not a \
853 valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
854 echo compiler: $HAIKU_CC
855 echo compiler is configured for target: $targetMachine
859 HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch"
864 # Generate BuildConfig
865 cat << EOF > "$buildConfigFile"
867 # Note: This file has been automatically generated by configure with the
868 # following arguments:
871 TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
872 HOST_PLATFORM ?= "${HOST_PLATFORM}" ;
874 HAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
875 HAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ;
876 HAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ;
877 HAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
878 HAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ;
879 HAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ;
880 HAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ;
881 HAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ;
882 HAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ;
884 HAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ;
886 HAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ;
888 HAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
890 HAIKU_NASM ?= ${HAIKU_NASM} ;
891 HAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ;
893 HOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ;
894 HOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ;
895 HOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ;
896 HOST_LD ?= ${HOST_GCC_LD} ;
897 HOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ;
898 HOST_SHA256 ?= ${HOST_SHA256} ;
900 HOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ;
901 HAIKU_PORTS ?= ${HAIKU_PORTS} ;
902 HAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ;
903 HAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ;
907 for targetArch in $HAIKU_PACKAGING_ARCHS; do
909 HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION
910 HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE
911 HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR
913 HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC
914 HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX
917 HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG
919 HAIKU_OBJCOPY HAIKU_OBJCOPY
920 HAIKU_RANLIB HAIKU_RANLIB
921 HAIKU_ELFEDIT HAIKU_ELFEDIT
922 HAIKU_STRIP HAIKU_STRIP
923 HAIKU_CPPFLAGS HAIKU_CPPFLAGS
924 HAIKU_CCFLAGS HAIKU_CCFLAGS
925 HAIKU_C++FLAGS HAIKU_CXXFLAGS
926 HAIKU_LDFLAGS HAIKU_LDFLAGS
927 HAIKU_ARFLAGS HAIKU_ARFLAGS
928 HAIKU_UNARFLAGS HAIKU_UNARFLAGS
929 HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE
932 while [ $# -ge 2 ]; do
933 value=`get_variable
${2}_
$targetArch`
934 echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile"
938 # For variables that may have long values, distribute them over multiple
939 # lines so that jam doesn't hit the maximum line length.
941 HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR
944 while [ $# -ge 2 ]; do
945 echo "${1}_${targetArch} ?= " >> "$buildConfigFile"
946 get_variable ${2}_$targetArch | xargs -n 1 echo " " \
947 >> "$buildConfigFile"
948 echo " ;" >> "$buildConfigFile"
954 # Generate a boot strap Jamfile in the output directory.
956 cat << EOF > $outputDir/Jamfile
957 # automatically generated Jamfile
959 HAIKU_TOP = ${sourceDir} ;
960 HAIKU_OUTPUT_DIR = ${outputDir} ;
962 include [ FDirName \$(HAIKU_TOP) Jamfile ] ;
966 echo "Configured successfully!"