ffmpeg: implement deinterlace feature for ffmpeg 3.x.
[haiku.git] / configure
blob31f041c8cbb5264ea936fbf65c78f635fd01baef
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-gpl-addons Include GPL licensed add-ons.
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 disables code that is currently known
65 to be problematic.
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 --update re-runs last configure invocation [must be given
87 as first option!]
88 --use-clang Build with host Clang instead of GCC cross
89 compiler
90 --use-gcc-pipe Build with GCC option -pipe. Speeds up the build
91 process, but uses more memory.
92 --use-gcc-graphite Build with GCC Graphite engine for loop
93 optimizations. Only for gcc 4.
94 --use-32bit Use -m32 flag on 64bit host gcc compiler.
95 --use-xattr Use Linux xattr respectively *BSD extattr support
96 for BeOS attribute emulation. Warning: Make sure
97 your file system supports sufficient attribute
98 sizes (4 KB per file for all attributes won't
99 suffice).
100 --use-xattr-ref Use the generic BeOS attribute emulation, but use
101 Linux xattr respectively *BSD extattr support to
102 make it more robust (i.e. attribute mix-ups become
103 less likely).
104 --with-gdb <gdb sources dir>
105 specify the path to a GDB source dir, to build
106 GDB for each arch we build the cross-tools for.
108 environment variables:
109 CC The host compiler. Defaults to "gcc".
110 HAIKU_AR_x86_gcc2 The static library archiver for x86_gcc2.
111 Defaults to "ar".
112 HAIKU_CC_x86_gcc2 The x86_gcc2 compiler. Defaults to "gcc".
113 HAIKU_LD_x86_gcc2 The x86_gcc2 linker. Defaults to "ld".
114 HAIKU_OBJCOPY_x86_gcc2 The x86_gcc2 objcopy to be used. Defaults to
115 "objcopy".
116 HAIKU_RANLIB_x86_gcc2 The static library indexer for x86_gcc2. Defaults
117 to "ranlib".
118 HAIKU_STRIP_x86_gcc2 The x86_gcc2 strip command. Defaults to "strip".
119 HAIKU_NASM The nasm assembler (x86 and x86_64 only).
120 HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture
121 <arch>. Defaults to "".
122 HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>.
123 Defaults to "".
124 HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>.
125 Defaults to "".
126 HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>.
127 Defaults to "".
128 HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target
129 architecture <arch> for archiving. Defaults to
130 "cru".
131 HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target
132 architecture <arch> for unarchiving. Defaults to
133 "x".
135 Non-default output directories:
136 By default all objects, build configuration, and other related files are
137 stored in /path/to/haiku_source/generated. To store objects in a non-default
138 location, run "../../relative/path/to/haiku_source/configure <options>" from
139 within your non-default location. "jam [ options ] targets" can then be run
140 directly inside your non-default location. Another option is to invoke "jam
141 [ options ] targets" from within haiku_source. This can be accomplished by
142 either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
143 jam or by creating a symlink of haiku_source/generated pointing to your
144 non-default location and running jam.
150 # assertparam
152 # Checks whether at least one parameter is left.
154 assertparam()
156 if [ $2 -lt 2 ]; then
157 echo $0: \`$1\': Parameter expected.
158 exit 1
162 # assertparams
164 # Checks whether at least a certain number of parameters is left.
166 assertparams()
168 if [ $3 -le $2 ]; then
169 echo $0: \`$1\': Not enough parameters.
170 exit 1
174 # absolute_path
176 # returns the absolute path of a given path.
178 absolute_path()
180 if [ "x$1" != "x${1#/}" ]; then
181 echo "$1"
182 else
183 echo "`pwd`/$1"
187 # check_dir_exists
189 # check if a directory exists or not
191 check_dir_exists()
193 if [ -d "$1" ]; then
194 return 0
195 else
196 return 1
200 # check_file_exists
202 # check if a file exists or not
204 check_file_exists()
206 if [ -f "$1" ]; then
207 return 0
208 else
209 return 1
213 # real_path
215 # returns the realpath of a symbolic link.
217 real_path()
219 perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1"
222 # standard_gcc_settings
224 # Sets the variables for a GCC platform.
226 standard_gcc_settings()
228 local gcc=$1
230 if which greadlink > /dev/null 2>&1; then
231 readlink="greadlink -e"
232 elif which realpath > /dev/null 2>&1; then
233 readlink=realpath
234 elif readlink -e / > /dev/null 2>&1; then
235 readlink="readlink -e"
236 else
237 readlink=real_path
240 # PLATFORM_LINKLIBS
241 local gcclib=`$gcc -print-libgcc-file-name`
242 local gccdir=`dirname ${gcclib}`
244 local gccRawVersion=`$gcc -dumpversion`
245 local gccMachine=`$gcc -dumpmachine`
247 # determine architecture from machine triple
248 case $gccMachine in
249 arm-*) targetCpu=arm;;
250 i?86-*) targetCpu=x86;;
251 m68k-*) targetCpu=m68k;;
252 powerpc-*) targetCpu=ppc;;
253 x86_64-*) targetCpu=x86_64;;
255 echo "Unsupported gcc target machine: $gccMachine" >&2
256 exit 1
258 esac
260 local targetArch=$targetCpu
262 case $gccRawVersion in
263 2.9*)
264 # check for correct (most up-to-date) legacy compiler and complain
265 # if an older one is installed
266 if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then
267 echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
268 echo "Please download it from www.haiku-os.org...";
269 exit 1;
272 targetArch=x86_gcc2
274 esac
276 local bootLibgcc
277 local bootLibSupCxx
278 local bootCxxHeaders
279 case $gccMachine in
280 x86_64-*)
281 # Boot loader is 32-bit, need the 32-bit libs and c++ config
282 bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a`
283 bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a`
285 local headersBase=$gccdir/../../../..
286 local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion
287 if [ ! -d $headers ]; then
288 headers=$headersBase/include/c++/$gccRawVersion
290 bootCxxHeaders="$headers/$gccMachine/32"
292 esac
294 # determine whether graphite loop optimization should/can be used
295 local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu`
296 if [ -z "$useGraphite" ]; then
297 useGraphite=$useGccGraphiteDefault
300 if [ "$useGraphite" != 0 ]; then
301 UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1`
302 if [ $? != 0 ]; then
303 echo "GCC Graphite loop optimizations cannot be used on $targetArch"
304 useGraphite=0
308 set_variable HAIKU_CPU_$targetArch $targetCpu
310 get_build_tool_path CC_$targetArch "$gcc"
311 set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang
312 set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion
313 set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine
314 set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir
315 set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders"
316 set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx"
317 set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc
318 set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite
320 standard_gcc_settings_targetArch=$targetArch
323 # set_variable
325 # Set the value of a variable.
327 set_variable()
329 eval "$1=\"$2\""
332 # get_variable
334 # Echo the value of a variable.
336 get_variable()
338 eval "echo \${$1}"
341 # set_default_value
343 # Set the value for a variable, if no value is set yet.
345 set_default_value()
347 eval "$1=\${$1-$2}"
350 # get_build_tool_path
352 # Gets a usable absolute path of a build tool.
354 get_build_tool_path()
356 local var="HAIKU_$1"
357 local cmd=$2
358 local path=${2%% *}
360 if [ -f "$path" ]; then
361 # get absolute path
362 local oldPwd="`pwd`"
363 cd "`dirname "$path"`"
364 path="`pwd`/`basename "$path"`"
365 cd $oldPwd
366 else
367 which "$path" > /dev/null 2>&1 || {
368 echo "Build tool \"$path\" not found." >&2
369 exit 1
373 eval "$var=\"$path ${cmd#${2%% *}}\""
376 is_in_list()
378 local element
379 for element in $2; do
380 if [ "$1" = "$element" ]; then
381 return 0
383 done
384 return 1
387 # check for --help or -h and show usage immediately
388 if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
389 usage; exit 0;
393 # get cwd and the source directory
394 currentDir=`pwd`
395 cd `dirname "$0"`
396 sourceDir=`pwd`
397 cd "$currentDir"
399 # backup the passed arguments
400 configureArgs="$@"
402 # internal default parameter values
404 platform=`uname`
405 platformMachine=`uname -m`
406 targetArchs=
407 buildCrossTools=
408 buildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
409 buildCrossToolsJobs=
410 useClang=0
411 useGccGraphiteDefault=0
412 unknownArchIndex=1
413 haikuTargetArchs=
414 gdbSources=
416 if [ -z "$CC" ]; then
417 CC=gcc
420 # exported (BuildSetup) default parameter values
422 HOST_GCC_RAW_VERSION=`$CC -dumpversion`
423 HOST_GCC_MACHINE=`$CC -dumpmachine`
424 HAIKU_INCLUDE_GPL_ADDONS=0
425 HAIKU_INCLUDE_PATENTED_CODE=0
426 HAIKU_INCLUDE_SOURCES=0
427 HAIKU_INCLUDE_3RDPARTY=0
428 HAIKU_ENABLE_MULTIUSER=0
429 HAIKU_DISTRO_COMPATIBILITY=default
430 TARGET_PLATFORM=haiku
431 HAIKU_USE_GCC_PIPE=0
432 HAIKU_HOST_USE_32BIT=0
433 HAIKU_HOST_USE_XATTR=0
434 HAIKU_HOST_USE_XATTR_REF=0
435 HAIKU_HOST_BUILD_ONLY=0
436 HOST_EXTENDED_REGEX_SED="sed -r"
437 HOST_GCC_LD=`$CC -print-prog-name=ld`
438 HOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy`
439 HOST_SHA256=
440 HOST_HAIKU_PORTER=
441 HAIKU_PORTS=
442 HAIKU_PORTS_CROSS=
443 HAIKU_IS_BOOTSTRAP=0
444 HAIKU_BOOT_BOARD=
445 HAIKU_NO_DOWNLOADS=0
447 HAIKU_PACKAGING_ARCHS=
449 set_default_value HAIKU_NASM nasm
451 if sha256sum < /dev/null > /dev/null 2>&1; then
452 HOST_SHA256=sha256sum
453 elif sha256 < /dev/null > /dev/null 2>&1; then
454 HOST_SHA256="sha256 -q"
455 elif shasum < /dev/null > /dev/null 2>&1; then
456 HOST_SHA256="shasum -a 256"
457 else
458 echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2
459 exit 1
462 haikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20"
463 export haikuRequiredLegacyGCCVersion
464 # version of legacy gcc required to build haiku
465 supportedTargetArchs="
467 m68k
470 x86_64
471 x86_gcc2
474 # determine output directory
475 if [ "$currentDir" = "$sourceDir" ]; then
476 outputDir=$currentDir/generated
477 else
478 outputDir=$currentDir
480 buildOutputDir="$outputDir/build"
481 HAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes"
482 buildConfigFile="$buildOutputDir/BuildConfig"
484 # check for update request
485 if [ "$1" = "--update" ]; then
486 if ! [ -e "$buildConfigFile" ]; then
487 echo $0 --update: \'$buildConfigFile\' not found - updating not possible.
488 exit 1
490 if ! type perl >/dev/null 2>&1; then
491 echo $0 --update: \'perl\' not found - updating not possible.
492 exit 1
494 # convert BuildConfig from jam format to shell format and evaluate it
495 shellConfigFile="${buildConfigFile}.shell"
496 perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
497 <"$buildConfigFile" >"$shellConfigFile"
498 . "$shellConfigFile"
499 rm "$shellConfigFile"
500 shift
503 # parse parameters
505 while [ $# -gt 0 ] ; do
506 case "$1" in
507 --bootstrap)
508 assertparams "$1" 3 $#
509 HOST_HAIKU_PORTER="`absolute_path $2`"
510 HAIKU_PORTS_CROSS="`absolute_path $3`"
511 HAIKU_PORTS="`absolute_path $4`"
512 HAIKU_IS_BOOTSTRAP=1
513 HAIKU_NO_DOWNLOADS=1
514 check_file_exists "$HOST_HAIKU_PORTER" || (
515 echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2
516 exit 1
518 check_dir_exists "$HAIKU_PORTS" || (
519 echo "Non-existent directory $HAIKU_PORTS" >&2
520 exit 1
522 check_dir_exists "$HAIKU_PORTS_CROSS" || (
523 echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2
524 exit 1
526 shift 4
528 --build-cross-tools)
529 if [ -z "$buildCrossTools" ]; then
530 assertparams "$1" 2 $#
531 targetArch=$2
532 buildCrossTools=$3
533 shift 3
534 else
535 assertparam "$1" $#
536 targetArch=$2
537 shift 2
539 case "$targetArch" in
540 x86_gcc2) targetMachine=i586-pc-haiku;;
541 x86) targetMachine=i586-pc-haiku;;
542 x86_64) targetMachine=x86_64-unknown-haiku;;
543 ppc) targetMachine=powerpc-apple-haiku;;
544 m68k) targetMachine=m68k-unknown-haiku;;
545 arm) targetMachine=arm-unknown-haiku;;
547 echo "Unsupported target architecture: $2" >&2
548 exit 1
550 esac
551 set_variable buildCrossToolsMachine_$targetArch $targetMachine
552 targetArchs="$targetArchs $targetArch"
553 HAIKU_PACKAGING_ARCHS=
555 --cross-tools-prefix)
556 assertparam "$1" $#
557 targetArch=unknown${unknownArchIndex}
558 set_variable crossToolsPrefix_$targetArch "$2"
559 targetArchs="$targetArchs $targetArch"
560 HAIKU_PACKAGING_ARCHS=
561 unknownArchIndex=$(($unknownArchIndex + 1))
562 shift 2
564 --distro-compatibility)
565 assertparam "$1" $#
566 HAIKU_DISTRO_COMPATIBILITY=$2
567 case "$HAIKU_DISTRO_COMPATIBILITY" in
568 official) ;;
569 compatible) ;;
570 default) ;;
571 *) echo "Invalid distro compatibility" \
572 "level: $HAIKU_DISTRO_COMPATIBILITY"
573 exit 1;;
574 esac
575 shift 2
577 --enable-multiuser) HAIKU_ENABLE_MULTIUSER=1; shift 1;;
578 --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;;
579 --include-gpl-addons) HAIKU_INCLUDE_GPL_ADDONS=1; shift 1;;
580 --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;;
581 --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;;
582 --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;;
583 -j*) buildCrossToolsJobs="$1"; shift 1;;
584 --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;;
585 --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;;
586 --target-arch)
587 assertparam "$1" $#
588 targetArch=$2
589 shift 2
590 if [ ! "$platform" = Haiku ]; then
591 echo "--target-arch can only be specified on Haiku." >&2
592 exit 1
594 is_in_list "$targetArch" "$supportedTargetArchs" || (
595 echo "Unsupported target architecture: \"$targetArch\"" >&2
596 exit 1
598 haikuTargetArchs="$haikuTargetArchs $targetArch"
600 --use-clang) useClang=1; shift 1;;
601 --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;;
602 --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;;
603 --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;;
604 --use-xattr) HAIKU_HOST_USE_XATTR=1; shift 1;;
605 --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF=1; shift 1;;
606 --with-gdb) gdbSources=$2; shift 2;;
607 *) echo Invalid argument: \`$1\'; exit 1;;
608 esac
609 done
611 # detect the build platform
612 case "${platform}" in
613 Darwin) HOST_PLATFORM=darwin ;;
614 FreeBSD) HOST_PLATFORM=freebsd
615 if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then
616 echo Unsupported platform: FreeBSD ${platformMachine}
617 exit 1
618 fi ;;
619 Haiku) HOST_PLATFORM=haiku_host ;;
620 Linux) HOST_PLATFORM=linux ;;
621 OpenBSD) HOST_PLATFORM=openbsd ;;
622 SunOS) HOST_PLATFORM=sunos ;;
623 CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
624 *) echo Unsupported platform: ${platform}
625 exit 1 ;;
626 esac
628 # check for case-sensitive filesystem
629 mkdir haikuCaseTest 2>/dev/null
630 mkdir haikucasetest 2>/dev/null
631 caseInsensitive=$?
632 rmdir haikuCaseTest haikucasetest 2>/dev/null
633 if [ $caseInsensitive != 0 ]; then
634 echo "You need a case-sensitive file-system to build Haiku."
635 if [ $HOST_PLATFORM = "darwin" ]; then
636 echo "You can create a case-sensitive disk image using Disk Utility."
638 exit 1
641 # determine how to invoke sed with extended regexp support for non-GNU sed
642 if [ $HOST_PLATFORM = "darwin" ]; then
643 HOST_EXTENDED_REGEX_SED="sed -E"
646 # check if nasm can actually output ELF files
647 # (the stock version in OSX can't)
648 # XXX: should probably only test for x86* arch
649 if [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then
650 echo "$HAIKU_NASM cannot generate ELF files. Please install a working version."
651 if [ $HOST_PLATFORM = "darwin" ]; then
652 echo "You can install it from Mac Ports."
653 echo "Mac Ports is available at: http://www.macports.org/"
655 exit 1
658 # create output directory
659 mkdir -p "$buildOutputDir" || exit 1
661 if [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
662 invalidCommand=$sourceDir/build/scripts/host_build_only
663 HAIKU_AR=$invalidCommand
664 HAIKU_CC=$invalidCommand
665 HAIKU_LD=$invalidCommand
666 HAIKU_OBJCOPY=$invalidCommand
667 HAIKU_RANLIB=$invalidCommand
668 HAIKU_ELFEDIT=$invalidCommand
669 HAIKU_NASM=$invalidCommand
670 HAIKU_STRIP=$invalidCommand
671 else
672 if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then
673 targetArchs="$HAIKU_PACKAGING_ARCHS"
675 HAIKU_PACKAGING_ARCHS=
677 # On Haiku determine target architectures and tools automatically.
678 if [ -z "$targetArchs" ]; then
679 if [ $HOST_PLATFORM != haiku_host ]; then
680 echo "Please specify the build tools to use or build (via" \
681 "--cross-tools-prefix or --build-cross-tools) or specify a" \
682 "host-only build (--host-only)." >&2
683 echo "For more info, invoke $0 --help"
684 exit 1
687 # determine primary architecture
688 targetArch=`package list -i /system/packages/haiku-*.hpkg \
689 | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'`
690 is_in_list "$targetArch" "$supportedTargetArchs" || (
691 echo "Unsupported target architecture: \"$targetArch\"" >&2
692 exit 1
694 targetArchs=$targetArch
696 set_default_value HAIKU_AR_$targetArch ar
697 set_default_value HAIKU_CC_$targetArch gcc
698 set_default_value HAIKU_LD_$targetArch ld
699 set_default_value HAIKU_OBJCOPY_$targetArch objcopy
700 set_default_value HAIKU_RANLIB_$targetArch ranlib
701 set_default_value HAIKU_ELFEDIT_$targetArch elfedit
702 set_default_value HAIKU_STRIP_$targetArch strip
704 # determine secondary architectures
705 for targetArch in $supportedTargetArchs; do
706 if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then
707 targetArchs="$targetArchs $targetArch"
708 set_default_value HAIKU_AR_$targetArch ar-$targetArch
709 set_default_value HAIKU_CC_$targetArch gcc-$targetArch
710 set_default_value HAIKU_LD_$targetArch ld-$targetArch
711 set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch
712 set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch
713 set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch
714 set_default_value HAIKU_STRIP_$targetArch strip-$targetArch
716 done
718 # The target architectures might have been specified explicitly.
719 if [ -n "$haikuTargetArchs" ]; then
720 for targetArch in $haikuTargetArchs; do
721 is_in_list "$targetArch" "$targetArchs" || (
722 echo "Unsupported target architecture: \"$targetArch\"." \
723 "Only native architectures of the host platform can" \
724 "be specified." >&2
725 exit 1
727 done
728 targetArchs="$haikuTargetArchs"
732 isPrimaryArch=1
733 for targetArch in $targetArchs; do
734 # Note: targetArch is "unknown<n>" at this point, if a cross-tools
735 # prefix was specified. The standard_gcc_settings call below will get
736 # the actual architecture.
738 crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch`
740 # build cross tools from sources
741 if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then
742 crossToolsDir="$outputDir/cross-tools-$targetArch"
743 targetMachine=`get_variable buildCrossToolsMachine_$targetArch`
744 script="$buildCrossToolsScript"
745 scriptArgs=
746 if [ $targetArch != x86_gcc2 ]; then
747 script="${script}_gcc4"
748 scriptArgs="$targetMachine"
749 set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \
750 $useGccGraphiteDefault
752 secondaryArch=
753 if [ -z "$isPrimaryArch" ]; then
754 secondaryArch=$targetArch
757 case $HOST_PLATFORM in
758 freebsd|openbsd) MAKE=gmake;;
759 *) MAKE=make;;
760 esac
762 MAKE=$MAKE \
763 SECONDARY_ARCH=$secondaryArch \
764 HAIKU_USE_GCC_GRAPHITE=`get_variable \
765 HAIKU_USE_GCC_GRAPHITE_$targetArch` \
766 HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
767 HAIKU_USE_GDB="$gdbSources" \
768 "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
769 "$crossToolsDir" $buildCrossToolsJobs || exit 1
770 crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
773 # prepare gcc settings and get the actual target architecture
774 if [ $useClang = 1 ]; then
775 target=${crossToolsPrefix##*/}
776 target=${target%-}
777 gcc="clang -target ${target} -no-integrated-as"
778 else
779 gcc="${crossToolsPrefix}gcc"
781 if [ -z "${crossToolsPrefix}" ]; then
782 gcc=`get_variable HAIKU_CC_$targetArch`
784 standard_gcc_settings "$gcc"
785 targetArch=$standard_gcc_settings_targetArch
787 # set default values for flags
788 set_default_value HAIKU_CPPFLAGS_$targetArch ""
789 set_default_value HAIKU_CCFLAGS_$targetArch ""
790 set_default_value HAIKU_CXXFLAGS_$targetArch ""
791 set_default_value HAIKU_LDFLAGS_$targetArch ""
792 set_default_value HAIKU_ARFLAGS_$targetArch cru
793 set_default_value HAIKU_UNARFLAGS_$targetArch x
795 # Override the cross tools variables, if the tools were built or a
796 # prefix was specified.
797 if [ -n "$crossToolsPrefix" ]; then
798 get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar
799 get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld
800 get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy
801 get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib
802 get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip
804 case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in
805 4.*|5.*|6.*|7.*|8.*)
806 get_build_tool_path ELFEDIT_$targetArch \
807 ${crossToolsPrefix}elfedit
809 esac
812 # check whether the Haiku compiler really targets Haiku
813 targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch`
814 case "$targetMachine" in
815 *-*-haiku) ;;
817 echo The compiler specified as Haiku target compiler is not a \
818 valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
819 echo compiler: $HAIKU_CC
820 echo compiler is configured for target: $targetMachine
821 exit 1 ;;
822 esac
824 HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch"
825 isPrimaryArch=
826 done
829 # Generate BuildConfig
830 cat << EOF > "$buildConfigFile"
831 # BuildConfig
832 # Note: This file has been automatically generated by configure with the
833 # following arguments:
834 # ${configureArgs}
836 TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
837 HOST_PLATFORM ?= "${HOST_PLATFORM}" ;
839 HAIKU_INCLUDE_GPL_ADDONS ?= "${HAIKU_INCLUDE_GPL_ADDONS}" ;
840 HAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
841 HAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ;
842 HAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ;
843 HAIKU_ENABLE_MULTIUSER ?= "${HAIKU_ENABLE_MULTIUSER}" ;
844 HAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
845 HAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ;
846 HAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ;
847 HAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ;
848 HAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ;
849 HAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ;
851 HAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ;
853 HAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ;
855 HAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
857 HAIKU_NASM ?= ${HAIKU_NASM} ;
858 HAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ;
860 HOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ;
861 HOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ;
862 HOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ;
863 HOST_LD ?= ${HOST_GCC_LD} ;
864 HOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ;
865 HOST_SHA256 ?= ${HOST_SHA256} ;
867 HOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ;
868 HAIKU_PORTS ?= ${HAIKU_PORTS} ;
869 HAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ;
870 HAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ;
874 for targetArch in $HAIKU_PACKAGING_ARCHS; do
875 variables="
876 HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION
877 HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE
878 HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR
879 HAIKU_CPU HAIKU_CPU
880 HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC
881 HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX
882 HAIKU_AR HAIKU_AR
883 HAIKU_CC HAIKU_CC
884 HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG
885 HAIKU_LD HAIKU_LD
886 HAIKU_OBJCOPY HAIKU_OBJCOPY
887 HAIKU_RANLIB HAIKU_RANLIB
888 HAIKU_ELFEDIT HAIKU_ELFEDIT
889 HAIKU_STRIP HAIKU_STRIP
890 HAIKU_CPPFLAGS HAIKU_CPPFLAGS
891 HAIKU_CCFLAGS HAIKU_CCFLAGS
892 HAIKU_C++FLAGS HAIKU_CXXFLAGS
893 HAIKU_LDFLAGS HAIKU_LDFLAGS
894 HAIKU_ARFLAGS HAIKU_ARFLAGS
895 HAIKU_UNARFLAGS HAIKU_UNARFLAGS
896 HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE
898 set -- $variables
899 while [ $# -ge 2 ]; do
900 value=`get_variable ${2}_$targetArch`
901 echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile"
902 shift 2
903 done
905 # For variables that may have long values, distribute them over multiple
906 # lines so that jam doesn't hit the maximum line length.
907 variables="
908 HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR
910 set -- $variables
911 while [ $# -ge 2 ]; do
912 echo "${1}_${targetArch} ?= " >> "$buildConfigFile"
913 get_variable ${2}_$targetArch | xargs -n 1 echo " " \
914 >> "$buildConfigFile"
915 echo " ;" >> "$buildConfigFile"
916 shift 2
917 done
918 done
921 # Generate a boot strap Jamfile in the output directory.
923 cat << EOF > $outputDir/Jamfile
924 # automatically generated Jamfile
926 HAIKU_TOP = ${sourceDir} ;
927 HAIKU_OUTPUT_DIR = ${outputDir} ;
929 include [ FDirName \$(HAIKU_TOP) Jamfile ] ;