3 # configure [ <options> ]
15 --help Prints out this help.
16 --update Re-runs last configure invocation [must be given
18 --bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo>
19 Prepare for a bootstrap build. No pre-built
20 packages will be used, instead they will be built
21 from the sources (in several phases).
22 <haikuporter> is the path to the haikuporter tool
23 suitable for the host platform.
24 <HaikuPorts cross repo> is the path to a checked
25 out HaikuPorts cross-compilation repository.
26 <HaikuPorts repo> is the path to a checked out
27 HaikuPorts repository.
28 --build-cross-tools <arch> [ <build tools dir> ]
29 Assume cross compilation. <build tools dir>
30 defines the location of the build tools sources.
31 They will be compiled and placed in the output
32 directory under "cross-tools". The HAIKU_* tools
33 variables will be set accordingly.
34 <arch> specifies the target architecture, either
35 "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm"
36 This option and --cross-tools-prefix can be
37 specified multiple times. The first cross tools
38 specify the primary tools, the subsequent ones the
39 secondary tools (for "hybrid" images).
40 For the first --build-cross-tools the
41 <build tools dir> argument must be specified and
42 for the subsequent ones it must be omitted.
43 --cross-tools-prefix <prefix>
44 Assume cross compilation. <prefix> should be a
45 path to the directory where the cross
46 compilation tools are located, plus the platform
47 prefix, e.g. "/path/to/tools/i586-pc-haiku-".
48 This overrides the HAIKU_* tool variables.
49 --distro-compatibility <level>
50 The distribution's level of compatibility with
51 the official Haiku distribution. The generated
52 files will contain the respective trademarks
54 official -- the official Haiku distribution.
55 compatible -- a Haiku Compatible (tm) distro.
56 default -- any other distro (default value).
57 --host-only Configure for building tools for the build host
58 only. Haiku cannot be built when configured like
60 --include-patented-code Enable code that is known to implemented patented
61 ideas and techniques. If this option is not
62 specified, the resulting distribution may still
63 implement patented ideas and techniques. This
64 option only enables code that is currently known
66 --include-sources Includes the source code of projects that require
67 either an offer of source code or a copy of the
68 patched sources. This is preferable when
69 distributing on physical mediums.
70 --include-3rdparty Include 3rdparty/ in the build system.
71 -j<n> Only relevant for --build-cross-tools. Is passed
72 on to the make building the build tools.
73 --no-downloads Do not download anything. Useful when trying to
74 bootstrap and build Haiku from source only.
75 --target=TARGET Select build target platform.
76 [default=${TARGET_PLATFORM}]
77 valid targets=r5,bone,dano,haiku
78 --target-arch <arch> Haiku only: Specify the target architecture to
79 build for. Must be one of the architectures of the
80 host system. The installed build tools for that
81 architecture will be used.
82 This option can be specified multiple times. The
83 first occurrence specifies the primary
84 architecture of the Haiku to build, subsequent
85 ones the secondary architectures.
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 --no-full-xattr Do not use Linux/*BSD/Darwin's native extended file
94 attributes as Haiku attributes. If they are still
95 available, they will be used to store hashes for
96 the attribute emulation layer.
97 --no-xattr Do not use Linux/*BSD/Darwin's native extended file
98 attributes for Haiku extended attributes at all,
99 even if they are available.
100 --with-gdb <gdb sources dir>
101 specify the path to a GDB source dir, to build
102 GDB for each arch we build the cross-tools for.
104 environment variables:
105 CC The host compiler. Defaults to "gcc".
106 HAIKU_AR_<arch> The static library archiver for <arch>.
108 HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc".
109 HAIKU_LD_<arch> The <arch> linker. Defaults to "ld".
110 HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to
112 HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults
114 HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip".
115 HAIKU_NASM The nasm assembler (x86 and x86_64 only).
116 HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture
117 <arch>. Defaults to "".
118 HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>.
120 HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>.
122 HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>.
124 HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target
125 architecture <arch> for archiving. Defaults to
127 HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target
128 architecture <arch> for unarchiving. Defaults to
131 Non-default output directories:
132 By default all objects, build configuration, and other related files are
133 stored in /path/to/haiku_source/generated. To store objects in a non-default
134 location, run "../../relative/path/to/haiku_source/configure <options>" from
135 within your non-default location. "jam [ options ] targets" can then be run
136 directly inside your non-default location. Another option is to invoke "jam
137 [ options ] targets" from within haiku_source. This can be accomplished by
138 either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
139 jam or by creating a symlink of haiku_source/generated pointing to your
140 non-default location and running jam.
148 # Checks whether at least one parameter is left.
152 if [ $2 -lt 2 ]; then
153 echo $0: \
`$1\': Parameter expected.
160 # Checks whether at least a certain number of parameters is left.
164 if [ $3 -le $2 ]; then
165 echo $0: \`$1\': Not enough parameters.
172 # returns the absolute path of a given path.
176 if [ "x$1" != "x${1#/}" ]; then
185 # check if a directory exists or not
198 # check if a file exists or not
211 # returns the realpath of a symbolic link.
215 perl
-MCwd=realpath
-e'print realpath($ARGV[0]), "\n"' "$1"
218 # standard_gcc_settings
220 # Sets the variables for a GCC platform.
222 standard_gcc_settings
()
226 if which greadlink
> /dev
/null
2>&1; then
227 readlink
="greadlink -e"
228 elif which realpath
> /dev
/null
2>&1; then
230 elif readlink
-e / > /dev
/null
2>&1; then
231 readlink
="readlink -e"
237 local gcclib
=`$gcc -print-libgcc-file-name`
238 local gccdir
=`dirname ${gcclib}`
240 local gccRawVersion
=`$gcc -dumpversion`
241 local gccMachine
=`$gcc -dumpmachine`
243 # determine architecture from machine triple
245 arm-
*) targetCpu
=arm
;;
246 i?
86-*) targetCpu
=x86
;;
247 m68k-
*) targetCpu
=m68k
;;
248 powerpc-
*) targetCpu
=ppc
;;
249 x86_64-
*) targetCpu
=x86_64
;;
251 echo "Unsupported gcc target machine: $gccMachine" >&2
256 local targetArch
=$targetCpu
258 case $gccRawVersion in
260 # check for correct (most up-to-date) legacy compiler and complain
261 # if an older one is installed
262 if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then
263 echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
264 echo "Please download it from www.haiku-os.org...";
277 # Boot loader is 32-bit, need the 32-bit libs and c++ config
278 bootLibgcc
=`$gcc -m32 -print-file-name=libgcc.a`
279 bootLibSupCxx
=`$gcc -m32 -print-file-name=libsupc++.a`
281 local headersBase
=$gccdir/..
/..
/..
/..
282 local headers
=$headersBase/$gccMachine/include
/c
++/$gccRawVersion
283 if [ ! -d $headers ]; then
284 headers
=$headersBase/include
/c
++/$gccRawVersion
286 bootCxxHeaders
="$headers/$gccMachine/32"
290 # determine whether graphite loop optimization should/can be used
291 local useGraphite
=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu`
292 if [ -z "$useGraphite" ]; then
293 useGraphite
=$useGccGraphiteDefault
296 if [ "$useGraphite" != 0 ]; then
297 UNUSED
=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1`
299 echo "GCC Graphite loop optimizations cannot be used on $targetArch"
304 set_variable HAIKU_CPU_
$targetArch $targetCpu
306 get_build_tool_path CC_
$targetArch "$gcc"
307 set_variable HAIKU_CC_IS_CLANG_
$targetArch $useClang
308 set_variable HAIKU_GCC_RAW_VERSION_
$targetArch $gccRawVersion
309 set_variable HAIKU_GCC_MACHINE_
$targetArch $gccMachine
310 set_variable HAIKU_GCC_LIB_DIR_
$targetArch $gccdir
311 set_variable HAIKU_BOOT_CXX_HEADERS_DIR_
$targetArch "$bootCxxHeaders"
312 set_variable HAIKU_BOOT_LIBSUPCXX_
$targetArch "$bootLibSupCxx"
313 set_variable HAIKU_BOOT_LIBGCC_
$targetArch $bootLibgcc
314 set_variable HAIKU_USE_GCC_GRAPHITE_
$targetArch $useGraphite
316 standard_gcc_settings_targetArch
=$targetArch
321 # Set the value of a variable.
330 # Echo the value of a variable.
339 # Set the value for a variable, if no value is set yet.
346 # get_build_tool_path
348 # Gets a usable absolute path of a build tool.
350 get_build_tool_path
()
353 local varval
="`get_variable $var`"
356 if [ ! -z "$varval" ]; then
357 # this variable is already set (probably by user) so grab its contents
361 local path
=${cmd%% *}
363 if [ -f "$path" ]; then
364 # get absolute path from relative path
366 cd "`dirname "$path"`"
367 path
="`pwd`/`basename "$path"`"
370 which "$path" > /dev
/null
2>&1 ||
{
371 echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2
376 if test "${cmd#* }" != "$cmd"; then
377 # $cmd contains arguments, so preserve them (and only them)
380 # $cmd does not contain arguments, so unset it
383 eval "$var=\"$path $cmd\""
386 # check_native_xattrs
388 # Checks the host platform's support for extended attributes.
389 # 0: no support, 1: only enough for xattr-ref, 2: full support
391 check_native_xattrs
()
394 local xattr_set_args
=
396 local xattr_get_args
=
397 case $HOST_PLATFORM in
399 xattr_set
="xattr"; xattr_set_args
="-w \$NAME \"\$VALUE\""
400 xattr_get
="xattr"; xattr_get_args
="-p \$NAME"
403 xattr_set
="setextattr"; xattr_set_args
="user \$NAME \"\$VALUE\""
404 xattr_get
="getextattr"; xattr_get_args
="user \$NAME"
407 xattr_set
="setfattr"; xattr_set_args
="-n user.\$NAME -v \"\$VALUE\""
408 xattr_get
="getfattr"; xattr_get_args
="-n user.\$NAME"
414 if ! type $xattr_set >/dev
/null
2>&1; then
415 echo "$0: could not find $xattr_set, assuming host has no extended attributes"
417 elif ! type $xattr_get >/dev
/null
2>&1; then
418 echo "$0: could not find $xattr_get, assuming host has no extended attributes"
422 echo "xattr test file" >"$outputDir/xattrtest"
424 # on round 0, we test if we can set 3 attrs of 1K each (enough for xattr-ref)
425 # on round 1, we test if we can set 3 attrs of 45K each (enough for full xattr)
426 while [ $i -lt 2 ]; do
428 while [ $j -lt 3 ]; do
430 VALUE
=`printf '%*s' $((1024 + $i * 45056)) "" | tr ' ' x`
431 if [ `echo -n $VALUE | wc -c` -lt $
((1024 + $i * 45056)) ]; then
432 echo "$0: warning: could not generate test data for extended attributes"
433 rm "$outputDir/xattrtest"
435 elif ! $xattr_set `eval echo \"$xattr_set_args\"` \
436 "$outputDir/xattrtest" >/dev
/null
2>&1 ; then
437 rm "$outputDir/xattrtest"
444 rm "$outputDir/xattrtest"
451 for element
in $2; do
452 if [ "$1" = "$element" ]; then
459 # check for --help or -h and show usage immediately
460 if [ "$1" = "--help" ] ||
[ "$1" = "-h" ]; then
464 # ensure umask is not too restrictive
465 if [ $
(umask) -gt 22 ]; then
466 echo "Your umask is too restrictive (should be: <= 0022; is actually:" $
(umask)")"
470 # get cwd and the source directory
476 # backup the passed arguments
480 # backup relevant environs
485 configureEnvirons
="$configureEnvirons $var"
490 # internal default parameter values
493 platformMachine
=`uname -m`
496 buildCrossToolsScript
="$sourceDir/build/scripts/build_cross_tools"
499 useGccGraphiteDefault
=0
504 if [ -z "$CC" ]; then
508 # exported (BuildSetup) default parameter values
510 HOST_GCC_RAW_VERSION
=`$CC -dumpversion`
511 HOST_GCC_MACHINE
=`$CC -dumpmachine`
512 HAIKU_INCLUDE_PATENTED_CODE
=0
513 HAIKU_INCLUDE_SOURCES
=0
514 HAIKU_INCLUDE_3RDPARTY
=0
515 HAIKU_DISTRO_COMPATIBILITY
=default
516 TARGET_PLATFORM
=haiku
518 HAIKU_HOST_USE_32BIT
=0
519 HAIKU_HOST_USE_XATTR
=
520 HAIKU_HOST_USE_XATTR_REF
=
521 HAIKU_HOST_BUILD_ONLY
=0
522 HOST_EXTENDED_REGEX_SED
="sed -r"
523 HOST_GCC_LD
=`$CC -print-prog-name=ld`
524 HOST_GCC_OBJCOPY
=`$CC -print-prog-name=objcopy`
533 HAIKU_PACKAGING_ARCHS
=
535 set_default_value HAIKU_NASM nasm
537 if sha256sum
< /dev
/null
> /dev
/null
2>&1; then
538 HOST_SHA256
=sha256sum
539 elif sha256
< /dev
/null
> /dev
/null
2>&1; then
540 HOST_SHA256
="sha256 -q"
541 elif shasum
< /dev
/null
> /dev
/null
2>&1; then
542 HOST_SHA256
="shasum -a 256"
544 echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2
548 haikuRequiredLegacyGCCVersion
="2.95.3-haiku-2017_07_20"
549 export haikuRequiredLegacyGCCVersion
550 # version of legacy gcc required to build haiku
551 supportedTargetArchs
="
560 # determine output directory
561 if [ "$currentDir" = "$sourceDir" ]; then
562 outputDir
=$currentDir/generated
564 outputDir
=$currentDir
566 buildOutputDir
="$outputDir/build"
567 HAIKU_BUILD_ATTRIBUTES_DIR
="$outputDir/attributes"
568 buildConfigFile
="$buildOutputDir/BuildConfig"
570 # check for update request
571 if [ "$1" = "--update" ]; then
572 if ! [ -e "$buildConfigFile" ]; then
573 echo $0 --update: \'$buildConfigFile\' not found
- updating not possible.
576 # get last configure invocation and flags from BuildConfig and call ourselves with it
577 lastPwd
=`grep "#d " "$buildConfigFile" | cut -c 4-`
578 lastConfig
=`grep "#c " "$buildConfigFile" | cut -c 4-`
579 lastEnv
=`grep "#e " "$buildConfigFile" | cut -c 4-`
580 lastArgs
=`grep "#a " "$buildConfigFile" | cut -c 4-`
581 if [ -z "$lastConfig" ]; then
582 echo "$0 --update: The previous configure invocation was not properly" \
583 "encoded into '$buildConfigFile' - updating not possible."
587 if [ -n "$lastEnv" ]; then
590 $lastConfig $lastArgs
596 while [ $# -gt 0 ] ; do
599 assertparams
"$1" 3 $#
600 HOST_HAIKU_PORTER
="`absolute_path $2`"
601 HAIKU_PORTS_CROSS
="`absolute_path $3`"
602 HAIKU_PORTS
="`absolute_path $4`"
605 check_file_exists
"$HOST_HAIKU_PORTER" ||
(
606 echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2
609 check_dir_exists
"$HAIKU_PORTS" ||
(
610 echo "Non-existent directory $HAIKU_PORTS" >&2
613 check_dir_exists
"$HAIKU_PORTS_CROSS" ||
(
614 echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2
620 if [ -z "$buildCrossTools" ]; then
621 assertparams
"$1" 2 $#
630 case "$targetArch" in
631 x86_gcc2
) targetMachine
=i586-pc-haiku
;;
632 x86
) targetMachine
=i586-pc-haiku
;;
633 x86_64
) targetMachine
=x86_64-unknown-haiku
;;
634 ppc
) targetMachine
=powerpc-apple-haiku
;;
635 m68k
) targetMachine
=m68k-unknown-haiku
;;
636 arm
) targetMachine
=arm-unknown-haiku
;;
638 echo "Unsupported target architecture: $2" >&2
642 set_variable buildCrossToolsMachine_
$targetArch $targetMachine
643 targetArchs
="$targetArchs $targetArch"
644 HAIKU_PACKAGING_ARCHS
=
646 --cross-tools-prefix)
648 targetArch
=unknown
${unknownArchIndex}
649 set_variable crossToolsPrefix_
$targetArch "$2"
650 targetArchs
="$targetArchs $targetArch"
651 HAIKU_PACKAGING_ARCHS
=
652 unknownArchIndex
=$
(($unknownArchIndex + 1))
655 --distro-compatibility)
657 HAIKU_DISTRO_COMPATIBILITY
=$2
658 case "$HAIKU_DISTRO_COMPATIBILITY" in
662 *) echo "Invalid distro compatibility" \
663 "level: $HAIKU_DISTRO_COMPATIBILITY"
668 --host-only) HAIKU_HOST_BUILD_ONLY
=1; shift 1;;
669 --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE
=1; shift 1;;
670 --include-sources) HAIKU_INCLUDE_SOURCES
=1; shift 1;;
671 --include-3rdparty) HAIKU_INCLUDE_3RDPARTY
=1; shift 1;;
672 -j*) buildCrossToolsJobs
="$1"; shift 1;;
673 --no-downloads) HAIKU_NO_DOWNLOADS
=1; shift 1;;
674 --target=*) TARGET_PLATFORM
=`echo $1 | cut -d'=' -f2-`; shift 1;;
679 if [ ! "$platform" = Haiku
]; then
680 echo "--target-arch can only be specified on Haiku." >&2
683 is_in_list
"$targetArch" "$supportedTargetArchs" ||
(
684 echo "Unsupported target architecture: \"$targetArch\"" >&2
687 haikuTargetArchs
="$haikuTargetArchs $targetArch"
693 case "$targetArch" in
694 x86
) targetMachine
=i586-pc-haiku
;;
695 x86_64
) targetMachine
=x86_64-unknown-haiku
;;
697 echo "Unsupported target architecture: $2" >&2
701 get_build_tool_path clang clang
702 if [ -n "crossToolsPrefix_$targetArch" ]; then
703 set_variable crossToolsPrefix_
$targetArch llvm-
705 targetArchs
="$targetArchs $targetArch"
706 HAIKU_PACKAGING_ARCHS
=
709 --use-gcc-pipe) HAIKU_USE_GCC_PIPE
=1; shift 1;;
710 --use-gcc-graphite) useGccGraphiteDefault
=1; shift 1;;
711 --use-32bit) HAIKU_HOST_USE_32BIT
=1; shift 1;;
712 --no-full-xattr)HAIKU_HOST_USE_XATTR
=0; shift 1;;
713 --no-xattr) HAIKU_HOST_USE_XATTR_REF
=0; shift 1;;
714 --with-gdb) gdbSources
=$2; shift 2;;
715 *) echo Invalid argument
: \
`$1\'; exit 1;;
719 # detect the build platform
720 case "${platform}" in
721 Darwin) HOST_PLATFORM=darwin ;;
722 FreeBSD) HOST_PLATFORM=freebsd
723 if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then
724 echo Unsupported platform: FreeBSD ${platformMachine}
727 Haiku) HOST_PLATFORM=haiku_host ;;
728 Linux) HOST_PLATFORM=linux ;;
729 OpenBSD) HOST_PLATFORM=openbsd ;;
730 SunOS) HOST_PLATFORM=sunos ;;
731 CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
732 *) echo Unsupported platform: ${platform}
736 # check for case-sensitive filesystem
737 mkdir haikuCaseTest 2>/dev/null
738 mkdir haikucasetest 2>/dev/null
740 rmdir haikuCaseTest haikucasetest 2>/dev/null
741 if [ $caseInsensitive != 0 ]; then
742 echo "You need a case-sensitive file-system to build Haiku."
743 if [ $HOST_PLATFORM = "darwin" ]; then
744 echo "You can create a case-sensitive disk image using Disk Utility."
749 # check xattr support
750 if [ $HOST_PLATFORM != "haiku_host" ] && [ -z $HAIKU_HOST_USE_XATTR_REF ]; then
753 if [ $attrSupport = 2 ] && [ -z $HAIKU_HOST_USE_XATTR ]; then
754 HAIKU_HOST_USE_XATTR=1
755 elif [ $attrSupport = 1 ]; then
756 HAIKU_HOST_USE_XATTR_REF=1
759 if [ -z $HAIKU_HOST_USE_XATTR ]; then HAIKU_HOST_USE_XATTR=0; fi
760 if [ -z $HAIKU_HOST_USE_XATTR_REF ]; then HAIKU_HOST_USE_XATTR_REF=0; fi
762 # determine how to invoke sed with extended regexp support for non-GNU sed
763 if [ $HOST_PLATFORM = "darwin" ]; then
764 HOST_EXTENDED_REGEX_SED="sed -E"
767 # check if nasm can actually output ELF files
768 # (the stock version in OSX can't)
769 # XXX: should probably only test for x86* arch
770 if [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then
771 echo "$HAIKU_NASM cannot generate ELF files. Please install a working version."
772 if [ $HOST_PLATFORM = "darwin" ]; then
773 echo "You can install it from Mac Ports."
774 echo "Mac Ports is available at: http://www.macports.org/"
779 # create output directory
780 mkdir -p "$buildOutputDir" || exit 1
782 if [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
783 invalidCommand=$sourceDir/build/scripts/host_build_only
784 HAIKU_AR=$invalidCommand
785 HAIKU_CC=$invalidCommand
786 HAIKU_LD=$invalidCommand
787 HAIKU_OBJCOPY=$invalidCommand
788 HAIKU_RANLIB=$invalidCommand
789 HAIKU_ELFEDIT=$invalidCommand
790 HAIKU_NASM=$invalidCommand
791 HAIKU_STRIP=$invalidCommand
793 if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then
794 targetArchs="$HAIKU_PACKAGING_ARCHS"
796 HAIKU_PACKAGING_ARCHS=
798 # On Haiku determine target architectures and tools automatically.
799 if [ -z "$targetArchs" ]; then
800 if [ $HOST_PLATFORM != haiku_host ]; then
801 echo "Please specify the build tools to use or build (via" \
802 "--cross-tools-prefix or --build-cross-tools) or specify a" \
803 "host-only build (--host-only)." >&2
804 echo "For more info, invoke $0 --help"
808 # determine primary architecture
809 targetArch=`package list
-i /system
/packages
/haiku-
*.hpkg \
810 |
sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'`
811 is_in_list "$targetArch" "$supportedTargetArchs" || (
812 echo "Unsupported target architecture: \"$targetArch\"" >&2
815 targetArchs=$targetArch
817 set_default_value HAIKU_AR_$targetArch ar
818 set_default_value HAIKU_CC_$targetArch gcc
819 set_default_value HAIKU_LD_$targetArch ld
820 set_default_value HAIKU_OBJCOPY_$targetArch objcopy
821 set_default_value HAIKU_RANLIB_$targetArch ranlib
822 set_default_value HAIKU_ELFEDIT_$targetArch elfedit
823 set_default_value HAIKU_STRIP_$targetArch strip
825 # determine secondary architectures
826 for targetArch in $supportedTargetArchs; do
827 if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then
828 targetArchs="$targetArchs $targetArch"
829 set_default_value HAIKU_AR_$targetArch ar-$targetArch
830 set_default_value HAIKU_CC_$targetArch gcc-$targetArch
831 set_default_value HAIKU_LD_$targetArch ld-$targetArch
832 set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch
833 set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch
834 set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch
835 set_default_value HAIKU_STRIP_$targetArch strip-$targetArch
839 # The target architectures might have been specified explicitly.
840 if [ -n "$haikuTargetArchs" ]; then
841 for targetArch in $haikuTargetArchs; do
842 is_in_list "$targetArch" "$targetArchs" || (
843 echo "Unsupported target architecture: \"$targetArch\"." \
844 "Only native architectures of the host platform can" \
849 targetArchs="$haikuTargetArchs"
854 for targetArch in $targetArchs; do
855 # Note: targetArch is "unknown<n>" at this point, if a cross-tools
856 # prefix was specified. The standard_gcc_settings call below will get
857 # the actual architecture.
859 crossToolsPrefix=`get_variable crossToolsPrefix_
$targetArch`
861 # build cross tools from sources
862 if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then
863 crossToolsDir="$outputDir/cross-tools-$targetArch"
864 targetMachine=`get_variable buildCrossToolsMachine_
$targetArch`
865 script="$buildCrossToolsScript"
867 if [ $targetArch != x86_gcc2 ]; then
868 script="${script}_gcc4"
869 scriptArgs="$targetMachine"
870 set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \
871 $useGccGraphiteDefault
874 if [ -z "$isPrimaryArch" ]; then
875 secondaryArch=$targetArch
878 case $HOST_PLATFORM in
879 freebsd|openbsd) MAKE=gmake;;
883 if [ ! -d "$crossToolsDir" ]; then
885 SECONDARY_ARCH=$secondaryArch \
886 HAIKU_USE_GCC_GRAPHITE=`get_variable \
887 HAIKU_USE_GCC_GRAPHITE_
$targetArch` \
888 HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
889 HAIKU_USE_GDB="$gdbSources" \
890 "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
891 "$crossToolsDir" $buildCrossToolsJobs || exit 1
893 echo "$targetArch crosstools already exist in $crossToolsDir; skipping build"
895 crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
898 # prepare gcc settings and get the actual target architecture
899 if [ $useClang = 1 ]; then
900 gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as"
902 # Clang's compiler intrinsics are not compatible with GCC's or even
903 # across versions of Clang, so we must collect them for use in the build.
904 mkdir -p "$outputDir/clang_headers" || exit 1
905 clangHeadersDir=`$gcc -print-resource-dir`/include/
906 cp $clangHeadersDir/*intrin* $clangHeadersDir/mm3* "$outputDir/clang_headers" || exit 1
907 elif [ -z "${crossToolsPrefix}" ]; then
908 gcc=`get_variable HAIKU_CC_
$targetArch`
910 gcc="${crossToolsPrefix}gcc"
912 standard_gcc_settings "$gcc"
913 targetArch=$standard_gcc_settings_targetArch
915 # set default values for flags
916 set_default_value HAIKU_CPPFLAGS_$targetArch ""
917 set_default_value HAIKU_CCFLAGS_$targetArch ""
918 set_default_value HAIKU_CXXFLAGS_$targetArch ""
919 set_default_value HAIKU_LDFLAGS_$targetArch ""
920 set_default_value HAIKU_ARFLAGS_$targetArch cru
921 set_default_value HAIKU_UNARFLAGS_$targetArch x
923 # Override the cross tools variables, if the tools were built or a
924 # prefix was specified.
925 if [ -n "$crossToolsPrefix" ]; then
926 get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar
927 get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld
928 get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy
929 get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib
930 get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip
932 case `get_variable HAIKU_GCC_RAW_VERSION_
$targetArch` in
934 get_build_tool_path ELFEDIT_$targetArch \
935 ${crossToolsPrefix}elfedit
940 # check whether the Haiku compiler really targets Haiku
941 targetMachine=`get_variable HAIKU_GCC_MACHINE_
$targetArch`
942 case "$targetMachine" in
945 echo The compiler specified as Haiku target compiler is not a \
946 valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
947 echo compiler: $HAIKU_CC
948 echo compiler is configured for target: $targetMachine
952 HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch"
957 # Generate BuildConfig
958 cat << EOF > "$buildConfigFile"
960 # This file was AUTOMATICALLY GENERATED by configure, and will be completely
961 # overwritten the next time configure is run.
965 #e ${configureEnvirons}
968 TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
969 HOST_PLATFORM ?= "${HOST_PLATFORM}" ;
971 HAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
972 HAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ;
973 HAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ;
974 HAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
975 HAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ;
976 HAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ;
977 HAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ;
978 HAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ;
979 HAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ;
981 HAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ;
983 HAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ;
985 HAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
987 HAIKU_NASM ?= ${HAIKU_NASM} ;
988 HAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ;
990 HOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ;
991 HOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ;
992 HOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ;
993 HOST_LD ?= ${HOST_GCC_LD} ;
994 HOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ;
995 HOST_SHA256 ?= ${HOST_SHA256} ;
997 HOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ;
998 HAIKU_PORTS ?= ${HAIKU_PORTS} ;
999 HAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ;
1000 HAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ;
1004 for targetArch in $HAIKU_PACKAGING_ARCHS; do
1006 HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION
1007 HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE
1008 HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR
1010 HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC
1011 HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX
1014 HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG
1016 HAIKU_OBJCOPY HAIKU_OBJCOPY
1017 HAIKU_RANLIB HAIKU_RANLIB
1018 HAIKU_ELFEDIT HAIKU_ELFEDIT
1019 HAIKU_STRIP HAIKU_STRIP
1020 HAIKU_CPPFLAGS HAIKU_CPPFLAGS
1021 HAIKU_CCFLAGS HAIKU_CCFLAGS
1022 HAIKU_C++FLAGS HAIKU_CXXFLAGS
1023 HAIKU_LDFLAGS HAIKU_LDFLAGS
1024 HAIKU_ARFLAGS HAIKU_ARFLAGS
1025 HAIKU_UNARFLAGS HAIKU_UNARFLAGS
1026 HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE
1029 while [ $# -ge 2 ]; do
1030 value=`get_variable
${2}_
$targetArch`
1031 echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile"
1035 # For variables that may have long values, distribute them over multiple
1036 # lines so that jam doesn't hit the maximum line length.
1038 HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR
1041 while [ $# -ge 2 ]; do
1042 echo "${1}_${targetArch} ?= " >> "$buildConfigFile"
1043 get_variable ${2}_$targetArch | xargs -n 1 echo " " \
1044 >> "$buildConfigFile"
1045 echo " ;" >> "$buildConfigFile"
1051 # Generate a boot strap Jamfile in the output directory.
1053 cat << EOF > $outputDir/Jamfile
1054 # automatically generated Jamfile
1056 HAIKU_TOP = ${sourceDir} ;
1057 HAIKU_OUTPUT_DIR = ${outputDir} ;
1059 include [ FDirName \$(HAIKU_TOP) Jamfile ] ;
1063 echo "Configured successfully!"