RemoteHWInterface: Add mechanism to retrieve the system palette.
[haiku.git] / configure
blobb9228b7a83051396e8420c15c24a0561d2beafb4
1 #!/bin/sh
3 # configure [ <options> ]
5 # usage
7 # Prints usage.
9 usage()
11 cat << EOF
13 Usage: $0 <options>
14 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
50 accordingly.
51 official -- the official Haiku distribution.
52 compatible -- a Haiku Compatible (tm) distro.
53 default -- any other distro (default value).
54 --enable-multiuser Enable experimental multiuser support.
55 --help Prints out this help.
56 --host-only Configure for building tools for the build host
57 only. Haiku cannot be built when configured like
58 this.
59 --include-patented-code Enable code that is known to implemented patented
60 ideas and techniques. If this option is not
61 specified, the resulting distribution may still
62 implement patented ideas and techniques. This
63 option only disables code that is currently known
64 to be problematic.
65 --include-sources Includes the source code of projects that require
66 either an offer of source code or a copy of the
67 patched sources. This is preferable when
68 distributing on physical mediums.
69 --include-3rdparty Include 3rdparty/ in the build system.
70 -j<n> Only relevant for --build-cross-tools. Is passed
71 on to the make building the build tools.
72 --no-downloads Do not download anything. Useful when trying to
73 bootstrap and build Haiku from source only.
74 --target=TARGET Select build target platform.
75 [default=${TARGET_PLATFORM}]
76 valid targets=r5,bone,dano,haiku
77 --target-arch <arch> Haiku only: Specify the target architecture to
78 build for. Must be one of the architectures of the
79 host system. The installed build tools for that
80 architecture will be used.
81 This option can be specified multiple times. The
82 first occurrence specifies the primary
83 architecture of the Haiku to build, subsequent
84 ones the secondary architectures.
85 --update re-runs last configure invocation [must be given
86 as first option!]
87 --use-clang Build with host Clang instead of GCC cross
88 compiler
89 --use-gcc-pipe Build with GCC option -pipe. Speeds up the build
90 process, but uses more memory.
91 --use-gcc-graphite Build with GCC Graphite engine for loop
92 optimizations. Only for gcc 4.
93 --use-32bit Use -m32 flag on 64bit host gcc compiler.
94 --use-xattr Use Linux xattr respectively *BSD extattr support
95 for BeOS attribute emulation. Warning: Make sure
96 your file system supports sufficient attribute
97 sizes (4 KB per file for all attributes won't
98 suffice).
99 --use-xattr-ref Use the generic BeOS attribute emulation, but use
100 Linux xattr respectively *BSD extattr support to
101 make it more robust (i.e. attribute mix-ups become
102 less likely).
103 --with-gdb <gdb sources dir>
104 specify the path to a GDB source dir, to build
105 GDB for each arch we build the cross-tools for.
107 environment variables:
108 CC The host compiler. Defaults to "gcc".
109 HAIKU_AR_x86_gcc2 The static library archiver for x86_gcc2.
110 Defaults to "ar".
111 HAIKU_CC_x86_gcc2 The x86_gcc2 compiler. Defaults to "gcc".
112 HAIKU_LD_x86_gcc2 The x86_gcc2 linker. Defaults to "ld".
113 HAIKU_OBJCOPY_x86_gcc2 The x86_gcc2 objcopy to be used. Defaults to
114 "objcopy".
115 HAIKU_RANLIB_x86_gcc2 The static library indexer for x86_gcc2. Defaults
116 to "ranlib".
117 HAIKU_STRIP_x86_gcc2 The x86_gcc2 strip command. Defaults to "strip".
118 HAIKU_NASM The nasm assembler (x86 and x86_64 only).
119 HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture
120 <arch>. Defaults to "".
121 HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>.
122 Defaults to "".
123 HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>.
124 Defaults to "".
125 HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>.
126 Defaults to "".
127 HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target
128 architecture <arch> for archiving. Defaults to
129 "cru".
130 HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target
131 architecture <arch> for unarchiving. Defaults to
132 "x".
134 Non-default output directories:
135 By default all objects, build configuration, and other related files are
136 stored in /path/to/haiku_source/generated. To store objects in a non-default
137 location, run "../../relative/path/to/haiku_source/configure <options>" from
138 within your non-default location. "jam [ options ] targets" can then be run
139 directly inside your non-default location. Another option is to invoke "jam
140 [ options ] targets" from within haiku_source. This can be accomplished by
141 either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
142 jam or by creating a symlink of haiku_source/generated pointing to your
143 non-default location and running jam.
149 # assertparam
151 # Checks whether at least one parameter is left.
153 assertparam()
155 if [ $2 -lt 2 ]; then
156 echo $0: \`$1\': Parameter expected.
157 exit 1
161 # assertparams
163 # Checks whether at least a certain number of parameters is left.
165 assertparams()
167 if [ $3 -le $2 ]; then
168 echo $0: \`$1\': Not enough parameters.
169 exit 1
173 # absolute_path
175 # returns the absolute path of a given path.
177 absolute_path()
179 if [ "x$1" != "x${1#/}" ]; then
180 echo "$1"
181 else
182 echo "`pwd`/$1"
186 # check_dir_exists
188 # check if a directory exists or not
190 check_dir_exists()
192 if [ -d "$1" ]; then
193 return 0
194 else
195 return 1
199 # check_file_exists
201 # check if a file exists or not
203 check_file_exists()
205 if [ -f "$1" ]; then
206 return 0
207 else
208 return 1
212 # real_path
214 # returns the realpath of a symbolic link.
216 real_path()
218 perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1"
221 # standard_gcc_settings
223 # Sets the variables for a GCC platform.
225 standard_gcc_settings()
227 local gcc=$1
229 if which greadlink > /dev/null 2>&1; then
230 readlink="greadlink -e"
231 elif which realpath > /dev/null 2>&1; then
232 readlink=realpath
233 elif readlink -e / > /dev/null 2>&1; then
234 readlink="readlink -e"
235 else
236 readlink=real_path
239 # PLATFORM_LINKLIBS
240 local gcclib=`$gcc -print-libgcc-file-name`
241 local gccdir=`dirname ${gcclib}`
243 local gccRawVersion=`$gcc -dumpversion`
244 local gccMachine=`$gcc -dumpmachine`
246 # determine architecture from machine triple
247 case $gccMachine in
248 arm-*) targetCpu=arm;;
249 i?86-*) targetCpu=x86;;
250 m68k-*) targetCpu=m68k;;
251 powerpc-*) targetCpu=ppc;;
252 x86_64-*) targetCpu=x86_64;;
254 echo "Unsupported gcc target machine: $gccMachine" >&2
255 exit 1
257 esac
259 local targetArch=$targetCpu
261 case $gccRawVersion in
262 2.9*)
263 # check for correct (most up-to-date) legacy compiler and complain
264 # if an older one is installed
265 if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then
266 echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
267 echo "Please download it from www.haiku-os.org...";
268 exit 1;
271 targetArch=x86_gcc2
273 esac
275 local bootLibgcc
276 local bootLibSupCxx
277 local bootCxxHeaders
278 case $gccMachine in
279 x86_64-*)
280 # Boot loader is 32-bit, need the 32-bit libs and c++ config
281 bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a`
282 bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a`
284 local headersBase=$gccdir/../../../..
285 local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion
286 if [ ! -d $headers ]; then
287 headers=$headersBase/include/c++/$gccRawVersion
289 bootCxxHeaders="$headers/$gccMachine/32"
291 esac
293 # determine whether graphite loop optimization should/can be used
294 local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu`
295 if [ -z "$useGraphite" ]; then
296 useGraphite=$useGccGraphiteDefault
299 if [ "$useGraphite" != 0 ]; then
300 UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1`
301 if [ $? != 0 ]; then
302 echo "GCC Graphite loop optimizations cannot be used on $targetArch"
303 useGraphite=0
307 set_variable HAIKU_CPU_$targetArch $targetCpu
309 get_build_tool_path CC_$targetArch "$gcc"
310 set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang
311 set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion
312 set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine
313 set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir
314 set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders"
315 set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx"
316 set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc
317 set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite
319 standard_gcc_settings_targetArch=$targetArch
322 # set_variable
324 # Set the value of a variable.
326 set_variable()
328 eval "$1=\"$2\""
331 # get_variable
333 # Echo the value of a variable.
335 get_variable()
337 eval "echo \${$1}"
340 # set_default_value
342 # Set the value for a variable, if no value is set yet.
344 set_default_value()
346 eval "$1=\${$1-$2}"
349 # get_build_tool_path
351 # Gets a usable absolute path of a build tool.
353 get_build_tool_path()
355 local var="HAIKU_$1"
356 local cmd=$2
357 local path=${2%% *}
359 if [ -f "$path" ]; then
360 # get absolute path
361 local oldPwd="`pwd`"
362 cd "`dirname "$path"`"
363 path="`pwd`/`basename "$path"`"
364 cd $oldPwd
365 else
366 which "$path" > /dev/null 2>&1 || {
367 echo "Build tool \"$path\" not found." >&2
368 exit 1
372 eval "$var=\"$path ${cmd#${2%% *}}\""
375 is_in_list()
377 local element
378 for element in $2; do
379 if [ "$1" = "$element" ]; then
380 return 0
382 done
383 return 1
386 # check for --help or -h and show usage immediately
387 if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
388 usage; exit 0;
391 # ensure umask is not too restrictive
392 if [ $(umask) -gt 22 ]; then
393 echo "Your umask is too restrictive (should be: <= 0022; is actually:" $(umask)")"
394 exit 1
397 # get cwd and the source directory
398 currentDir=`pwd`
399 cd `dirname "$0"`
400 sourceDir=`pwd`
401 cd "$currentDir"
403 # backup the passed arguments
404 configureArgs="$@"
406 # internal default parameter values
408 platform=`uname`
409 platformMachine=`uname -m`
410 targetArchs=
411 buildCrossTools=
412 buildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
413 buildCrossToolsJobs=
414 useClang=0
415 useGccGraphiteDefault=0
416 unknownArchIndex=1
417 haikuTargetArchs=
418 gdbSources=
420 if [ -z "$CC" ]; then
421 CC=gcc
424 # exported (BuildSetup) default parameter values
426 HOST_GCC_RAW_VERSION=`$CC -dumpversion`
427 HOST_GCC_MACHINE=`$CC -dumpmachine`
428 HAIKU_INCLUDE_PATENTED_CODE=0
429 HAIKU_INCLUDE_SOURCES=0
430 HAIKU_INCLUDE_3RDPARTY=0
431 HAIKU_ENABLE_MULTIUSER=0
432 HAIKU_DISTRO_COMPATIBILITY=default
433 TARGET_PLATFORM=haiku
434 HAIKU_USE_GCC_PIPE=0
435 HAIKU_HOST_USE_32BIT=0
436 HAIKU_HOST_USE_XATTR=0
437 HAIKU_HOST_USE_XATTR_REF=0
438 HAIKU_HOST_BUILD_ONLY=0
439 HOST_EXTENDED_REGEX_SED="sed -r"
440 HOST_GCC_LD=`$CC -print-prog-name=ld`
441 HOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy`
442 HOST_SHA256=
443 HOST_HAIKU_PORTER=
444 HAIKU_PORTS=
445 HAIKU_PORTS_CROSS=
446 HAIKU_IS_BOOTSTRAP=0
447 HAIKU_BOOT_BOARD=
448 HAIKU_NO_DOWNLOADS=0
450 HAIKU_PACKAGING_ARCHS=
452 set_default_value HAIKU_NASM nasm
454 if sha256sum < /dev/null > /dev/null 2>&1; then
455 HOST_SHA256=sha256sum
456 elif sha256 < /dev/null > /dev/null 2>&1; then
457 HOST_SHA256="sha256 -q"
458 elif shasum < /dev/null > /dev/null 2>&1; then
459 HOST_SHA256="shasum -a 256"
460 else
461 echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2
462 exit 1
465 haikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20"
466 export haikuRequiredLegacyGCCVersion
467 # version of legacy gcc required to build haiku
468 supportedTargetArchs="
470 m68k
473 x86_64
474 x86_gcc2
477 # determine output directory
478 if [ "$currentDir" = "$sourceDir" ]; then
479 outputDir=$currentDir/generated
480 else
481 outputDir=$currentDir
483 buildOutputDir="$outputDir/build"
484 HAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes"
485 buildConfigFile="$buildOutputDir/BuildConfig"
487 # check for update request
488 if [ "$1" = "--update" ]; then
489 if ! [ -e "$buildConfigFile" ]; then
490 echo $0 --update: \'$buildConfigFile\' not found - updating not possible.
491 exit 1
493 if ! type perl >/dev/null 2>&1; then
494 echo $0 --update: \'perl\' not found - updating not possible.
495 exit 1
497 # convert BuildConfig from jam format to shell format and evaluate it
498 shellConfigFile="${buildConfigFile}.shell"
499 perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
500 <"$buildConfigFile" >"$shellConfigFile"
501 . "$shellConfigFile"
502 rm "$shellConfigFile"
503 shift
506 # parse parameters
508 while [ $# -gt 0 ] ; do
509 case "$1" in
510 --bootstrap)
511 assertparams "$1" 3 $#
512 HOST_HAIKU_PORTER="`absolute_path $2`"
513 HAIKU_PORTS_CROSS="`absolute_path $3`"
514 HAIKU_PORTS="`absolute_path $4`"
515 HAIKU_IS_BOOTSTRAP=1
516 HAIKU_NO_DOWNLOADS=1
517 check_file_exists "$HOST_HAIKU_PORTER" || (
518 echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2
519 exit 1
521 check_dir_exists "$HAIKU_PORTS" || (
522 echo "Non-existent directory $HAIKU_PORTS" >&2
523 exit 1
525 check_dir_exists "$HAIKU_PORTS_CROSS" || (
526 echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2
527 exit 1
529 shift 4
531 --build-cross-tools)
532 if [ -z "$buildCrossTools" ]; then
533 assertparams "$1" 2 $#
534 targetArch=$2
535 buildCrossTools=$3
536 shift 3
537 else
538 assertparam "$1" $#
539 targetArch=$2
540 shift 2
542 case "$targetArch" in
543 x86_gcc2) targetMachine=i586-pc-haiku;;
544 x86) targetMachine=i586-pc-haiku;;
545 x86_64) targetMachine=x86_64-unknown-haiku;;
546 ppc) targetMachine=powerpc-apple-haiku;;
547 m68k) targetMachine=m68k-unknown-haiku;;
548 arm) targetMachine=arm-unknown-haiku;;
550 echo "Unsupported target architecture: $2" >&2
551 exit 1
553 esac
554 set_variable buildCrossToolsMachine_$targetArch $targetMachine
555 targetArchs="$targetArchs $targetArch"
556 HAIKU_PACKAGING_ARCHS=
558 --cross-tools-prefix)
559 assertparam "$1" $#
560 targetArch=unknown${unknownArchIndex}
561 set_variable crossToolsPrefix_$targetArch "$2"
562 targetArchs="$targetArchs $targetArch"
563 HAIKU_PACKAGING_ARCHS=
564 unknownArchIndex=$(($unknownArchIndex + 1))
565 shift 2
567 --distro-compatibility)
568 assertparam "$1" $#
569 HAIKU_DISTRO_COMPATIBILITY=$2
570 case "$HAIKU_DISTRO_COMPATIBILITY" in
571 official) ;;
572 compatible) ;;
573 default) ;;
574 *) echo "Invalid distro compatibility" \
575 "level: $HAIKU_DISTRO_COMPATIBILITY"
576 exit 1;;
577 esac
578 shift 2
580 --enable-multiuser) HAIKU_ENABLE_MULTIUSER=1; shift 1;;
581 --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;;
582 --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;;
583 --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;;
584 --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;;
585 -j*) buildCrossToolsJobs="$1"; shift 1;;
586 --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;;
587 --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;;
588 --target-arch)
589 assertparam "$1" $#
590 targetArch=$2
591 shift 2
592 if [ ! "$platform" = Haiku ]; then
593 echo "--target-arch can only be specified on Haiku." >&2
594 exit 1
596 is_in_list "$targetArch" "$supportedTargetArchs" || (
597 echo "Unsupported target architecture: \"$targetArch\"" >&2
598 exit 1
600 haikuTargetArchs="$haikuTargetArchs $targetArch"
602 --use-clang) useClang=1; shift 1;;
603 --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;;
604 --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;;
605 --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;;
606 --use-xattr) HAIKU_HOST_USE_XATTR=1; shift 1;;
607 --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF=1; shift 1;;
608 --with-gdb) gdbSources=$2; shift 2;;
609 *) echo Invalid argument: \`$1\'; exit 1;;
610 esac
611 done
613 # detect the build platform
614 case "${platform}" in
615 Darwin) HOST_PLATFORM=darwin ;;
616 FreeBSD) HOST_PLATFORM=freebsd
617 if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then
618 echo Unsupported platform: FreeBSD ${platformMachine}
619 exit 1
620 fi ;;
621 Haiku) HOST_PLATFORM=haiku_host ;;
622 Linux) HOST_PLATFORM=linux ;;
623 OpenBSD) HOST_PLATFORM=openbsd ;;
624 SunOS) HOST_PLATFORM=sunos ;;
625 CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
626 *) echo Unsupported platform: ${platform}
627 exit 1 ;;
628 esac
630 # check for case-sensitive filesystem
631 mkdir haikuCaseTest 2>/dev/null
632 mkdir haikucasetest 2>/dev/null
633 caseInsensitive=$?
634 rmdir haikuCaseTest haikucasetest 2>/dev/null
635 if [ $caseInsensitive != 0 ]; then
636 echo "You need a case-sensitive file-system to build Haiku."
637 if [ $HOST_PLATFORM = "darwin" ]; then
638 echo "You can create a case-sensitive disk image using Disk Utility."
640 exit 1
643 # determine how to invoke sed with extended regexp support for non-GNU sed
644 if [ $HOST_PLATFORM = "darwin" ]; then
645 HOST_EXTENDED_REGEX_SED="sed -E"
648 # check if nasm can actually output ELF files
649 # (the stock version in OSX can't)
650 # XXX: should probably only test for x86* arch
651 if [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then
652 echo "$HAIKU_NASM cannot generate ELF files. Please install a working version."
653 if [ $HOST_PLATFORM = "darwin" ]; then
654 echo "You can install it from Mac Ports."
655 echo "Mac Ports is available at: http://www.macports.org/"
657 exit 1
660 # create output directory
661 mkdir -p "$buildOutputDir" || exit 1
663 if [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
664 invalidCommand=$sourceDir/build/scripts/host_build_only
665 HAIKU_AR=$invalidCommand
666 HAIKU_CC=$invalidCommand
667 HAIKU_LD=$invalidCommand
668 HAIKU_OBJCOPY=$invalidCommand
669 HAIKU_RANLIB=$invalidCommand
670 HAIKU_ELFEDIT=$invalidCommand
671 HAIKU_NASM=$invalidCommand
672 HAIKU_STRIP=$invalidCommand
673 else
674 if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then
675 targetArchs="$HAIKU_PACKAGING_ARCHS"
677 HAIKU_PACKAGING_ARCHS=
679 # On Haiku determine target architectures and tools automatically.
680 if [ -z "$targetArchs" ]; then
681 if [ $HOST_PLATFORM != haiku_host ]; then
682 echo "Please specify the build tools to use or build (via" \
683 "--cross-tools-prefix or --build-cross-tools) or specify a" \
684 "host-only build (--host-only)." >&2
685 echo "For more info, invoke $0 --help"
686 exit 1
689 # determine primary architecture
690 targetArch=`package list -i /system/packages/haiku-*.hpkg \
691 | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'`
692 is_in_list "$targetArch" "$supportedTargetArchs" || (
693 echo "Unsupported target architecture: \"$targetArch\"" >&2
694 exit 1
696 targetArchs=$targetArch
698 set_default_value HAIKU_AR_$targetArch ar
699 set_default_value HAIKU_CC_$targetArch gcc
700 set_default_value HAIKU_LD_$targetArch ld
701 set_default_value HAIKU_OBJCOPY_$targetArch objcopy
702 set_default_value HAIKU_RANLIB_$targetArch ranlib
703 set_default_value HAIKU_ELFEDIT_$targetArch elfedit
704 set_default_value HAIKU_STRIP_$targetArch strip
706 # determine secondary architectures
707 for targetArch in $supportedTargetArchs; do
708 if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then
709 targetArchs="$targetArchs $targetArch"
710 set_default_value HAIKU_AR_$targetArch ar-$targetArch
711 set_default_value HAIKU_CC_$targetArch gcc-$targetArch
712 set_default_value HAIKU_LD_$targetArch ld-$targetArch
713 set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch
714 set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch
715 set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch
716 set_default_value HAIKU_STRIP_$targetArch strip-$targetArch
718 done
720 # The target architectures might have been specified explicitly.
721 if [ -n "$haikuTargetArchs" ]; then
722 for targetArch in $haikuTargetArchs; do
723 is_in_list "$targetArch" "$targetArchs" || (
724 echo "Unsupported target architecture: \"$targetArch\"." \
725 "Only native architectures of the host platform can" \
726 "be specified." >&2
727 exit 1
729 done
730 targetArchs="$haikuTargetArchs"
734 isPrimaryArch=1
735 for targetArch in $targetArchs; do
736 # Note: targetArch is "unknown<n>" at this point, if a cross-tools
737 # prefix was specified. The standard_gcc_settings call below will get
738 # the actual architecture.
740 crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch`
742 # build cross tools from sources
743 if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then
744 crossToolsDir="$outputDir/cross-tools-$targetArch"
745 targetMachine=`get_variable buildCrossToolsMachine_$targetArch`
746 script="$buildCrossToolsScript"
747 scriptArgs=
748 if [ $targetArch != x86_gcc2 ]; then
749 script="${script}_gcc4"
750 scriptArgs="$targetMachine"
751 set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \
752 $useGccGraphiteDefault
754 secondaryArch=
755 if [ -z "$isPrimaryArch" ]; then
756 secondaryArch=$targetArch
759 case $HOST_PLATFORM in
760 freebsd|openbsd) MAKE=gmake;;
761 *) MAKE=make;;
762 esac
764 MAKE=$MAKE \
765 SECONDARY_ARCH=$secondaryArch \
766 HAIKU_USE_GCC_GRAPHITE=`get_variable \
767 HAIKU_USE_GCC_GRAPHITE_$targetArch` \
768 HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
769 HAIKU_USE_GDB="$gdbSources" \
770 "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
771 "$crossToolsDir" $buildCrossToolsJobs || exit 1
772 crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
775 # prepare gcc settings and get the actual target architecture
776 if [ $useClang = 1 ]; then
777 target=${crossToolsPrefix##*/}
778 target=${target%-}
779 gcc="clang -target ${target} -no-integrated-as"
780 else
781 gcc="${crossToolsPrefix}gcc"
783 if [ -z "${crossToolsPrefix}" ]; then
784 gcc=`get_variable HAIKU_CC_$targetArch`
786 standard_gcc_settings "$gcc"
787 targetArch=$standard_gcc_settings_targetArch
789 # set default values for flags
790 set_default_value HAIKU_CPPFLAGS_$targetArch ""
791 set_default_value HAIKU_CCFLAGS_$targetArch ""
792 set_default_value HAIKU_CXXFLAGS_$targetArch ""
793 set_default_value HAIKU_LDFLAGS_$targetArch ""
794 set_default_value HAIKU_ARFLAGS_$targetArch cru
795 set_default_value HAIKU_UNARFLAGS_$targetArch x
797 # Override the cross tools variables, if the tools were built or a
798 # prefix was specified.
799 if [ -n "$crossToolsPrefix" ]; then
800 get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar
801 get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld
802 get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy
803 get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib
804 get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip
806 case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in
807 4.*|5.*|6.*|7.*|8.*)
808 get_build_tool_path ELFEDIT_$targetArch \
809 ${crossToolsPrefix}elfedit
811 esac
814 # check whether the Haiku compiler really targets Haiku
815 targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch`
816 case "$targetMachine" in
817 *-*-haiku) ;;
819 echo The compiler specified as Haiku target compiler is not a \
820 valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
821 echo compiler: $HAIKU_CC
822 echo compiler is configured for target: $targetMachine
823 exit 1 ;;
824 esac
826 HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch"
827 isPrimaryArch=
828 done
831 # Generate BuildConfig
832 cat << EOF > "$buildConfigFile"
833 # BuildConfig
834 # Note: This file has been automatically generated by configure with the
835 # following arguments:
836 # ${configureArgs}
838 TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
839 HOST_PLATFORM ?= "${HOST_PLATFORM}" ;
841 HAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
842 HAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ;
843 HAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ;
844 HAIKU_ENABLE_MULTIUSER ?= "${HAIKU_ENABLE_MULTIUSER}" ;
845 HAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
846 HAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ;
847 HAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ;
848 HAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ;
849 HAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ;
850 HAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ;
852 HAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ;
854 HAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ;
856 HAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
858 HAIKU_NASM ?= ${HAIKU_NASM} ;
859 HAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ;
861 HOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ;
862 HOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ;
863 HOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ;
864 HOST_LD ?= ${HOST_GCC_LD} ;
865 HOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ;
866 HOST_SHA256 ?= ${HOST_SHA256} ;
868 HOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ;
869 HAIKU_PORTS ?= ${HAIKU_PORTS} ;
870 HAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ;
871 HAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ;
875 for targetArch in $HAIKU_PACKAGING_ARCHS; do
876 variables="
877 HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION
878 HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE
879 HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR
880 HAIKU_CPU HAIKU_CPU
881 HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC
882 HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX
883 HAIKU_AR HAIKU_AR
884 HAIKU_CC HAIKU_CC
885 HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG
886 HAIKU_LD HAIKU_LD
887 HAIKU_OBJCOPY HAIKU_OBJCOPY
888 HAIKU_RANLIB HAIKU_RANLIB
889 HAIKU_ELFEDIT HAIKU_ELFEDIT
890 HAIKU_STRIP HAIKU_STRIP
891 HAIKU_CPPFLAGS HAIKU_CPPFLAGS
892 HAIKU_CCFLAGS HAIKU_CCFLAGS
893 HAIKU_C++FLAGS HAIKU_CXXFLAGS
894 HAIKU_LDFLAGS HAIKU_LDFLAGS
895 HAIKU_ARFLAGS HAIKU_ARFLAGS
896 HAIKU_UNARFLAGS HAIKU_UNARFLAGS
897 HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE
899 set -- $variables
900 while [ $# -ge 2 ]; do
901 value=`get_variable ${2}_$targetArch`
902 echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile"
903 shift 2
904 done
906 # For variables that may have long values, distribute them over multiple
907 # lines so that jam doesn't hit the maximum line length.
908 variables="
909 HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR
911 set -- $variables
912 while [ $# -ge 2 ]; do
913 echo "${1}_${targetArch} ?= " >> "$buildConfigFile"
914 get_variable ${2}_$targetArch | xargs -n 1 echo " " \
915 >> "$buildConfigFile"
916 echo " ;" >> "$buildConfigFile"
917 shift 2
918 done
919 done
922 # Generate a boot strap Jamfile in the output directory.
924 cat << EOF > $outputDir/Jamfile
925 # automatically generated Jamfile
927 HAIKU_TOP = ${sourceDir} ;
928 HAIKU_OUTPUT_DIR = ${outputDir} ;
930 include [ FDirName \$(HAIKU_TOP) Jamfile ] ;