152a38012Sejakowatz#!/bin/sh 252a38012Sejakowatz# 3338b8dc3SIngo Weinhold# configure [ <options> ] 4614026d7Sshatty 5022fa244SIngo Weinhold# usage 6022fa244SIngo Weinhold# 7022fa244SIngo Weinhold# Prints usage. 8022fa244SIngo Weinhold# 9022fa244SIngo Weinholdusage() 10022fa244SIngo Weinhold{ 11022fa244SIngo Weinhold cat << EOF 12022fa244SIngo Weinhold 13022fa244SIngo WeinholdUsage: $0 <options> 14022fa244SIngo Weinholdoptions: 15825700d3SAugustin Cavalier --help Prints out this help. 16825700d3SAugustin Cavalier --update Re-runs last configure invocation [must be given 17825700d3SAugustin Cavalier as first option!] 18e173a1ecSIngo Weinhold --bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo> 19e173a1ecSIngo Weinhold Prepare for a bootstrap build. No pre-built 20e173a1ecSIngo Weinhold packages will be used, instead they will be built 21e173a1ecSIngo Weinhold from the sources (in several phases). 22e173a1ecSIngo Weinhold <haikuporter> is the path to the haikuporter tool 23e173a1ecSIngo Weinhold suitable for the host platform. 24e173a1ecSIngo Weinhold <HaikuPorts cross repo> is the path to a checked 25e173a1ecSIngo Weinhold out HaikuPorts cross-compilation repository. 26e173a1ecSIngo Weinhold <HaikuPorts repo> is the path to a checked out 27e173a1ecSIngo Weinhold HaikuPorts repository. 28c0e8cc1aSIngo Weinhold --build-cross-tools <arch> [ <build tools dir> ] 29338b8dc3SIngo Weinhold Assume cross compilation. <build tools dir> 30338b8dc3SIngo Weinhold defines the location of the build tools sources. 31338b8dc3SIngo Weinhold They will be compiled and placed in the output 32a5b60fa8SOliver Tappe directory under "cross-tools". The HAIKU_* tools 33a5b60fa8SOliver Tappe variables will be set accordingly. 3420ab75e6SIngo Weinhold <arch> specifies the target architecture, either 351b38c341SAlexander von Gluck IV "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm" 36c0e8cc1aSIngo Weinhold This option and --cross-tools-prefix can be 37c0e8cc1aSIngo Weinhold specified multiple times. The first cross tools 38c0e8cc1aSIngo Weinhold specify the primary tools, the subsequent ones the 39c0e8cc1aSIngo Weinhold secondary tools (for "hybrid" images). 40c0e8cc1aSIngo Weinhold For the first --build-cross-tools the 41c0e8cc1aSIngo Weinhold <build tools dir> argument must be specified and 42c0e8cc1aSIngo Weinhold for the subsequent ones it must be omitted. 43eccc7665SIngo Weinhold --cross-tools-prefix <prefix> 44eccc7665SIngo Weinhold Assume cross compilation. <prefix> should be a 45eccc7665SIngo Weinhold path to the directory where the cross 46eccc7665SIngo Weinhold compilation tools are located, plus the platform 470da9c208SIngo Weinhold prefix, e.g. "/path/to/tools/i586-pc-haiku-". 48eccc7665SIngo Weinhold This overrides the HAIKU_* tool variables. 49a66c32ddSIngo Weinhold --distro-compatibility <level> 50a66c32ddSIngo Weinhold The distribution's level of compatibility with 51a66c32ddSIngo Weinhold the official Haiku distribution. The generated 52a66c32ddSIngo Weinhold files will contain the respective trademarks 53a66c32ddSIngo Weinhold accordingly. 54a66c32ddSIngo Weinhold official -- the official Haiku distribution. 55a66c32ddSIngo Weinhold compatible -- a Haiku Compatible (tm) distro. 56a66c32ddSIngo Weinhold default -- any other distro (default value). 572ebcd86dSIngo Weinhold --host-only Configure for building tools for the build host 582ebcd86dSIngo Weinhold only. Haiku cannot be built when configured like 592ebcd86dSIngo Weinhold this. 6067838392SAxel Dörfler --include-patented-code Enable code that is known to implemented patented 6167838392SAxel Dörfler ideas and techniques. If this option is not 6267838392SAxel Dörfler specified, the resulting distribution may still 6367838392SAxel Dörfler implement patented ideas and techniques. This 64825700d3SAugustin Cavalier option only enables code that is currently known 6567838392SAxel Dörfler to be problematic. 6676fa0be3SIngo Weinhold --include-sources Includes the source code of projects that require 6776fa0be3SIngo Weinhold either an offer of source code or a copy of the 6876fa0be3SIngo Weinhold patched sources. This is preferable when 6976fa0be3SIngo Weinhold distributing on physical mediums. 701974210fSFrançois Revol --include-3rdparty Include 3rdparty/ in the build system. 714880ae01SJessica Hamilton -j<n> Only relevant for --build-cross-tools. Is passed 724880ae01SJessica Hamilton on to the make building the build tools. 73aa2e5ecaSOliver Tappe --no-downloads Do not download anything. Useful when trying to 74aa2e5ecaSOliver Tappe bootstrap and build Haiku from source only. 757c4641d0SOliver Tappe --target=TARGET Select build target platform. 767c4641d0SOliver Tappe [default=${TARGET_PLATFORM}] 77deb1a319SAlexander von Gluck IV valid targets=r5,bone,dano,haiku 78483b28e4SIngo Weinhold --target-arch <arch> Haiku only: Specify the target architecture to 79483b28e4SIngo Weinhold build for. Must be one of the architectures of the 80483b28e4SIngo Weinhold host system. The installed build tools for that 81483b28e4SIngo Weinhold architecture will be used. 82483b28e4SIngo Weinhold This option can be specified multiple times. The 83483b28e4SIngo Weinhold first occurrence specifies the primary 84483b28e4SIngo Weinhold architecture of the Haiku to build, subsequent 85483b28e4SIngo Weinhold ones the secondary architectures. 86d73993ffSAugustin Cavalier --use-clang <arch> Build with host Clang instead of GCC cross 87d73993ffSAugustin Cavalier compiler, targeting <arch> 88eccc7665SIngo Weinhold --use-gcc-pipe Build with GCC option -pipe. Speeds up the build 895a34a443SFrançois Revol process, but uses more memory. 90ed38d2efSJerome Duval --use-gcc-graphite Build with GCC Graphite engine for loop 91a5c952dbSAugustin Cavalier optimizations. (Only for GCC 4+.) 920385b065SIngo Weinhold --use-32bit Use -m32 flag on 64bit host gcc compiler. 93fc2c93fbSAugustin Cavalier --no-full-xattr Do not use Linux/*BSD/Darwin's native extended file 94fc2c93fbSAugustin Cavalier attributes as Haiku attributes. If they are still 95fc2c93fbSAugustin Cavalier available, they will be used to store hashes for 96fc2c93fbSAugustin Cavalier the attribute emulation layer. 97fc2c93fbSAugustin Cavalier --no-xattr Do not use Linux/*BSD/Darwin's native extended file 98fc2c93fbSAugustin Cavalier attributes for Haiku extended attributes at all, 99fc2c93fbSAugustin Cavalier even if they are available. 1004da6cf84SFrançois Revol --with-gdb <gdb sources dir> 1014da6cf84SFrançois Revol specify the path to a GDB source dir, to build 1024da6cf84SFrançois Revol GDB for each arch we build the cross-tools for. 103338b8dc3SIngo Weinhold 104338b8dc3SIngo Weinholdenvironment variables: 10563701e7dSOliver Tappe CC The host compiler. Defaults to "gcc". 10665706842SAugustin Cavalier HAIKU_AR_<arch> The static library archiver for <arch>. 107c0e8cc1aSIngo Weinhold Defaults to "ar". 10865706842SAugustin Cavalier HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc". 10965706842SAugustin Cavalier HAIKU_LD_<arch> The <arch> linker. Defaults to "ld". 11065706842SAugustin Cavalier HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to 111c0e8cc1aSIngo Weinhold "objcopy". 11265706842SAugustin Cavalier HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults 113c0e8cc1aSIngo Weinhold to "ranlib". 11465706842SAugustin Cavalier HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip". 115a04a520bSJonathan Schleifer HAIKU_NASM The nasm assembler (x86 and x86_64 only). 116c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture 117c0e8cc1aSIngo Weinhold <arch>. Defaults to "". 118c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>. 119c0e8cc1aSIngo Weinhold Defaults to "". 120c0e8cc1aSIngo Weinhold HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>. 121c0e8cc1aSIngo Weinhold Defaults to "". 122c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>. 123c0e8cc1aSIngo Weinhold Defaults to "". 124c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target 125c0e8cc1aSIngo Weinhold architecture <arch> for archiving. Defaults to 126c0e8cc1aSIngo Weinhold "cru". 127c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target 128c0e8cc1aSIngo Weinhold architecture <arch> for unarchiving. Defaults to 129c0e8cc1aSIngo Weinhold "x". 13064f6da31SIngo Weinhold 131c0e8cc1aSIngo WeinholdNon-default output directories: 13264f6da31SIngo Weinhold By default all objects, build configuration, and other related files are 13364f6da31SIngo Weinhold stored in /path/to/haiku_source/generated. To store objects in a non-default 13464f6da31SIngo Weinhold location, run "../../relative/path/to/haiku_source/configure <options>" from 13564f6da31SIngo Weinhold within your non-default location. "jam [ options ] targets" can then be run 13664f6da31SIngo Weinhold directly inside your non-default location. Another option is to invoke "jam 13764f6da31SIngo Weinhold [ options ] targets" from within haiku_source. This can be accomplished by 13864f6da31SIngo Weinhold either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking 13964f6da31SIngo Weinhold jam or by creating a symlink of haiku_source/generated pointing to your 14064f6da31SIngo Weinhold non-default location and running jam. 14164f6da31SIngo Weinhold 14264f6da31SIngo Weinhold 143022fa244SIngo WeinholdEOF 144022fa244SIngo Weinhold} 145022fa244SIngo Weinhold 146022fa244SIngo Weinhold# assertparam 147022fa244SIngo Weinhold# 148022fa244SIngo Weinhold# Checks whether at least one parameter is left. 149022fa244SIngo Weinhold# 150022fa244SIngo Weinholdassertparam() 151022fa244SIngo Weinhold{ 15220ab75e6SIngo Weinhold if [ $2 -lt 2 ]; then 153022fa244SIngo Weinhold echo $0: \`$1\': Parameter expected. 154022fa244SIngo Weinhold exit 1 155022fa244SIngo Weinhold fi 156022fa244SIngo Weinhold} 157022fa244SIngo Weinhold 15820ab75e6SIngo Weinhold# assertparams 15920ab75e6SIngo Weinhold# 16020ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left. 16120ab75e6SIngo Weinhold# 16220ab75e6SIngo Weinholdassertparams() 16320ab75e6SIngo Weinhold{ 16420ab75e6SIngo Weinhold if [ $3 -le $2 ]; then 16520ab75e6SIngo Weinhold echo $0: \`$1\': Not enough parameters. 16620ab75e6SIngo Weinhold exit 1 16720ab75e6SIngo Weinhold fi 16820ab75e6SIngo Weinhold} 16920ab75e6SIngo Weinhold 170e173a1ecSIngo Weinhold# absolute_path 171e173a1ecSIngo Weinhold# 172e173a1ecSIngo Weinhold# returns the absolute path of a given path. 173e173a1ecSIngo Weinhold# 174e173a1ecSIngo Weinholdabsolute_path() 175e173a1ecSIngo Weinhold{ 1766a4f3954SFrançois Revol if [ "x$1" != "x${1#/}" ]; then 177e173a1ecSIngo Weinhold echo "$1" 178e173a1ecSIngo Weinhold else 179e173a1ecSIngo Weinhold echo "`pwd`/$1" 180e173a1ecSIngo Weinhold fi 181e173a1ecSIngo Weinhold} 182e173a1ecSIngo Weinhold 18339d444a3SArvind S Raj# check_dir_exists 18439d444a3SArvind S Raj# 18539d444a3SArvind S Raj# check if a directory exists or not 18639d444a3SArvind S Raj# 18739d444a3SArvind S Rajcheck_dir_exists() 18839d444a3SArvind S Raj{ 18939d444a3SArvind S Raj if [ -d "$1" ]; then 19039d444a3SArvind S Raj return 0 19139d444a3SArvind S Raj else 19239d444a3SArvind S Raj return 1 19339d444a3SArvind S Raj fi 19439d444a3SArvind S Raj} 19539d444a3SArvind S Raj 196502882dbSJessica Hamilton# check_file_exists 197502882dbSJessica Hamilton# 198502882dbSJessica Hamilton# check if a file exists or not 199502882dbSJessica Hamilton# 200502882dbSJessica Hamiltoncheck_file_exists() 201502882dbSJessica Hamilton{ 202502882dbSJessica Hamilton if [ -f "$1" ]; then 203502882dbSJessica Hamilton return 0 204502882dbSJessica Hamilton else 205502882dbSJessica Hamilton return 1 206502882dbSJessica Hamilton fi 207502882dbSJessica Hamilton} 208502882dbSJessica Hamilton 2099a001156SOliver Tappe# real_path 2109a001156SOliver Tappe# 2119a001156SOliver Tappe# returns the realpath of a symbolic link. 2129a001156SOliver Tappe# 2139a001156SOliver Tappereal_path() 2149a001156SOliver Tappe{ 2159a001156SOliver Tappe perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1" 2169a001156SOliver Tappe} 2179a001156SOliver Tappe 21809c5682dSIngo Weinhold# standard_gcc_settings 21909c5682dSIngo Weinhold# 22009c5682dSIngo Weinhold# Sets the variables for a GCC platform. 22109c5682dSIngo Weinhold# 22209c5682dSIngo Weinholdstandard_gcc_settings() 22309c5682dSIngo Weinhold{ 22465706842SAugustin Cavalier local gcc="$1" 225c0e8cc1aSIngo Weinhold 226138f5fb4SIngo Weinhold if which greadlink > /dev/null 2>&1; then 227b29b48b1SMatt Madia readlink="greadlink -e" 228138f5fb4SIngo Weinhold elif which realpath > /dev/null 2>&1; then 229b29b48b1SMatt Madia readlink=realpath 2309a001156SOliver Tappe elif readlink -e / > /dev/null 2>&1; then 231b29b48b1SMatt Madia readlink="readlink -e" 2329a001156SOliver Tappe else 2339a001156SOliver Tappe readlink=real_path 234b4b6d83cSMatt Madia fi 235138f5fb4SIngo Weinhold 23609c5682dSIngo Weinhold # PLATFORM_LINKLIBS 237c0e8cc1aSIngo Weinhold local gcclib=`$gcc -print-libgcc-file-name` 238c0e8cc1aSIngo Weinhold local gccdir=`dirname ${gcclib}` 2395b0f7b1bSOliver Tappe 240c0e8cc1aSIngo Weinhold local gccRawVersion=`$gcc -dumpversion` 241c0e8cc1aSIngo Weinhold local gccMachine=`$gcc -dumpmachine` 242338b8dc3SIngo Weinhold 243fc8967f1SIngo Weinhold # determine architecture from machine triple 244c0e8cc1aSIngo Weinhold case $gccMachine in 245c0e8cc1aSIngo Weinhold arm-*) targetCpu=arm;; 246c0e8cc1aSIngo Weinhold i?86-*) targetCpu=x86;; 247c0e8cc1aSIngo Weinhold m68k-*) targetCpu=m68k;; 248c0e8cc1aSIngo Weinhold powerpc-*) targetCpu=ppc;; 249c0e8cc1aSIngo Weinhold x86_64-*) targetCpu=x86_64;; 250fc8967f1SIngo Weinhold *) 251c0e8cc1aSIngo Weinhold echo "Unsupported gcc target machine: $gccMachine" >&2 252fc8967f1SIngo Weinhold exit 1 253fc8967f1SIngo Weinhold ;; 254fc8967f1SIngo Weinhold esac 255fc8967f1SIngo Weinhold 256c0e8cc1aSIngo Weinhold local targetArch=$targetCpu 257fc8967f1SIngo Weinhold 258c0e8cc1aSIngo Weinhold case $gccRawVersion in 2596cc8eecfSOliver Tappe 2.9*) 2605b0f7b1bSOliver Tappe # check for correct (most up-to-date) legacy compiler and complain 2615b0f7b1bSOliver Tappe # if an older one is installed 262c0e8cc1aSIngo Weinhold if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then 2635b0f7b1bSOliver Tappe echo "GCC version $haikuRequiredLegacyGCCVersion is required!"; 2645b0f7b1bSOliver Tappe echo "Please download it from www.haiku-os.org..."; 2655b0f7b1bSOliver Tappe exit 1; 2665b0f7b1bSOliver Tappe fi 267aaeadfcbSAlex Smith 268c0e8cc1aSIngo Weinhold targetArch=x86_gcc2 2695b0f7b1bSOliver Tappe ;; 2708b5934c9SIngo Weinhold esac 27165ad1ba3SAlex Smith 272c0e8cc1aSIngo Weinhold local bootLibgcc 273c0e8cc1aSIngo Weinhold local bootLibSupCxx 27466a7f29fSJérôme Duval local bootCxxHeaders 275c0e8cc1aSIngo Weinhold case $gccMachine in 2764591ebc9SAlex Smith x86_64-*) 27766a7f29fSJérôme Duval # Boot loader is 32-bit, need the 32-bit libs and c++ config 27811ae3c5fSOliver Tappe bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` 279c0e8cc1aSIngo Weinhold bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` 28066a7f29fSJérôme Duval 28166a7f29fSJérôme Duval local headersBase=$gccdir/../../../.. 28266a7f29fSJérôme Duval local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion 28366a7f29fSJérôme Duval if [ ! -d $headers ]; then 28466a7f29fSJérôme Duval headers=$headersBase/include/c++/$gccRawVersion 28566a7f29fSJérôme Duval fi 28666a7f29fSJérôme Duval bootCxxHeaders="$headers/$gccMachine/32" 2874591ebc9SAlex Smith ;; 288338b8dc3SIngo Weinhold esac 289c0e8cc1aSIngo Weinhold 290c0e8cc1aSIngo Weinhold # determine whether graphite loop optimization should/can be used 291c0e8cc1aSIngo Weinhold local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu` 292c0e8cc1aSIngo Weinhold if [ -z "$useGraphite" ]; then 293c0e8cc1aSIngo Weinhold useGraphite=$useGccGraphiteDefault 294c0e8cc1aSIngo Weinhold fi 295c0e8cc1aSIngo Weinhold 296c0e8cc1aSIngo Weinhold if [ "$useGraphite" != 0 ]; then 297c0e8cc1aSIngo Weinhold UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1` 298c0e8cc1aSIngo Weinhold if [ $? != 0 ]; then 299c0e8cc1aSIngo Weinhold echo "GCC Graphite loop optimizations cannot be used on $targetArch" 300c0e8cc1aSIngo Weinhold useGraphite=0 301c0e8cc1aSIngo Weinhold fi 302c0e8cc1aSIngo Weinhold fi 303c0e8cc1aSIngo Weinhold 304c0e8cc1aSIngo Weinhold set_variable HAIKU_CPU_$targetArch $targetCpu 305c0e8cc1aSIngo Weinhold 306c0e8cc1aSIngo Weinhold get_build_tool_path CC_$targetArch "$gcc" 307a7bddff1SJonathan Schleifer set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang 308c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion 309c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine 310c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir 31166a7f29fSJérôme Duval set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" 31211ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" 31311ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc 314c0e8cc1aSIngo Weinhold set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite 315c0e8cc1aSIngo Weinhold 316c0e8cc1aSIngo Weinhold standard_gcc_settings_targetArch=$targetArch 317c0e8cc1aSIngo Weinhold} 318c0e8cc1aSIngo Weinhold 319c0e8cc1aSIngo Weinhold# set_variable 320c0e8cc1aSIngo Weinhold# 321c0e8cc1aSIngo Weinhold# Set the value of a variable. 322c0e8cc1aSIngo Weinhold# 323c0e8cc1aSIngo Weinholdset_variable() 324c0e8cc1aSIngo Weinhold{ 325c0e8cc1aSIngo Weinhold eval "$1=\"$2\"" 326c0e8cc1aSIngo Weinhold} 327c0e8cc1aSIngo Weinhold 328c0e8cc1aSIngo Weinhold# get_variable 329c0e8cc1aSIngo Weinhold# 330c0e8cc1aSIngo Weinhold# Echo the value of a variable. 331c0e8cc1aSIngo Weinhold# 332c0e8cc1aSIngo Weinholdget_variable() 333c0e8cc1aSIngo Weinhold{ 334c0e8cc1aSIngo Weinhold eval "echo \${$1}" 33509c5682dSIngo Weinhold} 33609c5682dSIngo Weinhold 337338b8dc3SIngo Weinhold# set_default_value 338338b8dc3SIngo Weinhold# 339338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 340338b8dc3SIngo Weinhold# 341338b8dc3SIngo Weinholdset_default_value() 342338b8dc3SIngo Weinhold{ 3430838a930SJérôme Duval eval "$1=\${$1-$2}" 344338b8dc3SIngo Weinhold} 345338b8dc3SIngo Weinhold 346338b8dc3SIngo Weinhold# get_build_tool_path 347338b8dc3SIngo Weinhold# 348338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 349338b8dc3SIngo Weinhold# 350338b8dc3SIngo Weinholdget_build_tool_path() 351338b8dc3SIngo Weinhold{ 352338b8dc3SIngo Weinhold local var="HAIKU_$1" 35365706842SAugustin Cavalier local varval="`get_variable $var`" 35465706842SAugustin Cavalier local cmd="$2" 355d73993ffSAugustin Cavalier 356e042a53bSAugustin Cavalier if [ ! -z "$varval" ]; then 357d73993ffSAugustin Cavalier # this variable is already set (probably by user) so grab its contents 358e042a53bSAugustin Cavalier cmd=$varval 359d73993ffSAugustin Cavalier fi 360d73993ffSAugustin Cavalier 361d73993ffSAugustin Cavalier local path=${cmd%% *} 362338b8dc3SIngo Weinhold 363338b8dc3SIngo Weinhold if [ -f "$path" ]; then 36465706842SAugustin Cavalier # get absolute path from relative path 365a559f87aSFrançois Revol local oldPwd="`pwd`" 366a559f87aSFrançois Revol cd "`dirname "$path"`" 367a559f87aSFrançois Revol path="`pwd`/`basename "$path"`" 368338b8dc3SIngo Weinhold cd $oldPwd 369338b8dc3SIngo Weinhold else 3707fe2e06cSMatt Madia which "$path" > /dev/null 2>&1 || { 371d73993ffSAugustin Cavalier echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2 372338b8dc3SIngo Weinhold exit 1 373338b8dc3SIngo Weinhold } 374338b8dc3SIngo Weinhold fi 375338b8dc3SIngo Weinhold 37665706842SAugustin Cavalier if test "${cmd#* }" != "$cmd"; then 37765706842SAugustin Cavalier # $cmd contains arguments, so preserve them (and only them) 37865706842SAugustin Cavalier cmd=${cmd#* } 37965706842SAugustin Cavalier else 38065706842SAugustin Cavalier # $cmd does not contain arguments, so unset it 38165706842SAugustin Cavalier cmd= 38265706842SAugustin Cavalier fi 38365706842SAugustin Cavalier eval "$var=\"$path $cmd\"" 384338b8dc3SIngo Weinhold} 385338b8dc3SIngo Weinhold 386a5c952dbSAugustin Cavalier# check_native_xattrs 387a5c952dbSAugustin Cavalier# 388a5c952dbSAugustin Cavalier# Checks the host platform's support for extended attributes. 389a5c952dbSAugustin Cavalier# 0: no support, 1: only enough for xattr-ref, 2: full support 390a5c952dbSAugustin Cavalier# 391a5c952dbSAugustin Cavaliercheck_native_xattrs() 392a5c952dbSAugustin Cavalier{ 393a5c952dbSAugustin Cavalier local xattr_set= 394a5c952dbSAugustin Cavalier local xattr_set_args= 395a5c952dbSAugustin Cavalier local xattr_get= 396a5c952dbSAugustin Cavalier local xattr_get_args= 397a5c952dbSAugustin Cavalier case $HOST_PLATFORM in 398a5c952dbSAugustin Cavalier darwin) 399a5c952dbSAugustin Cavalier xattr_set="xattr"; xattr_set_args="-w \$NAME \"\$VALUE\"" 400a5c952dbSAugustin Cavalier xattr_get="xattr"; xattr_get_args="-p \$NAME" 401a5c952dbSAugustin Cavalier ;; 402a5c952dbSAugustin Cavalier freebsd) 403a5c952dbSAugustin Cavalier xattr_set="setextattr"; xattr_set_args="user \$NAME \"\$VALUE\"" 404a5c952dbSAugustin Cavalier xattr_get="getextattr"; xattr_get_args="user \$NAME" 405a5c952dbSAugustin Cavalier ;; 406a5c952dbSAugustin Cavalier linux) 407a5c952dbSAugustin Cavalier xattr_set="setfattr"; xattr_set_args="-n user.\$NAME -v \"\$VALUE\"" 408a5c952dbSAugustin Cavalier xattr_get="getfattr"; xattr_get_args="-n user.\$NAME" 409a5c952dbSAugustin Cavalier ;; 410a5c952dbSAugustin Cavalier *) 411a5c952dbSAugustin Cavalier return 0 412a5c952dbSAugustin Cavalier ;; 413a5c952dbSAugustin Cavalier esac 414a5c952dbSAugustin Cavalier if ! type $xattr_set >/dev/null 2>&1; then 415a5c952dbSAugustin Cavalier echo "$0: could not find $xattr_set, assuming host has no extended attributes" 416a5c952dbSAugustin Cavalier return 0 417a5c952dbSAugustin Cavalier elif ! type $xattr_get >/dev/null 2>&1; then 418a5c952dbSAugustin Cavalier echo "$0: could not find $xattr_get, assuming host has no extended attributes" 419a5c952dbSAugustin Cavalier return 0 420a5c952dbSAugustin Cavalier fi 421a5c952dbSAugustin Cavalier 422a5c952dbSAugustin Cavalier echo "xattr test file" >"$outputDir/xattrtest" 423a5c952dbSAugustin Cavalier local i=0 424a5c952dbSAugustin Cavalier # on round 0, we test if we can set 3 attrs of 1K each (enough for xattr-ref) 425a5c952dbSAugustin Cavalier # on round 1, we test if we can set 3 attrs of 45K each (enough for full xattr) 426a5c952dbSAugustin Cavalier while [ $i -lt 2 ]; do 427a5c952dbSAugustin Cavalier local j=0 428a5c952dbSAugustin Cavalier while [ $j -lt 3 ]; do 429a5c952dbSAugustin Cavalier NAME=attr$j 430a5c952dbSAugustin Cavalier VALUE=`printf '%*s' $((1024 + $i * 45056)) "" | tr ' ' x` 431a5c952dbSAugustin Cavalier if [ `echo -n $VALUE | wc -c` -lt $((1024 + $i * 45056)) ]; then 432a5c952dbSAugustin Cavalier echo "$0: warning: could not generate test data for extended attributes" 433a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 434a5c952dbSAugustin Cavalier return $i 435a5c952dbSAugustin Cavalier elif ! $xattr_set `eval echo \"$xattr_set_args\"` \ 436a5c952dbSAugustin Cavalier "$outputDir/xattrtest" >/dev/null 2>&1 ; then 437a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 438a5c952dbSAugustin Cavalier return $i 439a5c952dbSAugustin Cavalier fi 440a5c952dbSAugustin Cavalier j=$((j+1)) 441a5c952dbSAugustin Cavalier done 442a5c952dbSAugustin Cavalier i=$((i+1)) 443a5c952dbSAugustin Cavalier done 444a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 445a5c952dbSAugustin Cavalier return 2 446a5c952dbSAugustin Cavalier} 447a5c952dbSAugustin Cavalier 448483b28e4SIngo Weinholdis_in_list() 449483b28e4SIngo Weinhold{ 450483b28e4SIngo Weinhold local element 451483b28e4SIngo Weinhold for element in $2; do 452483b28e4SIngo Weinhold if [ "$1" = "$element" ]; then 453483b28e4SIngo Weinhold return 0 454483b28e4SIngo Weinhold fi 455483b28e4SIngo Weinhold done 456483b28e4SIngo Weinhold return 1 457483b28e4SIngo Weinhold} 458483b28e4SIngo Weinhold 4597f9beaf1SOliver Tappe# check for --help or -h and show usage immediately 4607f9beaf1SOliver Tappeif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then 4618b420c2fSOliver Tappe usage; exit 0; 4628b420c2fSOliver Tappefi 4638b420c2fSOliver Tappe 464c6c03d56SAugustin Cavalier# ensure umask is not too restrictive 465c6c03d56SAugustin Cavalierif [ $(umask) -gt 22 ]; then 466c6c03d56SAugustin Cavalier echo "Your umask is too restrictive (should be: <= 0022; is actually:" $(umask)")" 467c6c03d56SAugustin Cavalier exit 1 468c6c03d56SAugustin Cavalierfi 4698b420c2fSOliver Tappe 470338b8dc3SIngo Weinhold# get cwd and the source directory 471338b8dc3SIngo WeinholdcurrentDir=`pwd` 4726e7c6fe5SIngo Weinholdcd `dirname "$0"` 473338b8dc3SIngo WeinholdsourceDir=`pwd` 4746e7c6fe5SIngo Weinholdcd "$currentDir" 475338b8dc3SIngo Weinhold 47655d267a4SFrançois Revol# backup the passed arguments 47755d267a4SFrançois RevolconfigureArgs="$@" 478825700d3SAugustin CavalierconfigurePath=$0 479825700d3SAugustin Cavalier 480825700d3SAugustin Cavalier# backup relevant environs 481825700d3SAugustin CavalierconfigureEnvirons= 482825700d3SAugustin Cavalierfor var in `env`; do 483825700d3SAugustin Cavalier case "$var" in 484825700d3SAugustin Cavalier CC\=*|HAIKU*\=*) 485825700d3SAugustin Cavalier configureEnvirons="$configureEnvirons $var" 486825700d3SAugustin Cavalier ;; 487825700d3SAugustin Cavalier esac 488825700d3SAugustin Cavalierdone 48955d267a4SFrançois Revol 4907c4641d0SOliver Tappe# internal default parameter values 491022fa244SIngo Weinhold# 49252a38012Sejakowatzplatform=`uname` 4935abd9a46SIngo WeinholdplatformMachine=`uname -m` 494c0e8cc1aSIngo WeinholdtargetArchs= 495338b8dc3SIngo WeinholdbuildCrossTools= 49629ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" 49760d8d8fcSIngo WeinholdbuildCrossToolsJobs= 498c2b76f7fSJonathan SchleiferuseClang=0 499c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0 500c0e8cc1aSIngo WeinholdunknownArchIndex=1 501483b28e4SIngo WeinholdhaikuTargetArchs= 5024da6cf84SFrançois RevolgdbSources= 5037c4641d0SOliver Tappe 50463701e7dSOliver Tappeif [ -z "$CC" ]; then 50563701e7dSOliver Tappe CC=gcc 50663701e7dSOliver Tappefi 50763701e7dSOliver Tappe 5087c4641d0SOliver Tappe# exported (BuildSetup) default parameter values 5097c4641d0SOliver Tappe# 51063701e7dSOliver TappeHOST_GCC_RAW_VERSION=`$CC -dumpversion` 51163701e7dSOliver TappeHOST_GCC_MACHINE=`$CC -dumpmachine` 5127c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0 51376fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0 5147c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0 5157c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default 5167c4641d0SOliver TappeTARGET_PLATFORM=haiku 5177c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0 5187986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0 519fc2c93fbSAugustin CavalierHAIKU_HOST_USE_XATTR= 520fc2c93fbSAugustin CavalierHAIKU_HOST_USE_XATTR_REF= 5212ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0 522f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r" 52363701e7dSOliver TappeHOST_GCC_LD=`$CC -print-prog-name=ld` 52463701e7dSOliver TappeHOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy` 5252a5d0aafSIngo WeinholdHOST_SHA256= 526e173a1ecSIngo WeinholdHOST_HAIKU_PORTER= 527e173a1ecSIngo WeinholdHAIKU_PORTS= 528e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS= 529c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP=0 530e70c4c64SPulkoMandyHAIKU_BOOT_BOARD= 531aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0 5322a5d0aafSIngo Weinhold 533c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS= 534c0e8cc1aSIngo Weinhold 535a04a520bSJonathan Schleiferset_default_value HAIKU_NASM nasm 536c0e8cc1aSIngo Weinhold 5373942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then 5382a5d0aafSIngo Weinhold HOST_SHA256=sha256sum 5393942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then 5402a5d0aafSIngo Weinhold HOST_SHA256="sha256 -q" 541b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then 542b5a871b1SNiels Sascha Reedijk HOST_SHA256="shasum -a 256" 5432a5d0aafSIngo Weinholdelse 5442a5d0aafSIngo Weinhold echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2 5452a5d0aafSIngo Weinhold exit 1 5462a5d0aafSIngo Weinholdfi 547338b8dc3SIngo Weinhold 54884edb1a1SAxel DörflerhaikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20" 549a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion 550af4bf973SOliver Tappe # version of legacy gcc required to build haiku 551483b28e4SIngo WeinholdsupportedTargetArchs=" 552483b28e4SIngo Weinhold arm 553483b28e4SIngo Weinhold m68k 554483b28e4SIngo Weinhold ppc 555483b28e4SIngo Weinhold x86 556483b28e4SIngo Weinhold x86_64 557483b28e4SIngo Weinhold x86_gcc2 558483b28e4SIngo Weinhold " 559af4bf973SOliver Tappe 5607c4641d0SOliver Tappe# determine output directory 5617c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then 5627c4641d0SOliver Tappe outputDir=$currentDir/generated 5637c4641d0SOliver Tappeelse 5647c4641d0SOliver Tappe outputDir=$currentDir 5657c4641d0SOliver Tappefi 5667c4641d0SOliver TappebuildOutputDir="$outputDir/build" 5677c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes" 5687c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig" 5697c4641d0SOliver Tappe 5707c4641d0SOliver Tappe# check for update request 5717c4641d0SOliver Tappeif [ "$1" = "--update" ]; then 5727c4641d0SOliver Tappe if ! [ -e "$buildConfigFile" ]; then 5737c4641d0SOliver Tappe echo $0 --update: \'$buildConfigFile\' not found - updating not possible. 5747c4641d0SOliver Tappe exit 1 5757c4641d0SOliver Tappe fi 576825700d3SAugustin Cavalier # get last configure invocation and flags from BuildConfig and call ourselves with it 577825700d3SAugustin Cavalier lastPwd=`grep "#d " "$buildConfigFile" | cut -c 4-` 578825700d3SAugustin Cavalier lastConfig=`grep "#c " "$buildConfigFile" | cut -c 4-` 579825700d3SAugustin Cavalier lastEnv=`grep "#e " "$buildConfigFile" | cut -c 4-` 580825700d3SAugustin Cavalier lastArgs=`grep "#a " "$buildConfigFile" | cut -c 4-` 581825700d3SAugustin Cavalier if [ -z "$lastConfig" ]; then 582825700d3SAugustin Cavalier echo "$0 --update: The previous configure invocation was not properly" \ 583825700d3SAugustin Cavalier "encoded into '$buildConfigFile' - updating not possible." 5847c4641d0SOliver Tappe exit 1 5857c4641d0SOliver Tappe fi 586825700d3SAugustin Cavalier cd $lastPwd 587fc2c93fbSAugustin Cavalier if [ -n "$lastEnv" ]; then 588825700d3SAugustin Cavalier export $lastEnv 589fc2c93fbSAugustin Cavalier fi 590825700d3SAugustin Cavalier $lastConfig $lastArgs 591825700d3SAugustin Cavalier exit $? 5927c4641d0SOliver Tappefi 5937c4641d0SOliver Tappe 594022fa244SIngo Weinhold# parse parameters 595022fa244SIngo Weinhold# 59620ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do 597022fa244SIngo Weinhold case "$1" in 598e173a1ecSIngo Weinhold --bootstrap) 599e173a1ecSIngo Weinhold assertparams "$1" 3 $# 600e173a1ecSIngo Weinhold HOST_HAIKU_PORTER="`absolute_path $2`" 601e173a1ecSIngo Weinhold HAIKU_PORTS_CROSS="`absolute_path $3`" 602e173a1ecSIngo Weinhold HAIKU_PORTS="`absolute_path $4`" 603c9dd05ffSJonathan Schleifer HAIKU_IS_BOOTSTRAP=1 604c9dd05ffSJonathan Schleifer HAIKU_NO_DOWNLOADS=1 605502882dbSJessica Hamilton check_file_exists "$HOST_HAIKU_PORTER" || ( 606502882dbSJessica Hamilton echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2 60739d444a3SArvind S Raj exit 1 60839d444a3SArvind S Raj ) 60939d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS" || ( 61039d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS" >&2 61139d444a3SArvind S Raj exit 1 61239d444a3SArvind S Raj ) 61339d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS_CROSS" || ( 61439d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2 61539d444a3SArvind S Raj exit 1 61639d444a3SArvind S Raj ) 617e173a1ecSIngo Weinhold shift 4 618e173a1ecSIngo Weinhold ;; 619c0e8cc1aSIngo Weinhold --build-cross-tools) 620c0e8cc1aSIngo Weinhold if [ -z "$buildCrossTools" ]; then 6219b0dd528SIngo Weinhold assertparams "$1" 2 $# 622c0e8cc1aSIngo Weinhold targetArch=$2 6239b0dd528SIngo Weinhold buildCrossTools=$3 6249b0dd528SIngo Weinhold shift 3 625c0e8cc1aSIngo Weinhold else 626c0e8cc1aSIngo Weinhold assertparam "$1" $# 627c0e8cc1aSIngo Weinhold targetArch=$2 628c0e8cc1aSIngo Weinhold shift 2 629c0e8cc1aSIngo Weinhold fi 630c0e8cc1aSIngo Weinhold case "$targetArch" in 631c0e8cc1aSIngo Weinhold x86_gcc2) targetMachine=i586-pc-haiku;; 632c0e8cc1aSIngo Weinhold x86) targetMachine=i586-pc-haiku;; 633c0e8cc1aSIngo Weinhold x86_64) targetMachine=x86_64-unknown-haiku;; 634c0e8cc1aSIngo Weinhold ppc) targetMachine=powerpc-apple-haiku;; 635c0e8cc1aSIngo Weinhold m68k) targetMachine=m68k-unknown-haiku;; 636c0e8cc1aSIngo Weinhold arm) targetMachine=arm-unknown-haiku;; 637c0e8cc1aSIngo Weinhold *) 638c0e8cc1aSIngo Weinhold echo "Unsupported target architecture: $2" >&2 639c0e8cc1aSIngo Weinhold exit 1 640c0e8cc1aSIngo Weinhold ;; 641c0e8cc1aSIngo Weinhold esac 642c0e8cc1aSIngo Weinhold set_variable buildCrossToolsMachine_$targetArch $targetMachine 643c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 644c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 6459b0dd528SIngo Weinhold ;; 6469b0dd528SIngo Weinhold --cross-tools-prefix) 6479b0dd528SIngo Weinhold assertparam "$1" $# 648c0e8cc1aSIngo Weinhold targetArch=unknown${unknownArchIndex} 649c0e8cc1aSIngo Weinhold set_variable crossToolsPrefix_$targetArch "$2" 650c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 651c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 652d68208faSMatt Madia unknownArchIndex=$(($unknownArchIndex + 1)) 6539b0dd528SIngo Weinhold shift 2 6549b0dd528SIngo Weinhold ;; 655a66c32ddSIngo Weinhold --distro-compatibility) 6569b0dd528SIngo Weinhold assertparam "$1" $# 6577c4641d0SOliver Tappe HAIKU_DISTRO_COMPATIBILITY=$2 6587c4641d0SOliver Tappe case "$HAIKU_DISTRO_COMPATIBILITY" in 659a66c32ddSIngo Weinhold official) ;; 660a66c32ddSIngo Weinhold compatible) ;; 661a66c32ddSIngo Weinhold default) ;; 662a66c32ddSIngo Weinhold *) echo "Invalid distro compatibility" \ 6637c4641d0SOliver Tappe "level: $HAIKU_DISTRO_COMPATIBILITY" 664a66c32ddSIngo Weinhold exit 1;; 665a66c32ddSIngo Weinhold esac 6669b0dd528SIngo Weinhold shift 2 6679b0dd528SIngo Weinhold ;; 6682ebcd86dSIngo Weinhold --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;; 6697c4641d0SOliver Tappe --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;; 67076fa0be3SIngo Weinhold --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;; 6717c4641d0SOliver Tappe --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;; 67260d8d8fcSIngo Weinhold -j*) buildCrossToolsJobs="$1"; shift 1;; 673aa2e5ecaSOliver Tappe --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;; 6747c4641d0SOliver Tappe --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;; 675483b28e4SIngo Weinhold --target-arch) 676483b28e4SIngo Weinhold assertparam "$1" $# 677483b28e4SIngo Weinhold targetArch=$2 678483b28e4SIngo Weinhold shift 2 679483b28e4SIngo Weinhold if [ ! "$platform" = Haiku ]; then 680483b28e4SIngo Weinhold echo "--target-arch can only be specified on Haiku." >&2 681483b28e4SIngo Weinhold exit 1 682483b28e4SIngo Weinhold fi 683483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 684483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 685483b28e4SIngo Weinhold exit 1 686483b28e4SIngo Weinhold ) 687483b28e4SIngo Weinhold haikuTargetArchs="$haikuTargetArchs $targetArch" 688483b28e4SIngo Weinhold ;; 689d73993ffSAugustin Cavalier --use-clang) 690d73993ffSAugustin Cavalier assertparam "$1" $# 691d73993ffSAugustin Cavalier targetArch=$2 692d73993ffSAugustin Cavalier useClang=1 693d73993ffSAugustin Cavalier case "$targetArch" in 694d73993ffSAugustin Cavalier x86) targetMachine=i586-pc-haiku;; 695d73993ffSAugustin Cavalier x86_64) targetMachine=x86_64-unknown-haiku;; 696d73993ffSAugustin Cavalier *) 697d73993ffSAugustin Cavalier echo "Unsupported target architecture: $2" >&2 698d73993ffSAugustin Cavalier exit 1 699d73993ffSAugustin Cavalier ;; 700d73993ffSAugustin Cavalier esac 70165706842SAugustin Cavalier get_build_tool_path clang clang 702*36f28382SAugustin Cavalier if [ -z `get_variable "crossToolsPrefix_$targetArch"` ] \ 703*36f28382SAugustin Cavalier && [ -z `get_variable buildCrossToolsMachine_$targetArch` ]; then 70465706842SAugustin Cavalier set_variable crossToolsPrefix_$targetArch llvm- 70565706842SAugustin Cavalier fi 706*36f28382SAugustin Cavalier if ! test "${targetArchs#*$targetArch}" != "$targetArchs"; then 707*36f28382SAugustin Cavalier # we have not already added this arch to targetArchs, so add it now 708d73993ffSAugustin Cavalier targetArchs="$targetArchs $targetArch" 709*36f28382SAugustin Cavalier fi 710d73993ffSAugustin Cavalier HAIKU_PACKAGING_ARCHS= 711d73993ffSAugustin Cavalier shift 2 712d73993ffSAugustin Cavalier ;; 7137c4641d0SOliver Tappe --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;; 714c0e8cc1aSIngo Weinhold --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;; 7157986925fSIngo Weinhold --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;; 716fc2c93fbSAugustin Cavalier --no-full-xattr)HAIKU_HOST_USE_XATTR=0; shift 1;; 717fc2c93fbSAugustin Cavalier --no-xattr) HAIKU_HOST_USE_XATTR_REF=0; shift 1;; 7184da6cf84SFrançois Revol --with-gdb) gdbSources=$2; shift 2;; 719022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 720022fa244SIngo Weinhold esac 721022fa244SIngo Weinholddone 722022fa244SIngo Weinhold 7230df3cc9cSIngo Weinhold# detect the build platform 724338b8dc3SIngo Weinholdcase "${platform}" in 7257c4641d0SOliver Tappe Darwin) HOST_PLATFORM=darwin ;; 7267c4641d0SOliver Tappe FreeBSD) HOST_PLATFORM=freebsd 7277986925fSIngo Weinhold if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then 7285abd9a46SIngo Weinhold echo Unsupported platform: FreeBSD ${platformMachine} 729308c212cSIngo Weinhold exit 1 730308c212cSIngo Weinhold fi ;; 7317c4641d0SOliver Tappe Haiku) HOST_PLATFORM=haiku_host ;; 7327c4641d0SOliver Tappe Linux) HOST_PLATFORM=linux ;; 7337c4641d0SOliver Tappe OpenBSD) HOST_PLATFORM=openbsd ;; 7347c4641d0SOliver Tappe SunOS) HOST_PLATFORM=sunos ;; 7357c4641d0SOliver Tappe CYGWIN_NT-*) HOST_PLATFORM=cygwin ;; 736338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 7374cbe4925SAxel Dörfler exit 1 ;; 7384cbe4925SAxel Dörfleresac 73952a38012Sejakowatz 7400962132cSAlex Smith# check for case-sensitive filesystem 7410962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null 7420962132cSAlex Smithmkdir haikucasetest 2>/dev/null 7430962132cSAlex SmithcaseInsensitive=$? 74497f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null 7450962132cSAlex Smithif [ $caseInsensitive != 0 ]; then 7463ecc5287SMichael Lotz echo "You need a case-sensitive file-system to build Haiku." 7470962132cSAlex Smith if [ $HOST_PLATFORM = "darwin" ]; then 7487a05e252SJohn Scipione echo "You can create a case-sensitive disk image using Disk Utility." 7493ecc5287SMichael Lotz fi 7500962132cSAlex Smith exit 1 7513ecc5287SMichael Lotzfi 7523ecc5287SMichael Lotz 753a5c952dbSAugustin Cavalier# check xattr support 754fc2c93fbSAugustin Cavalierif [ $HOST_PLATFORM != "haiku_host" ] && [ -z $HAIKU_HOST_USE_XATTR_REF ]; then 755a5c952dbSAugustin Cavalier check_native_xattrs 756a5c952dbSAugustin Cavalier attrSupport=$? 757fc2c93fbSAugustin Cavalier if [ $attrSupport = 2 ] && [ -z $HAIKU_HOST_USE_XATTR ]; then 758fc2c93fbSAugustin Cavalier HAIKU_HOST_USE_XATTR=1 759a5c952dbSAugustin Cavalier elif [ $attrSupport = 1 ]; then 760fc2c93fbSAugustin Cavalier HAIKU_HOST_USE_XATTR_REF=1 761a5c952dbSAugustin Cavalier fi 762a5c952dbSAugustin Cavalierfi 763fc2c93fbSAugustin Cavalierif [ -z $HAIKU_HOST_USE_XATTR ]; then HAIKU_HOST_USE_XATTR=0; fi 764fc2c93fbSAugustin Cavalierif [ -z $HAIKU_HOST_USE_XATTR_REF ]; then HAIKU_HOST_USE_XATTR_REF=0; fi 765a5c952dbSAugustin Cavalier 766f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed 767f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then 768f04f7042SNiels Sascha Reedijk HOST_EXTENDED_REGEX_SED="sed -E" 769f04f7042SNiels Sascha Reedijkfi 770f04f7042SNiels Sascha Reedijk 771cb721c59SFrançois Revol# check if nasm can actually output ELF files 772cb721c59SFrançois Revol# (the stock version in OSX can't) 773cb721c59SFrançois Revol# XXX: should probably only test for x86* arch 7743e6c09cdSAdrien Destuguesif [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then 775cb721c59SFrançois Revol echo "$HAIKU_NASM cannot generate ELF files. Please install a working version." 776cb721c59SFrançois Revol if [ $HOST_PLATFORM = "darwin" ]; then 777cb721c59SFrançois Revol echo "You can install it from Mac Ports." 778cb721c59SFrançois Revol echo "Mac Ports is available at: http://www.macports.org/" 779cb721c59SFrançois Revol fi 780cb721c59SFrançois Revol exit 1 781cb721c59SFrançois Revolfi 782cb721c59SFrançois Revol 783338b8dc3SIngo Weinhold# create output directory 7846e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1 785338b8dc3SIngo Weinhold 7862ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then 7872ebcd86dSIngo Weinhold invalidCommand=$sourceDir/build/scripts/host_build_only 7882ebcd86dSIngo Weinhold HAIKU_AR=$invalidCommand 7892ebcd86dSIngo Weinhold HAIKU_CC=$invalidCommand 7902ebcd86dSIngo Weinhold HAIKU_LD=$invalidCommand 7912ebcd86dSIngo Weinhold HAIKU_OBJCOPY=$invalidCommand 7922ebcd86dSIngo Weinhold HAIKU_RANLIB=$invalidCommand 7932ebcd86dSIngo Weinhold HAIKU_ELFEDIT=$invalidCommand 794d6f80927SJonathan Schleifer HAIKU_NASM=$invalidCommand 7952ebcd86dSIngo Weinhold HAIKU_STRIP=$invalidCommand 7962ebcd86dSIngo Weinholdelse 797c0e8cc1aSIngo Weinhold if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then 798c0e8cc1aSIngo Weinhold targetArchs="$HAIKU_PACKAGING_ARCHS" 799c0e8cc1aSIngo Weinhold fi 800c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 801c0e8cc1aSIngo Weinhold 802483b28e4SIngo Weinhold # On Haiku determine target architectures and tools automatically. 803c0e8cc1aSIngo Weinhold if [ -z "$targetArchs" ]; then 804483b28e4SIngo Weinhold if [ $HOST_PLATFORM != haiku_host ]; then 805483b28e4SIngo Weinhold echo "Please specify the build tools to use or build (via" \ 806eaef83a9SJeroen Oortwijn "--cross-tools-prefix or --build-cross-tools) or specify a" \ 807483b28e4SIngo Weinhold "host-only build (--host-only)." >&2 8087f9beaf1SOliver Tappe echo "For more info, invoke $0 --help" 809483b28e4SIngo Weinhold exit 1 810483b28e4SIngo Weinhold fi 811483b28e4SIngo Weinhold 812483b28e4SIngo Weinhold # determine primary architecture 813dda53eaeSIngo Weinhold targetArch=`package list -i /system/packages/haiku-*.hpkg \ 814483b28e4SIngo Weinhold | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'` 815483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 816483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 817483b28e4SIngo Weinhold exit 1 818483b28e4SIngo Weinhold ) 819c0e8cc1aSIngo Weinhold targetArchs=$targetArch 820483b28e4SIngo Weinhold 821c0e8cc1aSIngo Weinhold set_default_value HAIKU_AR_$targetArch ar 822c0e8cc1aSIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc 823c0e8cc1aSIngo Weinhold set_default_value HAIKU_LD_$targetArch ld 824c0e8cc1aSIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy 825c0e8cc1aSIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib 826c0e8cc1aSIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit 827c0e8cc1aSIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip 828483b28e4SIngo Weinhold 829483b28e4SIngo Weinhold # determine secondary architectures 830483b28e4SIngo Weinhold for targetArch in $supportedTargetArchs; do 83180262a91SMatt Madia if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then 832483b28e4SIngo Weinhold targetArchs="$targetArchs $targetArch" 833483b28e4SIngo Weinhold set_default_value HAIKU_AR_$targetArch ar-$targetArch 834483b28e4SIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc-$targetArch 835483b28e4SIngo Weinhold set_default_value HAIKU_LD_$targetArch ld-$targetArch 836483b28e4SIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch 837483b28e4SIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch 838483b28e4SIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch 839483b28e4SIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip-$targetArch 840483b28e4SIngo Weinhold fi 841483b28e4SIngo Weinhold done 842483b28e4SIngo Weinhold 843483b28e4SIngo Weinhold # The target architectures might have been specified explicitly. 844483b28e4SIngo Weinhold if [ -n "$haikuTargetArchs" ]; then 845483b28e4SIngo Weinhold for targetArch in $haikuTargetArchs; do 846483b28e4SIngo Weinhold is_in_list "$targetArch" "$targetArchs" || ( 847483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"." \ 848483b28e4SIngo Weinhold "Only native architectures of the host platform can" \ 849483b28e4SIngo Weinhold "be specified." >&2 850483b28e4SIngo Weinhold exit 1 851483b28e4SIngo Weinhold ) 852483b28e4SIngo Weinhold done 853483b28e4SIngo Weinhold targetArchs="$haikuTargetArchs" 854483b28e4SIngo Weinhold fi 855c0e8cc1aSIngo Weinhold fi 856c0e8cc1aSIngo Weinhold 85768ccc989SIngo Weinhold isPrimaryArch=1 858c0e8cc1aSIngo Weinhold for targetArch in $targetArchs; do 859c0e8cc1aSIngo Weinhold # Note: targetArch is "unknown<n>" at this point, if a cross-tools 860c0e8cc1aSIngo Weinhold # prefix was specified. The standard_gcc_settings call below will get 861c0e8cc1aSIngo Weinhold # the actual architecture. 862c0e8cc1aSIngo Weinhold 863c0e8cc1aSIngo Weinhold crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch` 864c0e8cc1aSIngo Weinhold 865338b8dc3SIngo Weinhold # build cross tools from sources 866c0e8cc1aSIngo Weinhold if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then 867c0e8cc1aSIngo Weinhold crossToolsDir="$outputDir/cross-tools-$targetArch" 868c0e8cc1aSIngo Weinhold targetMachine=`get_variable buildCrossToolsMachine_$targetArch` 869c0e8cc1aSIngo Weinhold script="$buildCrossToolsScript" 8708304ec7cSIngo Weinhold scriptArgs= 871c0e8cc1aSIngo Weinhold if [ $targetArch != x86_gcc2 ]; then 8728304ec7cSIngo Weinhold script="${script}_gcc4" 8738304ec7cSIngo Weinhold scriptArgs="$targetMachine" 8741e93288eSJérôme Duval set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \ 8751e93288eSJérôme Duval $useGccGraphiteDefault 876c0e8cc1aSIngo Weinhold fi 87768ccc989SIngo Weinhold secondaryArch= 87868ccc989SIngo Weinhold if [ -z "$isPrimaryArch" ]; then 87968ccc989SIngo Weinhold secondaryArch=$targetArch 88068ccc989SIngo Weinhold fi 88186de8c37SIngo Weinhold 88286de8c37SIngo Weinhold case $HOST_PLATFORM in 88386de8c37SIngo Weinhold freebsd|openbsd) MAKE=gmake;; 88486de8c37SIngo Weinhold *) MAKE=make;; 88586de8c37SIngo Weinhold esac 88686de8c37SIngo Weinhold 887825700d3SAugustin Cavalier if [ ! -d "$crossToolsDir" ]; then 88886de8c37SIngo Weinhold MAKE=$MAKE \ 88968ccc989SIngo Weinhold SECONDARY_ARCH=$secondaryArch \ 890c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE=`get_variable \ 891c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE_$targetArch` \ 892b3ece905SJérôme Duval HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \ 8934da6cf84SFrançois Revol HAIKU_USE_GDB="$gdbSources" \ 8948304ec7cSIngo Weinhold "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \ 8958304ec7cSIngo Weinhold "$crossToolsDir" $buildCrossToolsJobs || exit 1 896825700d3SAugustin Cavalier else 897825700d3SAugustin Cavalier echo "$targetArch crosstools already exist in $crossToolsDir; skipping build" 898825700d3SAugustin Cavalier fi 899c0e8cc1aSIngo Weinhold crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-" 900338b8dc3SIngo Weinhold fi 901338b8dc3SIngo Weinhold 902c0e8cc1aSIngo Weinhold # prepare gcc settings and get the actual target architecture 903a7bddff1SJonathan Schleifer if [ $useClang = 1 ]; then 90465706842SAugustin Cavalier gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as" 9051f6fe055SAugustin Cavalier 9061f6fe055SAugustin Cavalier # Clang's compiler intrinsics are not compatible with GCC's or even 9071f6fe055SAugustin Cavalier # across versions of Clang, so we must collect them for use in the build. 9081f6fe055SAugustin Cavalier mkdir -p "$outputDir/clang_headers" || exit 1 9091f6fe055SAugustin Cavalier clangHeadersDir=`$gcc -print-resource-dir`/include/ 9101f6fe055SAugustin Cavalier cp $clangHeadersDir/*intrin* $clangHeadersDir/mm3* "$outputDir/clang_headers" || exit 1 911d73993ffSAugustin Cavalier elif [ -z "${crossToolsPrefix}" ]; then 912d73993ffSAugustin Cavalier gcc=`get_variable HAIKU_CC_$targetArch` 913a7bddff1SJonathan Schleifer else 914c0e8cc1aSIngo Weinhold gcc="${crossToolsPrefix}gcc" 915a7bddff1SJonathan Schleifer fi 916c0e8cc1aSIngo Weinhold standard_gcc_settings "$gcc" 917c0e8cc1aSIngo Weinhold targetArch=$standard_gcc_settings_targetArch 918338b8dc3SIngo Weinhold 919c0e8cc1aSIngo Weinhold # set default values for flags 920c0e8cc1aSIngo Weinhold set_default_value HAIKU_CPPFLAGS_$targetArch "" 921c0e8cc1aSIngo Weinhold set_default_value HAIKU_CCFLAGS_$targetArch "" 922c0e8cc1aSIngo Weinhold set_default_value HAIKU_CXXFLAGS_$targetArch "" 923c0e8cc1aSIngo Weinhold set_default_value HAIKU_LDFLAGS_$targetArch "" 924c0e8cc1aSIngo Weinhold set_default_value HAIKU_ARFLAGS_$targetArch cru 925c0e8cc1aSIngo Weinhold set_default_value HAIKU_UNARFLAGS_$targetArch x 926338b8dc3SIngo Weinhold 927c0e8cc1aSIngo Weinhold # Override the cross tools variables, if the tools were built or a 928c0e8cc1aSIngo Weinhold # prefix was specified. 929b7777272SAlex Smith if [ -n "$crossToolsPrefix" ]; then 930c0e8cc1aSIngo Weinhold get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar 931c0e8cc1aSIngo Weinhold get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld 932c0e8cc1aSIngo Weinhold get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy 933c0e8cc1aSIngo Weinhold get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib 934c0e8cc1aSIngo Weinhold get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip 935c0e8cc1aSIngo Weinhold 936c0e8cc1aSIngo Weinhold case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in 937133e4131SJérôme Duval 4.*|5.*|6.*|7.*|8.*) 938c0e8cc1aSIngo Weinhold get_build_tool_path ELFEDIT_$targetArch \ 939c0e8cc1aSIngo Weinhold ${crossToolsPrefix}elfedit 940bd16f0ddSAlex Smith ;; 941bd16f0ddSAlex Smith esac 94252a38012Sejakowatz fi 94352a38012Sejakowatz 944ef57df3dSIngo Weinhold # check whether the Haiku compiler really targets Haiku 945c0e8cc1aSIngo Weinhold targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` 946c0e8cc1aSIngo Weinhold case "$targetMachine" in 947eedc3d0bSIngo Weinhold *-*-haiku) ;; 948c0e8cc1aSIngo Weinhold *) 949c0e8cc1aSIngo Weinhold echo The compiler specified as Haiku target compiler is not a \ 950c0e8cc1aSIngo Weinhold valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2 951eedc3d0bSIngo Weinhold echo compiler: $HAIKU_CC 952c0e8cc1aSIngo Weinhold echo compiler is configured for target: $targetMachine 953eedc3d0bSIngo Weinhold exit 1 ;; 954eedc3d0bSIngo Weinhold esac 955c0e8cc1aSIngo Weinhold 956c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch" 95768ccc989SIngo Weinhold isPrimaryArch= 958c0e8cc1aSIngo Weinhold done 9592ebcd86dSIngo Weinholdfi 960eedc3d0bSIngo Weinhold 96152a38012Sejakowatz# Generate BuildConfig 9627c4641d0SOliver Tappecat << EOF > "$buildConfigFile" 963825700d3SAugustin Cavalier# -- WARNING -- 964825700d3SAugustin Cavalier# This file was AUTOMATICALLY GENERATED by configure, and will be completely 965825700d3SAugustin Cavalier# overwritten the next time configure is run. 966825700d3SAugustin Cavalier# 967825700d3SAugustin Cavalier#d ${currentDir} 968825700d3SAugustin Cavalier#c ${configurePath} 969825700d3SAugustin Cavalier#e ${configureEnvirons} 970825700d3SAugustin Cavalier#a ${configureArgs} 97152a38012Sejakowatz 9727c4641d0SOliver TappeTARGET_PLATFORM ?= "${TARGET_PLATFORM}" ; 9737c4641d0SOliver TappeHOST_PLATFORM ?= "${HOST_PLATFORM}" ; 974338b8dc3SIngo Weinhold 9757c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ; 97676fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ; 9777c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ; 9787c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ; 9797c4641d0SOliver TappeHAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ; 9807986925fSIngo WeinholdHAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ; 9817986925fSIngo WeinholdHAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ; 982bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ; 9832ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ; 984eccc7665SIngo Weinhold 985c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ; 98665ad1ba3SAlex Smith 987aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ; 988aa2e5ecaSOliver Tappe 9897c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ; 990338b8dc3SIngo Weinhold 991d6f80927SJonathan SchleiferHAIKU_NASM ?= ${HAIKU_NASM} ; 992e70c4c64SPulkoMandyHAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ; 993338b8dc3SIngo Weinhold 994f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ; 9957c4641d0SOliver TappeHOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ; 9967c4641d0SOliver TappeHOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ; 9977c4641d0SOliver TappeHOST_LD ?= ${HOST_GCC_LD} ; 9987c4641d0SOliver TappeHOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ; 9992a5d0aafSIngo WeinholdHOST_SHA256 ?= ${HOST_SHA256} ; 10008b5934c9SIngo Weinhold 1001e173a1ecSIngo WeinholdHOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ; 1002e173a1ecSIngo WeinholdHAIKU_PORTS ?= ${HAIKU_PORTS} ; 1003e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ; 1004c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ; 1005e173a1ecSIngo Weinhold 1006c4786ea6SlilloEOF 1007c4786ea6Slillo 1008c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do 1009c0e8cc1aSIngo Weinhold variables=" 1010c0e8cc1aSIngo Weinhold HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION 1011c0e8cc1aSIngo Weinhold HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE 1012c0e8cc1aSIngo Weinhold HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR 1013c0e8cc1aSIngo Weinhold HAIKU_CPU HAIKU_CPU 1014c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC 1015c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX 1016c0e8cc1aSIngo Weinhold HAIKU_AR HAIKU_AR 1017c0e8cc1aSIngo Weinhold HAIKU_CC HAIKU_CC 1018c2b76f7fSJonathan Schleifer HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG 1019c0e8cc1aSIngo Weinhold HAIKU_LD HAIKU_LD 1020c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY HAIKU_OBJCOPY 1021c0e8cc1aSIngo Weinhold HAIKU_RANLIB HAIKU_RANLIB 1022c0e8cc1aSIngo Weinhold HAIKU_ELFEDIT HAIKU_ELFEDIT 1023c0e8cc1aSIngo Weinhold HAIKU_STRIP HAIKU_STRIP 1024c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS HAIKU_CPPFLAGS 1025c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS HAIKU_CCFLAGS 1026c0e8cc1aSIngo Weinhold HAIKU_C++FLAGS HAIKU_CXXFLAGS 1027c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS HAIKU_LDFLAGS 1028c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS HAIKU_ARFLAGS 1029c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS HAIKU_UNARFLAGS 1030c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE 1031c0e8cc1aSIngo Weinhold " 1032c0e8cc1aSIngo Weinhold set -- $variables 1033c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 1034c0e8cc1aSIngo Weinhold value=`get_variable ${2}_$targetArch` 1035c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile" 1036c0e8cc1aSIngo Weinhold shift 2 1037c0e8cc1aSIngo Weinhold done 1038b1e5b60cSAxel Dörfler 1039c0e8cc1aSIngo Weinhold # For variables that may have long values, distribute them over multiple 1040c0e8cc1aSIngo Weinhold # lines so that jam doesn't hit the maximum line length. 1041c0e8cc1aSIngo Weinhold variables=" 104266a7f29fSJérôme Duval HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR 1043c0e8cc1aSIngo Weinhold " 1044c0e8cc1aSIngo Weinhold set -- $variables 1045c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 1046c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= " >> "$buildConfigFile" 1047c0e8cc1aSIngo Weinhold get_variable ${2}_$targetArch | xargs -n 1 echo " " \ 1048c0e8cc1aSIngo Weinhold >> "$buildConfigFile" 1049c0e8cc1aSIngo Weinhold echo " ;" >> "$buildConfigFile" 1050c0e8cc1aSIngo Weinhold shift 2 1051c0e8cc1aSIngo Weinhold done 1052c0e8cc1aSIngo Weinholddone 1053b1e5b60cSAxel Dörfler 1054b1e5b60cSAxel Dörfler 10559b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory. 1056338b8dc3SIngo Weinhold 1057338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 1058338b8dc3SIngo Weinhold# automatically generated Jamfile 1059338b8dc3SIngo Weinhold 1060338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 1061338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 1062338b8dc3SIngo Weinhold 1063338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 1064338b8dc3SIngo Weinhold 1065338b8dc3SIngo WeinholdEOF 1066d73993ffSAugustin Cavalier 1067d73993ffSAugustin Cavalierecho "Configured successfully!" 1068