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. 75483b28e4SIngo Weinhold --target-arch <arch> Haiku only: Specify the target architecture to 76483b28e4SIngo Weinhold build for. Must be one of the architectures of the 77483b28e4SIngo Weinhold host system. The installed build tools for that 78483b28e4SIngo Weinhold architecture will be used. 79483b28e4SIngo Weinhold This option can be specified multiple times. The 80483b28e4SIngo Weinhold first occurrence specifies the primary 81483b28e4SIngo Weinhold architecture of the Haiku to build, subsequent 82483b28e4SIngo Weinhold ones the secondary architectures. 83d73993ffSAugustin Cavalier --use-clang <arch> Build with host Clang instead of GCC cross 84d73993ffSAugustin Cavalier compiler, targeting <arch> 85eccc7665SIngo Weinhold --use-gcc-pipe Build with GCC option -pipe. Speeds up the build 865a34a443SFrançois Revol process, but uses more memory. 87ed38d2efSJerome Duval --use-gcc-graphite Build with GCC Graphite engine for loop 88a5c952dbSAugustin Cavalier optimizations. (Only for GCC 4+.) 890385b065SIngo Weinhold --use-32bit Use -m32 flag on 64bit host gcc compiler. 90fc2c93fbSAugustin Cavalier --no-full-xattr Do not use Linux/*BSD/Darwin's native extended file 91fc2c93fbSAugustin Cavalier attributes as Haiku attributes. If they are still 92fc2c93fbSAugustin Cavalier available, they will be used to store hashes for 93fc2c93fbSAugustin Cavalier the attribute emulation layer. 94fc2c93fbSAugustin Cavalier --no-xattr Do not use Linux/*BSD/Darwin's native extended file 95fc2c93fbSAugustin Cavalier attributes for Haiku extended attributes at all, 96fc2c93fbSAugustin Cavalier even if they are available. 974da6cf84SFrançois Revol --with-gdb <gdb sources dir> 984da6cf84SFrançois Revol specify the path to a GDB source dir, to build 994da6cf84SFrançois Revol GDB for each arch we build the cross-tools for. 100338b8dc3SIngo Weinhold 101338b8dc3SIngo Weinholdenvironment variables: 10263701e7dSOliver Tappe CC The host compiler. Defaults to "gcc". 10365706842SAugustin Cavalier HAIKU_AR_<arch> The static library archiver for <arch>. 104c0e8cc1aSIngo Weinhold Defaults to "ar". 10565706842SAugustin Cavalier HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc". 10665706842SAugustin Cavalier HAIKU_LD_<arch> The <arch> linker. Defaults to "ld". 10765706842SAugustin Cavalier HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to 108c0e8cc1aSIngo Weinhold "objcopy". 10965706842SAugustin Cavalier HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults 110c0e8cc1aSIngo Weinhold to "ranlib". 11165706842SAugustin Cavalier HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip". 112a04a520bSJonathan Schleifer HAIKU_NASM The nasm assembler (x86 and x86_64 only). 113c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture 114c0e8cc1aSIngo Weinhold <arch>. Defaults to "". 115c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>. 116c0e8cc1aSIngo Weinhold Defaults to "". 117c0e8cc1aSIngo Weinhold HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>. 118c0e8cc1aSIngo Weinhold Defaults to "". 119c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>. 120c0e8cc1aSIngo Weinhold Defaults to "". 121c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target 122c0e8cc1aSIngo Weinhold architecture <arch> for archiving. Defaults to 123c0e8cc1aSIngo Weinhold "cru". 124c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target 125c0e8cc1aSIngo Weinhold architecture <arch> for unarchiving. Defaults to 126c0e8cc1aSIngo Weinhold "x". 12764f6da31SIngo Weinhold 128c0e8cc1aSIngo WeinholdNon-default output directories: 12964f6da31SIngo Weinhold By default all objects, build configuration, and other related files are 13064f6da31SIngo Weinhold stored in /path/to/haiku_source/generated. To store objects in a non-default 13164f6da31SIngo Weinhold location, run "../../relative/path/to/haiku_source/configure <options>" from 13264f6da31SIngo Weinhold within your non-default location. "jam [ options ] targets" can then be run 13364f6da31SIngo Weinhold directly inside your non-default location. Another option is to invoke "jam 13464f6da31SIngo Weinhold [ options ] targets" from within haiku_source. This can be accomplished by 13564f6da31SIngo Weinhold either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking 13664f6da31SIngo Weinhold jam or by creating a symlink of haiku_source/generated pointing to your 13764f6da31SIngo Weinhold non-default location and running jam. 13864f6da31SIngo Weinhold 13964f6da31SIngo Weinhold 140022fa244SIngo WeinholdEOF 141022fa244SIngo Weinhold} 142022fa244SIngo Weinhold 143022fa244SIngo Weinhold# assertparam 144022fa244SIngo Weinhold# 145022fa244SIngo Weinhold# Checks whether at least one parameter is left. 146022fa244SIngo Weinhold# 147022fa244SIngo Weinholdassertparam() 148022fa244SIngo Weinhold{ 14920ab75e6SIngo Weinhold if [ $2 -lt 2 ]; then 150022fa244SIngo Weinhold echo $0: \`$1\': Parameter expected. 151022fa244SIngo Weinhold exit 1 152022fa244SIngo Weinhold fi 153022fa244SIngo Weinhold} 154022fa244SIngo Weinhold 15520ab75e6SIngo Weinhold# assertparams 15620ab75e6SIngo Weinhold# 15720ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left. 15820ab75e6SIngo Weinhold# 15920ab75e6SIngo Weinholdassertparams() 16020ab75e6SIngo Weinhold{ 16120ab75e6SIngo Weinhold if [ $3 -le $2 ]; then 16220ab75e6SIngo Weinhold echo $0: \`$1\': Not enough parameters. 16320ab75e6SIngo Weinhold exit 1 16420ab75e6SIngo Weinhold fi 16520ab75e6SIngo Weinhold} 16620ab75e6SIngo Weinhold 167e173a1ecSIngo Weinhold# absolute_path 168e173a1ecSIngo Weinhold# 169e173a1ecSIngo Weinhold# returns the absolute path of a given path. 170e173a1ecSIngo Weinhold# 171e173a1ecSIngo Weinholdabsolute_path() 172e173a1ecSIngo Weinhold{ 1736a4f3954SFrançois Revol if [ "x$1" != "x${1#/}" ]; then 174e173a1ecSIngo Weinhold echo "$1" 175e173a1ecSIngo Weinhold else 176e173a1ecSIngo Weinhold echo "`pwd`/$1" 177e173a1ecSIngo Weinhold fi 178e173a1ecSIngo Weinhold} 179e173a1ecSIngo Weinhold 18039d444a3SArvind S Raj# check_dir_exists 18139d444a3SArvind S Raj# 18239d444a3SArvind S Raj# check if a directory exists or not 18339d444a3SArvind S Raj# 18439d444a3SArvind S Rajcheck_dir_exists() 18539d444a3SArvind S Raj{ 18639d444a3SArvind S Raj if [ -d "$1" ]; then 18739d444a3SArvind S Raj return 0 18839d444a3SArvind S Raj else 18939d444a3SArvind S Raj return 1 19039d444a3SArvind S Raj fi 19139d444a3SArvind S Raj} 19239d444a3SArvind S Raj 193502882dbSJessica Hamilton# check_file_exists 194502882dbSJessica Hamilton# 195502882dbSJessica Hamilton# check if a file exists or not 196502882dbSJessica Hamilton# 197502882dbSJessica Hamiltoncheck_file_exists() 198502882dbSJessica Hamilton{ 199502882dbSJessica Hamilton if [ -f "$1" ]; then 200502882dbSJessica Hamilton return 0 201502882dbSJessica Hamilton else 202502882dbSJessica Hamilton return 1 203502882dbSJessica Hamilton fi 204502882dbSJessica Hamilton} 205502882dbSJessica Hamilton 2069a001156SOliver Tappe# real_path 2079a001156SOliver Tappe# 2089a001156SOliver Tappe# returns the realpath of a symbolic link. 2099a001156SOliver Tappe# 2109a001156SOliver Tappereal_path() 2119a001156SOliver Tappe{ 2129a001156SOliver Tappe perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1" 2139a001156SOliver Tappe} 2149a001156SOliver Tappe 215e5d446fcSAlexander von Gluck IV# valid_toolchain 216e5d446fcSAlexander von Gluck IV# 217e5d446fcSAlexander von Gluck IV# check if toolchain is valid 218e5d446fcSAlexander von Gluck IV# 219e5d446fcSAlexander von Gluck IVvalid_toolchain() 220e5d446fcSAlexander von Gluck IV{ 221e5d446fcSAlexander von Gluck IV TRIPLET="$1" 222e5d446fcSAlexander von Gluck IV BASE="$2" 223e5d446fcSAlexander von Gluck IV if [ ! -d "$BASE" ]; then 224e5d446fcSAlexander von Gluck IV return 1; 225e5d446fcSAlexander von Gluck IV fi 226e5d446fcSAlexander von Gluck IV if [ -f "$BASE/bin/$TRIPLET-gcc" ]; then 227e5d446fcSAlexander von Gluck IV return 0; 228e5d446fcSAlexander von Gluck IV fi 229e5d446fcSAlexander von Gluck IV # TODO: Check this! 230e5d446fcSAlexander von Gluck IV if [ -f "$BASE/bin/$TRIPLET-clang" ]; then 231e5d446fcSAlexander von Gluck IV return 0; 232e5d446fcSAlexander von Gluck IV fi 233e5d446fcSAlexander von Gluck IV return 1; 234e5d446fcSAlexander von Gluck IV} 235e5d446fcSAlexander von Gluck IV 23609c5682dSIngo Weinhold# standard_gcc_settings 23709c5682dSIngo Weinhold# 23809c5682dSIngo Weinhold# Sets the variables for a GCC platform. 23909c5682dSIngo Weinhold# 24009c5682dSIngo Weinholdstandard_gcc_settings() 24109c5682dSIngo Weinhold{ 24265706842SAugustin Cavalier local gcc="$1" 243c0e8cc1aSIngo Weinhold 244138f5fb4SIngo Weinhold if which greadlink > /dev/null 2>&1; then 245b29b48b1SMatt Madia readlink="greadlink -e" 246138f5fb4SIngo Weinhold elif which realpath > /dev/null 2>&1; then 247b29b48b1SMatt Madia readlink=realpath 2489a001156SOliver Tappe elif readlink -e / > /dev/null 2>&1; then 249b29b48b1SMatt Madia readlink="readlink -e" 2509a001156SOliver Tappe else 2519a001156SOliver Tappe readlink=real_path 252b4b6d83cSMatt Madia fi 253138f5fb4SIngo Weinhold 25409c5682dSIngo Weinhold # PLATFORM_LINKLIBS 255c0e8cc1aSIngo Weinhold local gcclib=`$gcc -print-libgcc-file-name` 256c0e8cc1aSIngo Weinhold local gccdir=`dirname ${gcclib}` 2575b0f7b1bSOliver Tappe 258c0e8cc1aSIngo Weinhold local gccRawVersion=`$gcc -dumpversion` 259c0e8cc1aSIngo Weinhold local gccMachine=`$gcc -dumpmachine` 260338b8dc3SIngo Weinhold 261fc8967f1SIngo Weinhold # determine architecture from machine triple 262c0e8cc1aSIngo Weinhold case $gccMachine in 263c0e8cc1aSIngo Weinhold arm-*) targetCpu=arm;; 264c0e8cc1aSIngo Weinhold i?86-*) targetCpu=x86;; 265c0e8cc1aSIngo Weinhold m68k-*) targetCpu=m68k;; 266c0e8cc1aSIngo Weinhold powerpc-*) targetCpu=ppc;; 267c0e8cc1aSIngo Weinhold x86_64-*) targetCpu=x86_64;; 268fc8967f1SIngo Weinhold *) 269c0e8cc1aSIngo Weinhold echo "Unsupported gcc target machine: $gccMachine" >&2 270fc8967f1SIngo Weinhold exit 1 271fc8967f1SIngo Weinhold ;; 272fc8967f1SIngo Weinhold esac 273fc8967f1SIngo Weinhold 274c0e8cc1aSIngo Weinhold local targetArch=$targetCpu 275fc8967f1SIngo Weinhold 276c0e8cc1aSIngo Weinhold case $gccRawVersion in 2776cc8eecfSOliver Tappe 2.9*) 2785b0f7b1bSOliver Tappe # check for correct (most up-to-date) legacy compiler and complain 2795b0f7b1bSOliver Tappe # if an older one is installed 280c0e8cc1aSIngo Weinhold if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then 2815b0f7b1bSOliver Tappe echo "GCC version $haikuRequiredLegacyGCCVersion is required!"; 2825b0f7b1bSOliver Tappe echo "Please download it from www.haiku-os.org..."; 2835b0f7b1bSOliver Tappe exit 1; 2845b0f7b1bSOliver Tappe fi 285aaeadfcbSAlex Smith 286c0e8cc1aSIngo Weinhold targetArch=x86_gcc2 2875b0f7b1bSOliver Tappe ;; 2888b5934c9SIngo Weinhold esac 28965ad1ba3SAlex Smith 290c0e8cc1aSIngo Weinhold local bootLibgcc 291c0e8cc1aSIngo Weinhold local bootLibSupCxx 29266a7f29fSJérôme Duval local bootCxxHeaders 293c0e8cc1aSIngo Weinhold case $gccMachine in 2944591ebc9SAlex Smith x86_64-*) 29566a7f29fSJérôme Duval # Boot loader is 32-bit, need the 32-bit libs and c++ config 29611ae3c5fSOliver Tappe bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` 297c0e8cc1aSIngo Weinhold bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` 29866a7f29fSJérôme Duval 29966a7f29fSJérôme Duval local headersBase=$gccdir/../../../.. 30066a7f29fSJérôme Duval local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion 30166a7f29fSJérôme Duval if [ ! -d $headers ]; then 30266a7f29fSJérôme Duval headers=$headersBase/include/c++/$gccRawVersion 30366a7f29fSJérôme Duval fi 30466a7f29fSJérôme Duval bootCxxHeaders="$headers/$gccMachine/32" 3054591ebc9SAlex Smith ;; 306338b8dc3SIngo Weinhold esac 307c0e8cc1aSIngo Weinhold 308c0e8cc1aSIngo Weinhold # determine whether graphite loop optimization should/can be used 309c0e8cc1aSIngo Weinhold local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu` 310c0e8cc1aSIngo Weinhold if [ -z "$useGraphite" ]; then 311c0e8cc1aSIngo Weinhold useGraphite=$useGccGraphiteDefault 312c0e8cc1aSIngo Weinhold fi 313c0e8cc1aSIngo Weinhold 314c0e8cc1aSIngo Weinhold if [ "$useGraphite" != 0 ]; then 315c0e8cc1aSIngo Weinhold UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1` 316c0e8cc1aSIngo Weinhold if [ $? != 0 ]; then 317c0e8cc1aSIngo Weinhold echo "GCC Graphite loop optimizations cannot be used on $targetArch" 318c0e8cc1aSIngo Weinhold useGraphite=0 319c0e8cc1aSIngo Weinhold fi 320c0e8cc1aSIngo Weinhold fi 321c0e8cc1aSIngo Weinhold 322c0e8cc1aSIngo Weinhold set_variable HAIKU_CPU_$targetArch $targetCpu 323c0e8cc1aSIngo Weinhold 324c0e8cc1aSIngo Weinhold get_build_tool_path CC_$targetArch "$gcc" 325a7bddff1SJonathan Schleifer set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang 326c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion 327c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine 328c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir 32966a7f29fSJérôme Duval set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" 33011ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" 33111ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc 332c0e8cc1aSIngo Weinhold set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite 333c0e8cc1aSIngo Weinhold 334c0e8cc1aSIngo Weinhold standard_gcc_settings_targetArch=$targetArch 335c0e8cc1aSIngo Weinhold} 336c0e8cc1aSIngo Weinhold 337c0e8cc1aSIngo Weinhold# set_variable 338c0e8cc1aSIngo Weinhold# 339c0e8cc1aSIngo Weinhold# Set the value of a variable. 340c0e8cc1aSIngo Weinhold# 341c0e8cc1aSIngo Weinholdset_variable() 342c0e8cc1aSIngo Weinhold{ 343c0e8cc1aSIngo Weinhold eval "$1=\"$2\"" 344c0e8cc1aSIngo Weinhold} 345c0e8cc1aSIngo Weinhold 346c0e8cc1aSIngo Weinhold# get_variable 347c0e8cc1aSIngo Weinhold# 348c0e8cc1aSIngo Weinhold# Echo the value of a variable. 349c0e8cc1aSIngo Weinhold# 350c0e8cc1aSIngo Weinholdget_variable() 351c0e8cc1aSIngo Weinhold{ 352c0e8cc1aSIngo Weinhold eval "echo \${$1}" 35309c5682dSIngo Weinhold} 35409c5682dSIngo Weinhold 355338b8dc3SIngo Weinhold# set_default_value 356338b8dc3SIngo Weinhold# 357338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 358338b8dc3SIngo Weinhold# 359338b8dc3SIngo Weinholdset_default_value() 360338b8dc3SIngo Weinhold{ 3610838a930SJérôme Duval eval "$1=\${$1-$2}" 362338b8dc3SIngo Weinhold} 363338b8dc3SIngo Weinhold 364338b8dc3SIngo Weinhold# get_build_tool_path 365338b8dc3SIngo Weinhold# 366338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 367338b8dc3SIngo Weinhold# 368338b8dc3SIngo Weinholdget_build_tool_path() 369338b8dc3SIngo Weinhold{ 370338b8dc3SIngo Weinhold local var="HAIKU_$1" 37165706842SAugustin Cavalier local varval="`get_variable $var`" 37265706842SAugustin Cavalier local cmd="$2" 373d73993ffSAugustin Cavalier 374e042a53bSAugustin Cavalier if [ ! -z "$varval" ]; then 375d73993ffSAugustin Cavalier # this variable is already set (probably by user) so grab its contents 376e042a53bSAugustin Cavalier cmd=$varval 377d73993ffSAugustin Cavalier fi 378d73993ffSAugustin Cavalier 379d73993ffSAugustin Cavalier local path=${cmd%% *} 380338b8dc3SIngo Weinhold 381338b8dc3SIngo Weinhold if [ -f "$path" ]; then 38265706842SAugustin Cavalier # get absolute path from relative path 383a559f87aSFrançois Revol local oldPwd="`pwd`" 384a559f87aSFrançois Revol cd "`dirname "$path"`" 385a559f87aSFrançois Revol path="`pwd`/`basename "$path"`" 386338b8dc3SIngo Weinhold cd $oldPwd 387338b8dc3SIngo Weinhold else 3887fe2e06cSMatt Madia which "$path" > /dev/null 2>&1 || { 389d73993ffSAugustin Cavalier echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2 390338b8dc3SIngo Weinhold exit 1 391338b8dc3SIngo Weinhold } 392338b8dc3SIngo Weinhold fi 393338b8dc3SIngo Weinhold 39465706842SAugustin Cavalier if test "${cmd#* }" != "$cmd"; then 39565706842SAugustin Cavalier # $cmd contains arguments, so preserve them (and only them) 39665706842SAugustin Cavalier cmd=${cmd#* } 39765706842SAugustin Cavalier else 39865706842SAugustin Cavalier # $cmd does not contain arguments, so unset it 39965706842SAugustin Cavalier cmd= 40065706842SAugustin Cavalier fi 40165706842SAugustin Cavalier eval "$var=\"$path $cmd\"" 402338b8dc3SIngo Weinhold} 403338b8dc3SIngo Weinhold 404a5c952dbSAugustin Cavalier# check_native_xattrs 405a5c952dbSAugustin Cavalier# 406a5c952dbSAugustin Cavalier# Checks the host platform's support for extended attributes. 407a5c952dbSAugustin Cavalier# 0: no support, 1: only enough for xattr-ref, 2: full support 408a5c952dbSAugustin Cavalier# 409a5c952dbSAugustin Cavaliercheck_native_xattrs() 410a5c952dbSAugustin Cavalier{ 411a5c952dbSAugustin Cavalier local xattr_set= 412a5c952dbSAugustin Cavalier local xattr_set_args= 413a5c952dbSAugustin Cavalier local xattr_get= 414a5c952dbSAugustin Cavalier local xattr_get_args= 415a5c952dbSAugustin Cavalier case $HOST_PLATFORM in 416503ef6d4SAugustin Cavalier haiku_host) 417503ef6d4SAugustin Cavalier xattr_set="addattr"; xattr_set_args="\$NAME \"\$VALUE\"" 418503ef6d4SAugustin Cavalier xattr_get="catattr"; xattr_get_args="\$NAME" 419503ef6d4SAugustin Cavalier ;; 420a5c952dbSAugustin Cavalier darwin) 421a5c952dbSAugustin Cavalier xattr_set="xattr"; xattr_set_args="-w \$NAME \"\$VALUE\"" 422a5c952dbSAugustin Cavalier xattr_get="xattr"; xattr_get_args="-p \$NAME" 423a5c952dbSAugustin Cavalier ;; 424a5c952dbSAugustin Cavalier freebsd) 425a5c952dbSAugustin Cavalier xattr_set="setextattr"; xattr_set_args="user \$NAME \"\$VALUE\"" 426a5c952dbSAugustin Cavalier xattr_get="getextattr"; xattr_get_args="user \$NAME" 427a5c952dbSAugustin Cavalier ;; 428a5c952dbSAugustin Cavalier linux) 429a5c952dbSAugustin Cavalier xattr_set="setfattr"; xattr_set_args="-n user.\$NAME -v \"\$VALUE\"" 430a5c952dbSAugustin Cavalier xattr_get="getfattr"; xattr_get_args="-n user.\$NAME" 431a5c952dbSAugustin Cavalier ;; 432a5c952dbSAugustin Cavalier *) 433a5c952dbSAugustin Cavalier return 0 434a5c952dbSAugustin Cavalier ;; 435a5c952dbSAugustin Cavalier esac 436a5c952dbSAugustin Cavalier if ! type $xattr_set >/dev/null 2>&1; then 437a5c952dbSAugustin Cavalier echo "$0: could not find $xattr_set, assuming host has no extended attributes" 438a5c952dbSAugustin Cavalier return 0 439a5c952dbSAugustin Cavalier elif ! type $xattr_get >/dev/null 2>&1; then 440a5c952dbSAugustin Cavalier echo "$0: could not find $xattr_get, assuming host has no extended attributes" 441a5c952dbSAugustin Cavalier return 0 442a5c952dbSAugustin Cavalier fi 443a5c952dbSAugustin Cavalier 444*43f5f35aSAugustin Cavalier mkdir -p "$outputDir" 445a5c952dbSAugustin Cavalier echo "xattr test file" >"$outputDir/xattrtest" 446a5c952dbSAugustin Cavalier local i=0 447a5c952dbSAugustin Cavalier # on round 0, we test if we can set 3 attrs of 1K each (enough for xattr-ref) 448a5c952dbSAugustin Cavalier # on round 1, we test if we can set 3 attrs of 45K each (enough for full xattr) 449a5c952dbSAugustin Cavalier while [ $i -lt 2 ]; do 450a5c952dbSAugustin Cavalier local j=0 451a5c952dbSAugustin Cavalier while [ $j -lt 3 ]; do 452a5c952dbSAugustin Cavalier NAME=attr$j 453a5c952dbSAugustin Cavalier VALUE=`printf '%*s' $((1024 + $i * 45056)) "" | tr ' ' x` 454a5c952dbSAugustin Cavalier if [ `echo -n $VALUE | wc -c` -lt $((1024 + $i * 45056)) ]; then 455a5c952dbSAugustin Cavalier echo "$0: warning: could not generate test data for extended attributes" 456a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 457a5c952dbSAugustin Cavalier return $i 458a5c952dbSAugustin Cavalier elif ! $xattr_set `eval echo \"$xattr_set_args\"` \ 459a5c952dbSAugustin Cavalier "$outputDir/xattrtest" >/dev/null 2>&1 ; then 460a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 461a5c952dbSAugustin Cavalier return $i 462a5c952dbSAugustin Cavalier fi 463a5c952dbSAugustin Cavalier j=$((j+1)) 464a5c952dbSAugustin Cavalier done 465a5c952dbSAugustin Cavalier i=$((i+1)) 466a5c952dbSAugustin Cavalier done 467a5c952dbSAugustin Cavalier rm "$outputDir/xattrtest" 468a5c952dbSAugustin Cavalier return 2 469a5c952dbSAugustin Cavalier} 470a5c952dbSAugustin Cavalier 471483b28e4SIngo Weinholdis_in_list() 472483b28e4SIngo Weinhold{ 473483b28e4SIngo Weinhold local element 474483b28e4SIngo Weinhold for element in $2; do 475483b28e4SIngo Weinhold if [ "$1" = "$element" ]; then 476483b28e4SIngo Weinhold return 0 477483b28e4SIngo Weinhold fi 478483b28e4SIngo Weinhold done 479483b28e4SIngo Weinhold return 1 480483b28e4SIngo Weinhold} 481483b28e4SIngo Weinhold 4827f9beaf1SOliver Tappe# check for --help or -h and show usage immediately 4837f9beaf1SOliver Tappeif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then 4848b420c2fSOliver Tappe usage; exit 0; 4858b420c2fSOliver Tappefi 4868b420c2fSOliver Tappe 487c6c03d56SAugustin Cavalier# ensure umask is not too restrictive 488c6c03d56SAugustin Cavalierif [ $(umask) -gt 22 ]; then 489c6c03d56SAugustin Cavalier echo "Your umask is too restrictive (should be: <= 0022; is actually:" $(umask)")" 490c6c03d56SAugustin Cavalier exit 1 491c6c03d56SAugustin Cavalierfi 4928b420c2fSOliver Tappe 493338b8dc3SIngo Weinhold# get cwd and the source directory 494338b8dc3SIngo WeinholdcurrentDir=`pwd` 4956e7c6fe5SIngo Weinholdcd `dirname "$0"` 496338b8dc3SIngo WeinholdsourceDir=`pwd` 4976e7c6fe5SIngo Weinholdcd "$currentDir" 498338b8dc3SIngo Weinhold 49955d267a4SFrançois Revol# backup the passed arguments 50055d267a4SFrançois RevolconfigureArgs="$@" 501825700d3SAugustin CavalierconfigurePath=$0 502825700d3SAugustin Cavalier 503825700d3SAugustin Cavalier# backup relevant environs 504825700d3SAugustin CavalierconfigureEnvirons= 505825700d3SAugustin Cavalierfor var in `env`; do 506825700d3SAugustin Cavalier case "$var" in 507825700d3SAugustin Cavalier CC\=*|HAIKU*\=*) 508825700d3SAugustin Cavalier configureEnvirons="$configureEnvirons $var" 509825700d3SAugustin Cavalier ;; 510825700d3SAugustin Cavalier esac 511825700d3SAugustin Cavalierdone 51255d267a4SFrançois Revol 5137c4641d0SOliver Tappe# internal default parameter values 514022fa244SIngo Weinhold# 51552a38012Sejakowatzplatform=`uname` 5165abd9a46SIngo WeinholdplatformMachine=`uname -m` 517c0e8cc1aSIngo WeinholdtargetArchs= 518338b8dc3SIngo WeinholdbuildCrossTools= 51929ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" 52060d8d8fcSIngo WeinholdbuildCrossToolsJobs= 521c2b76f7fSJonathan SchleiferuseClang=0 522c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0 523c0e8cc1aSIngo WeinholdunknownArchIndex=1 524483b28e4SIngo WeinholdhaikuTargetArchs= 5254da6cf84SFrançois RevolgdbSources= 5267c4641d0SOliver Tappe 52763701e7dSOliver Tappeif [ -z "$CC" ]; then 52863701e7dSOliver Tappe CC=gcc 52963701e7dSOliver Tappefi 53063701e7dSOliver Tappe 5317c4641d0SOliver Tappe# exported (BuildSetup) default parameter values 5327c4641d0SOliver Tappe# 53363701e7dSOliver TappeHOST_GCC_RAW_VERSION=`$CC -dumpversion` 53463701e7dSOliver TappeHOST_GCC_MACHINE=`$CC -dumpmachine` 5357c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0 53676fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0 5377c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0 5387c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default 5397c4641d0SOliver TappeTARGET_PLATFORM=haiku 5407c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0 5417986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0 542fc2c93fbSAugustin CavalierHAIKU_HOST_USE_XATTR= 543fc2c93fbSAugustin CavalierHAIKU_HOST_USE_XATTR_REF= 5442ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0 545f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r" 54663701e7dSOliver TappeHOST_GCC_LD=`$CC -print-prog-name=ld` 54763701e7dSOliver TappeHOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy` 5482a5d0aafSIngo WeinholdHOST_SHA256= 549e173a1ecSIngo WeinholdHOST_HAIKU_PORTER= 550e173a1ecSIngo WeinholdHAIKU_PORTS= 551e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS= 552c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP=0 553e70c4c64SPulkoMandyHAIKU_BOOT_BOARD= 554aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0 5552a5d0aafSIngo Weinhold 556c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS= 557c0e8cc1aSIngo Weinhold 558a04a520bSJonathan Schleiferset_default_value HAIKU_NASM nasm 559c0e8cc1aSIngo Weinhold 5603942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then 5612a5d0aafSIngo Weinhold HOST_SHA256=sha256sum 5623942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then 5632a5d0aafSIngo Weinhold HOST_SHA256="sha256 -q" 564b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then 565b5a871b1SNiels Sascha Reedijk HOST_SHA256="shasum -a 256" 5662a5d0aafSIngo Weinholdelse 5672a5d0aafSIngo Weinhold echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2 5682a5d0aafSIngo Weinhold exit 1 5692a5d0aafSIngo Weinholdfi 570338b8dc3SIngo Weinhold 57184edb1a1SAxel DörflerhaikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20" 572a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion 573af4bf973SOliver Tappe # version of legacy gcc required to build haiku 574483b28e4SIngo WeinholdsupportedTargetArchs=" 575483b28e4SIngo Weinhold arm 576483b28e4SIngo Weinhold m68k 577483b28e4SIngo Weinhold ppc 578483b28e4SIngo Weinhold x86 579483b28e4SIngo Weinhold x86_64 580483b28e4SIngo Weinhold x86_gcc2 581483b28e4SIngo Weinhold " 582af4bf973SOliver Tappe 5837c4641d0SOliver Tappe# determine output directory 5847c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then 5857c4641d0SOliver Tappe outputDir=$currentDir/generated 5867c4641d0SOliver Tappeelse 5877c4641d0SOliver Tappe outputDir=$currentDir 5887c4641d0SOliver Tappefi 5897c4641d0SOliver TappebuildOutputDir="$outputDir/build" 5907c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes" 5917c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig" 5927c4641d0SOliver Tappe 5937c4641d0SOliver Tappe# check for update request 5947c4641d0SOliver Tappeif [ "$1" = "--update" ]; then 5957c4641d0SOliver Tappe if ! [ -e "$buildConfigFile" ]; then 5967c4641d0SOliver Tappe echo $0 --update: \'$buildConfigFile\' not found - updating not possible. 5977c4641d0SOliver Tappe exit 1 5987c4641d0SOliver Tappe fi 599825700d3SAugustin Cavalier # get last configure invocation and flags from BuildConfig and call ourselves with it 600825700d3SAugustin Cavalier lastPwd=`grep "#d " "$buildConfigFile" | cut -c 4-` 601825700d3SAugustin Cavalier lastConfig=`grep "#c " "$buildConfigFile" | cut -c 4-` 602825700d3SAugustin Cavalier lastEnv=`grep "#e " "$buildConfigFile" | cut -c 4-` 603825700d3SAugustin Cavalier lastArgs=`grep "#a " "$buildConfigFile" | cut -c 4-` 604825700d3SAugustin Cavalier if [ -z "$lastConfig" ]; then 605825700d3SAugustin Cavalier echo "$0 --update: The previous configure invocation was not properly" \ 606825700d3SAugustin Cavalier "encoded into '$buildConfigFile' - updating not possible." 6077c4641d0SOliver Tappe exit 1 6087c4641d0SOliver Tappe fi 609825700d3SAugustin Cavalier cd $lastPwd 610fc2c93fbSAugustin Cavalier if [ -n "$lastEnv" ]; then 611825700d3SAugustin Cavalier export $lastEnv 612fc2c93fbSAugustin Cavalier fi 613825700d3SAugustin Cavalier $lastConfig $lastArgs 614825700d3SAugustin Cavalier exit $? 6157c4641d0SOliver Tappefi 6167c4641d0SOliver Tappe 617022fa244SIngo Weinhold# parse parameters 618022fa244SIngo Weinhold# 61920ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do 620022fa244SIngo Weinhold case "$1" in 621e173a1ecSIngo Weinhold --bootstrap) 622e173a1ecSIngo Weinhold assertparams "$1" 3 $# 623e173a1ecSIngo Weinhold HOST_HAIKU_PORTER="`absolute_path $2`" 624e173a1ecSIngo Weinhold HAIKU_PORTS_CROSS="`absolute_path $3`" 625e173a1ecSIngo Weinhold HAIKU_PORTS="`absolute_path $4`" 626c9dd05ffSJonathan Schleifer HAIKU_IS_BOOTSTRAP=1 627c9dd05ffSJonathan Schleifer HAIKU_NO_DOWNLOADS=1 628502882dbSJessica Hamilton check_file_exists "$HOST_HAIKU_PORTER" || ( 629502882dbSJessica Hamilton echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2 63039d444a3SArvind S Raj exit 1 63139d444a3SArvind S Raj ) 63239d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS" || ( 63339d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS" >&2 63439d444a3SArvind S Raj exit 1 63539d444a3SArvind S Raj ) 63639d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS_CROSS" || ( 63739d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2 63839d444a3SArvind S Raj exit 1 63939d444a3SArvind S Raj ) 640e173a1ecSIngo Weinhold shift 4 641e173a1ecSIngo Weinhold ;; 642c0e8cc1aSIngo Weinhold --build-cross-tools) 643c0e8cc1aSIngo Weinhold if [ -z "$buildCrossTools" ]; then 6449b0dd528SIngo Weinhold assertparams "$1" 2 $# 645c0e8cc1aSIngo Weinhold targetArch=$2 6469b0dd528SIngo Weinhold buildCrossTools=$3 6479b0dd528SIngo Weinhold shift 3 648c0e8cc1aSIngo Weinhold else 649c0e8cc1aSIngo Weinhold assertparam "$1" $# 650c0e8cc1aSIngo Weinhold targetArch=$2 651c0e8cc1aSIngo Weinhold shift 2 652c0e8cc1aSIngo Weinhold fi 653c0e8cc1aSIngo Weinhold case "$targetArch" in 654c0e8cc1aSIngo Weinhold x86_gcc2) targetMachine=i586-pc-haiku;; 655c0e8cc1aSIngo Weinhold x86) targetMachine=i586-pc-haiku;; 656c0e8cc1aSIngo Weinhold x86_64) targetMachine=x86_64-unknown-haiku;; 657c0e8cc1aSIngo Weinhold ppc) targetMachine=powerpc-apple-haiku;; 658c0e8cc1aSIngo Weinhold m68k) targetMachine=m68k-unknown-haiku;; 659c0e8cc1aSIngo Weinhold arm) targetMachine=arm-unknown-haiku;; 660c0e8cc1aSIngo Weinhold *) 661c0e8cc1aSIngo Weinhold echo "Unsupported target architecture: $2" >&2 662c0e8cc1aSIngo Weinhold exit 1 663c0e8cc1aSIngo Weinhold ;; 664c0e8cc1aSIngo Weinhold esac 665c0e8cc1aSIngo Weinhold set_variable buildCrossToolsMachine_$targetArch $targetMachine 666c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 667c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 6689b0dd528SIngo Weinhold ;; 6699b0dd528SIngo Weinhold --cross-tools-prefix) 6709b0dd528SIngo Weinhold assertparam "$1" $# 671c0e8cc1aSIngo Weinhold targetArch=unknown${unknownArchIndex} 672c0e8cc1aSIngo Weinhold set_variable crossToolsPrefix_$targetArch "$2" 673c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 674c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 675d68208faSMatt Madia unknownArchIndex=$(($unknownArchIndex + 1)) 6769b0dd528SIngo Weinhold shift 2 6779b0dd528SIngo Weinhold ;; 678a66c32ddSIngo Weinhold --distro-compatibility) 6799b0dd528SIngo Weinhold assertparam "$1" $# 6807c4641d0SOliver Tappe HAIKU_DISTRO_COMPATIBILITY=$2 6817c4641d0SOliver Tappe case "$HAIKU_DISTRO_COMPATIBILITY" in 682a66c32ddSIngo Weinhold official) ;; 683a66c32ddSIngo Weinhold compatible) ;; 684a66c32ddSIngo Weinhold default) ;; 685a66c32ddSIngo Weinhold *) echo "Invalid distro compatibility" \ 6867c4641d0SOliver Tappe "level: $HAIKU_DISTRO_COMPATIBILITY" 687a66c32ddSIngo Weinhold exit 1;; 688a66c32ddSIngo Weinhold esac 6899b0dd528SIngo Weinhold shift 2 6909b0dd528SIngo Weinhold ;; 6912ebcd86dSIngo Weinhold --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;; 6927c4641d0SOliver Tappe --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;; 69376fa0be3SIngo Weinhold --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;; 6947c4641d0SOliver Tappe --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;; 69560d8d8fcSIngo Weinhold -j*) buildCrossToolsJobs="$1"; shift 1;; 696aa2e5ecaSOliver Tappe --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;; 697483b28e4SIngo Weinhold --target-arch) 698483b28e4SIngo Weinhold assertparam "$1" $# 699483b28e4SIngo Weinhold targetArch=$2 700483b28e4SIngo Weinhold shift 2 701483b28e4SIngo Weinhold if [ ! "$platform" = Haiku ]; then 702483b28e4SIngo Weinhold echo "--target-arch can only be specified on Haiku." >&2 703483b28e4SIngo Weinhold exit 1 704483b28e4SIngo Weinhold fi 705483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 706483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 707483b28e4SIngo Weinhold exit 1 708483b28e4SIngo Weinhold ) 709483b28e4SIngo Weinhold haikuTargetArchs="$haikuTargetArchs $targetArch" 710483b28e4SIngo Weinhold ;; 711d73993ffSAugustin Cavalier --use-clang) 712d73993ffSAugustin Cavalier assertparam "$1" $# 713d73993ffSAugustin Cavalier targetArch=$2 714d73993ffSAugustin Cavalier useClang=1 715d73993ffSAugustin Cavalier case "$targetArch" in 716d73993ffSAugustin Cavalier x86) targetMachine=i586-pc-haiku;; 717d73993ffSAugustin Cavalier x86_64) targetMachine=x86_64-unknown-haiku;; 718d73993ffSAugustin Cavalier *) 719d73993ffSAugustin Cavalier echo "Unsupported target architecture: $2" >&2 720d73993ffSAugustin Cavalier exit 1 721d73993ffSAugustin Cavalier ;; 722d73993ffSAugustin Cavalier esac 72365706842SAugustin Cavalier get_build_tool_path clang clang 72436f28382SAugustin Cavalier if [ -z `get_variable "crossToolsPrefix_$targetArch"` ] \ 72536f28382SAugustin Cavalier && [ -z `get_variable buildCrossToolsMachine_$targetArch` ]; then 72665706842SAugustin Cavalier set_variable crossToolsPrefix_$targetArch llvm- 72765706842SAugustin Cavalier fi 72836f28382SAugustin Cavalier if ! test "${targetArchs#*$targetArch}" != "$targetArchs"; then 72936f28382SAugustin Cavalier # we have not already added this arch to targetArchs, so add it now 730d73993ffSAugustin Cavalier targetArchs="$targetArchs $targetArch" 73136f28382SAugustin Cavalier fi 732d73993ffSAugustin Cavalier HAIKU_PACKAGING_ARCHS= 733d73993ffSAugustin Cavalier shift 2 734d73993ffSAugustin Cavalier ;; 7357c4641d0SOliver Tappe --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;; 736c0e8cc1aSIngo Weinhold --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;; 7377986925fSIngo Weinhold --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;; 738fc2c93fbSAugustin Cavalier --no-full-xattr)HAIKU_HOST_USE_XATTR=0; shift 1;; 739fc2c93fbSAugustin Cavalier --no-xattr) HAIKU_HOST_USE_XATTR_REF=0; shift 1;; 7404da6cf84SFrançois Revol --with-gdb) gdbSources=$2; shift 2;; 741022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 742022fa244SIngo Weinhold esac 743022fa244SIngo Weinholddone 744022fa244SIngo Weinhold 7450df3cc9cSIngo Weinhold# detect the build platform 746338b8dc3SIngo Weinholdcase "${platform}" in 7477c4641d0SOliver Tappe Darwin) HOST_PLATFORM=darwin ;; 7487c4641d0SOliver Tappe FreeBSD) HOST_PLATFORM=freebsd 7497986925fSIngo Weinhold if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then 7505abd9a46SIngo Weinhold echo Unsupported platform: FreeBSD ${platformMachine} 751308c212cSIngo Weinhold exit 1 752308c212cSIngo Weinhold fi ;; 7537c4641d0SOliver Tappe Haiku) HOST_PLATFORM=haiku_host ;; 7547c4641d0SOliver Tappe Linux) HOST_PLATFORM=linux ;; 7557c4641d0SOliver Tappe OpenBSD) HOST_PLATFORM=openbsd ;; 7567c4641d0SOliver Tappe SunOS) HOST_PLATFORM=sunos ;; 7577c4641d0SOliver Tappe CYGWIN_NT-*) HOST_PLATFORM=cygwin ;; 758338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 7594cbe4925SAxel Dörfler exit 1 ;; 7604cbe4925SAxel Dörfleresac 76152a38012Sejakowatz 7620962132cSAlex Smith# check for case-sensitive filesystem 7630962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null 7640962132cSAlex Smithmkdir haikucasetest 2>/dev/null 7650962132cSAlex SmithcaseInsensitive=$? 76697f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null 7670962132cSAlex Smithif [ $caseInsensitive != 0 ]; then 7683ecc5287SMichael Lotz echo "You need a case-sensitive file-system to build Haiku." 7690962132cSAlex Smith if [ $HOST_PLATFORM = "darwin" ]; then 7707a05e252SJohn Scipione echo "You can create a case-sensitive disk image using Disk Utility." 7713ecc5287SMichael Lotz fi 7720962132cSAlex Smith exit 1 7733ecc5287SMichael Lotzfi 7743ecc5287SMichael Lotz 775a5c952dbSAugustin Cavalier# check xattr support 776503ef6d4SAugustin Cavalierif [ -z $HAIKU_HOST_USE_XATTR_REF ]; then 777a5c952dbSAugustin Cavalier check_native_xattrs 778a5c952dbSAugustin Cavalier attrSupport=$? 779fc2c93fbSAugustin Cavalier if [ $attrSupport = 2 ] && [ -z $HAIKU_HOST_USE_XATTR ]; then 780fc2c93fbSAugustin Cavalier HAIKU_HOST_USE_XATTR=1 781a5c952dbSAugustin Cavalier elif [ $attrSupport = 1 ]; then 782fc2c93fbSAugustin Cavalier HAIKU_HOST_USE_XATTR_REF=1 783a5c952dbSAugustin Cavalier fi 784a5c952dbSAugustin Cavalierfi 785fc2c93fbSAugustin Cavalierif [ -z $HAIKU_HOST_USE_XATTR ]; then HAIKU_HOST_USE_XATTR=0; fi 786fc2c93fbSAugustin Cavalierif [ -z $HAIKU_HOST_USE_XATTR_REF ]; then HAIKU_HOST_USE_XATTR_REF=0; fi 787a5c952dbSAugustin Cavalier 788f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed 789f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then 790f04f7042SNiels Sascha Reedijk HOST_EXTENDED_REGEX_SED="sed -E" 791f04f7042SNiels Sascha Reedijkfi 792f04f7042SNiels Sascha Reedijk 793cb721c59SFrançois Revol# check if nasm can actually output ELF files 794cb721c59SFrançois Revol# (the stock version in OSX can't) 795cb721c59SFrançois Revol# XXX: should probably only test for x86* arch 7963e6c09cdSAdrien Destuguesif [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then 797cb721c59SFrançois Revol echo "$HAIKU_NASM cannot generate ELF files. Please install a working version." 798cb721c59SFrançois Revol if [ $HOST_PLATFORM = "darwin" ]; then 799cb721c59SFrançois Revol echo "You can install it from Mac Ports." 800cb721c59SFrançois Revol echo "Mac Ports is available at: http://www.macports.org/" 801cb721c59SFrançois Revol fi 802cb721c59SFrançois Revol exit 1 803cb721c59SFrançois Revolfi 804cb721c59SFrançois Revol 805338b8dc3SIngo Weinhold# create output directory 8066e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1 807338b8dc3SIngo Weinhold 8082ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then 8092ebcd86dSIngo Weinhold invalidCommand=$sourceDir/build/scripts/host_build_only 8102ebcd86dSIngo Weinhold HAIKU_AR=$invalidCommand 8112ebcd86dSIngo Weinhold HAIKU_CC=$invalidCommand 8122ebcd86dSIngo Weinhold HAIKU_LD=$invalidCommand 8132ebcd86dSIngo Weinhold HAIKU_OBJCOPY=$invalidCommand 8142ebcd86dSIngo Weinhold HAIKU_RANLIB=$invalidCommand 8152ebcd86dSIngo Weinhold HAIKU_ELFEDIT=$invalidCommand 816d6f80927SJonathan Schleifer HAIKU_NASM=$invalidCommand 8172ebcd86dSIngo Weinhold HAIKU_STRIP=$invalidCommand 8182ebcd86dSIngo Weinholdelse 819c0e8cc1aSIngo Weinhold if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then 820c0e8cc1aSIngo Weinhold targetArchs="$HAIKU_PACKAGING_ARCHS" 821c0e8cc1aSIngo Weinhold fi 822c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 823c0e8cc1aSIngo Weinhold 824483b28e4SIngo Weinhold # On Haiku determine target architectures and tools automatically. 825c0e8cc1aSIngo Weinhold if [ -z "$targetArchs" ]; then 826483b28e4SIngo Weinhold if [ $HOST_PLATFORM != haiku_host ]; then 827483b28e4SIngo Weinhold echo "Please specify the build tools to use or build (via" \ 828eaef83a9SJeroen Oortwijn "--cross-tools-prefix or --build-cross-tools) or specify a" \ 829483b28e4SIngo Weinhold "host-only build (--host-only)." >&2 8307f9beaf1SOliver Tappe echo "For more info, invoke $0 --help" 831483b28e4SIngo Weinhold exit 1 832483b28e4SIngo Weinhold fi 833483b28e4SIngo Weinhold 834483b28e4SIngo Weinhold # determine primary architecture 835dda53eaeSIngo Weinhold targetArch=`package list -i /system/packages/haiku-*.hpkg \ 836483b28e4SIngo Weinhold | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'` 837483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 838483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 839483b28e4SIngo Weinhold exit 1 840483b28e4SIngo Weinhold ) 841c0e8cc1aSIngo Weinhold targetArchs=$targetArch 842483b28e4SIngo Weinhold 843c0e8cc1aSIngo Weinhold set_default_value HAIKU_AR_$targetArch ar 844c0e8cc1aSIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc 845c0e8cc1aSIngo Weinhold set_default_value HAIKU_LD_$targetArch ld 846c0e8cc1aSIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy 847c0e8cc1aSIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib 848c0e8cc1aSIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit 849c0e8cc1aSIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip 850483b28e4SIngo Weinhold 851483b28e4SIngo Weinhold # determine secondary architectures 852483b28e4SIngo Weinhold for targetArch in $supportedTargetArchs; do 85380262a91SMatt Madia if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then 854483b28e4SIngo Weinhold targetArchs="$targetArchs $targetArch" 855483b28e4SIngo Weinhold set_default_value HAIKU_AR_$targetArch ar-$targetArch 856483b28e4SIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc-$targetArch 857483b28e4SIngo Weinhold set_default_value HAIKU_LD_$targetArch ld-$targetArch 858483b28e4SIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch 859483b28e4SIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch 860483b28e4SIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch 861483b28e4SIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip-$targetArch 862483b28e4SIngo Weinhold fi 863483b28e4SIngo Weinhold done 864483b28e4SIngo Weinhold 865483b28e4SIngo Weinhold # The target architectures might have been specified explicitly. 866483b28e4SIngo Weinhold if [ -n "$haikuTargetArchs" ]; then 867483b28e4SIngo Weinhold for targetArch in $haikuTargetArchs; do 868483b28e4SIngo Weinhold is_in_list "$targetArch" "$targetArchs" || ( 869483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"." \ 870483b28e4SIngo Weinhold "Only native architectures of the host platform can" \ 871483b28e4SIngo Weinhold "be specified." >&2 872483b28e4SIngo Weinhold exit 1 873483b28e4SIngo Weinhold ) 874483b28e4SIngo Weinhold done 875483b28e4SIngo Weinhold targetArchs="$haikuTargetArchs" 876483b28e4SIngo Weinhold fi 877c0e8cc1aSIngo Weinhold fi 878c0e8cc1aSIngo Weinhold 87968ccc989SIngo Weinhold isPrimaryArch=1 880c0e8cc1aSIngo Weinhold for targetArch in $targetArchs; do 881c0e8cc1aSIngo Weinhold # Note: targetArch is "unknown<n>" at this point, if a cross-tools 882c0e8cc1aSIngo Weinhold # prefix was specified. The standard_gcc_settings call below will get 883c0e8cc1aSIngo Weinhold # the actual architecture. 884c0e8cc1aSIngo Weinhold 885c0e8cc1aSIngo Weinhold crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch` 886c0e8cc1aSIngo Weinhold 887338b8dc3SIngo Weinhold # build cross tools from sources 888c0e8cc1aSIngo Weinhold if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then 889c0e8cc1aSIngo Weinhold crossToolsDir="$outputDir/cross-tools-$targetArch" 890c0e8cc1aSIngo Weinhold targetMachine=`get_variable buildCrossToolsMachine_$targetArch` 891c0e8cc1aSIngo Weinhold script="$buildCrossToolsScript" 8928304ec7cSIngo Weinhold scriptArgs= 893c0e8cc1aSIngo Weinhold if [ $targetArch != x86_gcc2 ]; then 8948304ec7cSIngo Weinhold script="${script}_gcc4" 8958304ec7cSIngo Weinhold scriptArgs="$targetMachine" 8961e93288eSJérôme Duval set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \ 8971e93288eSJérôme Duval $useGccGraphiteDefault 898c0e8cc1aSIngo Weinhold fi 89968ccc989SIngo Weinhold secondaryArch= 90068ccc989SIngo Weinhold if [ -z "$isPrimaryArch" ]; then 90168ccc989SIngo Weinhold secondaryArch=$targetArch 90268ccc989SIngo Weinhold fi 90386de8c37SIngo Weinhold 90486de8c37SIngo Weinhold case $HOST_PLATFORM in 90586de8c37SIngo Weinhold freebsd|openbsd) MAKE=gmake;; 90686de8c37SIngo Weinhold *) MAKE=make;; 90786de8c37SIngo Weinhold esac 90886de8c37SIngo Weinhold 909e5d446fcSAlexander von Gluck IV if ! valid_toolchain "${targetMachine}" "${crossToolsDir}"; then 91086de8c37SIngo Weinhold MAKE=$MAKE \ 91168ccc989SIngo Weinhold SECONDARY_ARCH=$secondaryArch \ 912c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE=`get_variable \ 913c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE_$targetArch` \ 914b3ece905SJérôme Duval HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \ 9154da6cf84SFrançois Revol HAIKU_USE_GDB="$gdbSources" \ 9168304ec7cSIngo Weinhold "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \ 9178304ec7cSIngo Weinhold "$crossToolsDir" $buildCrossToolsJobs || exit 1 918825700d3SAugustin Cavalier else 919825700d3SAugustin Cavalier echo "$targetArch crosstools already exist in $crossToolsDir; skipping build" 920825700d3SAugustin Cavalier fi 921c0e8cc1aSIngo Weinhold crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-" 922338b8dc3SIngo Weinhold fi 923338b8dc3SIngo Weinhold 924c0e8cc1aSIngo Weinhold # prepare gcc settings and get the actual target architecture 925a7bddff1SJonathan Schleifer if [ $useClang = 1 ]; then 92665706842SAugustin Cavalier gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as" 9271f6fe055SAugustin Cavalier 9281f6fe055SAugustin Cavalier # Clang's compiler intrinsics are not compatible with GCC's or even 9291f6fe055SAugustin Cavalier # across versions of Clang, so we must collect them for use in the build. 9301f6fe055SAugustin Cavalier mkdir -p "$outputDir/clang_headers" || exit 1 9311f6fe055SAugustin Cavalier clangHeadersDir=`$gcc -print-resource-dir`/include/ 9321f6fe055SAugustin Cavalier cp $clangHeadersDir/*intrin* $clangHeadersDir/mm3* "$outputDir/clang_headers" || exit 1 933d73993ffSAugustin Cavalier elif [ -z "${crossToolsPrefix}" ]; then 934d73993ffSAugustin Cavalier gcc=`get_variable HAIKU_CC_$targetArch` 935a7bddff1SJonathan Schleifer else 936c0e8cc1aSIngo Weinhold gcc="${crossToolsPrefix}gcc" 937a7bddff1SJonathan Schleifer fi 938c0e8cc1aSIngo Weinhold standard_gcc_settings "$gcc" 939c0e8cc1aSIngo Weinhold targetArch=$standard_gcc_settings_targetArch 940338b8dc3SIngo Weinhold 941c0e8cc1aSIngo Weinhold # set default values for flags 942c0e8cc1aSIngo Weinhold set_default_value HAIKU_CPPFLAGS_$targetArch "" 943c0e8cc1aSIngo Weinhold set_default_value HAIKU_CCFLAGS_$targetArch "" 944c0e8cc1aSIngo Weinhold set_default_value HAIKU_CXXFLAGS_$targetArch "" 945c0e8cc1aSIngo Weinhold set_default_value HAIKU_LDFLAGS_$targetArch "" 946c0e8cc1aSIngo Weinhold set_default_value HAIKU_ARFLAGS_$targetArch cru 947c0e8cc1aSIngo Weinhold set_default_value HAIKU_UNARFLAGS_$targetArch x 948338b8dc3SIngo Weinhold 949c0e8cc1aSIngo Weinhold # Override the cross tools variables, if the tools were built or a 950c0e8cc1aSIngo Weinhold # prefix was specified. 951b7777272SAlex Smith if [ -n "$crossToolsPrefix" ]; then 952c0e8cc1aSIngo Weinhold get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar 953c0e8cc1aSIngo Weinhold get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld 954c0e8cc1aSIngo Weinhold get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy 955c0e8cc1aSIngo Weinhold get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib 956c0e8cc1aSIngo Weinhold get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip 957c0e8cc1aSIngo Weinhold 958c0e8cc1aSIngo Weinhold case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in 959133e4131SJérôme Duval 4.*|5.*|6.*|7.*|8.*) 960c0e8cc1aSIngo Weinhold get_build_tool_path ELFEDIT_$targetArch \ 961c0e8cc1aSIngo Weinhold ${crossToolsPrefix}elfedit 962bd16f0ddSAlex Smith ;; 963bd16f0ddSAlex Smith esac 96452a38012Sejakowatz fi 96552a38012Sejakowatz 966ef57df3dSIngo Weinhold # check whether the Haiku compiler really targets Haiku 967c0e8cc1aSIngo Weinhold targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` 968c0e8cc1aSIngo Weinhold case "$targetMachine" in 969eedc3d0bSIngo Weinhold *-*-haiku) ;; 970c0e8cc1aSIngo Weinhold *) 971c0e8cc1aSIngo Weinhold echo The compiler specified as Haiku target compiler is not a \ 972c0e8cc1aSIngo Weinhold valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2 973eedc3d0bSIngo Weinhold echo compiler: $HAIKU_CC 974c0e8cc1aSIngo Weinhold echo compiler is configured for target: $targetMachine 975eedc3d0bSIngo Weinhold exit 1 ;; 976eedc3d0bSIngo Weinhold esac 977c0e8cc1aSIngo Weinhold 978c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch" 97968ccc989SIngo Weinhold isPrimaryArch= 980c0e8cc1aSIngo Weinhold done 9812ebcd86dSIngo Weinholdfi 982eedc3d0bSIngo Weinhold 98352a38012Sejakowatz# Generate BuildConfig 9847c4641d0SOliver Tappecat << EOF > "$buildConfigFile" 985825700d3SAugustin Cavalier# -- WARNING -- 986825700d3SAugustin Cavalier# This file was AUTOMATICALLY GENERATED by configure, and will be completely 987825700d3SAugustin Cavalier# overwritten the next time configure is run. 988825700d3SAugustin Cavalier# 989825700d3SAugustin Cavalier#d ${currentDir} 990825700d3SAugustin Cavalier#c ${configurePath} 991825700d3SAugustin Cavalier#e ${configureEnvirons} 992825700d3SAugustin Cavalier#a ${configureArgs} 99352a38012Sejakowatz 9947c4641d0SOliver TappeTARGET_PLATFORM ?= "${TARGET_PLATFORM}" ; 9957c4641d0SOliver TappeHOST_PLATFORM ?= "${HOST_PLATFORM}" ; 996338b8dc3SIngo Weinhold 9977c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ; 99876fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ; 9997c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ; 10007c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ; 10017c4641d0SOliver TappeHAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ; 10027986925fSIngo WeinholdHAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ; 10037986925fSIngo WeinholdHAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ; 1004bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ; 10052ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ; 1006eccc7665SIngo Weinhold 1007c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ; 100865ad1ba3SAlex Smith 1009aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ; 1010aa2e5ecaSOliver Tappe 10117c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ; 1012338b8dc3SIngo Weinhold 1013d6f80927SJonathan SchleiferHAIKU_NASM ?= ${HAIKU_NASM} ; 1014e70c4c64SPulkoMandyHAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ; 1015338b8dc3SIngo Weinhold 1016f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ; 10177c4641d0SOliver TappeHOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ; 10187c4641d0SOliver TappeHOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ; 10197c4641d0SOliver TappeHOST_LD ?= ${HOST_GCC_LD} ; 10207c4641d0SOliver TappeHOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ; 10212a5d0aafSIngo WeinholdHOST_SHA256 ?= ${HOST_SHA256} ; 10228b5934c9SIngo Weinhold 1023e173a1ecSIngo WeinholdHOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ; 1024e173a1ecSIngo WeinholdHAIKU_PORTS ?= ${HAIKU_PORTS} ; 1025e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ; 1026c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ; 1027e173a1ecSIngo Weinhold 1028c4786ea6SlilloEOF 1029c4786ea6Slillo 1030c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do 1031c0e8cc1aSIngo Weinhold variables=" 1032c0e8cc1aSIngo Weinhold HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION 1033c0e8cc1aSIngo Weinhold HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE 1034c0e8cc1aSIngo Weinhold HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR 1035c0e8cc1aSIngo Weinhold HAIKU_CPU HAIKU_CPU 1036c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC 1037c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX 1038c0e8cc1aSIngo Weinhold HAIKU_AR HAIKU_AR 1039c0e8cc1aSIngo Weinhold HAIKU_CC HAIKU_CC 1040c2b76f7fSJonathan Schleifer HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG 1041c0e8cc1aSIngo Weinhold HAIKU_LD HAIKU_LD 1042c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY HAIKU_OBJCOPY 1043c0e8cc1aSIngo Weinhold HAIKU_RANLIB HAIKU_RANLIB 1044c0e8cc1aSIngo Weinhold HAIKU_ELFEDIT HAIKU_ELFEDIT 1045c0e8cc1aSIngo Weinhold HAIKU_STRIP HAIKU_STRIP 1046c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS HAIKU_CPPFLAGS 1047c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS HAIKU_CCFLAGS 1048c0e8cc1aSIngo Weinhold HAIKU_C++FLAGS HAIKU_CXXFLAGS 1049c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS HAIKU_LDFLAGS 1050c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS HAIKU_ARFLAGS 1051c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS HAIKU_UNARFLAGS 1052c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE 1053c0e8cc1aSIngo Weinhold " 1054c0e8cc1aSIngo Weinhold set -- $variables 1055c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 1056c0e8cc1aSIngo Weinhold value=`get_variable ${2}_$targetArch` 1057c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile" 1058c0e8cc1aSIngo Weinhold shift 2 1059c0e8cc1aSIngo Weinhold done 1060b1e5b60cSAxel Dörfler 1061c0e8cc1aSIngo Weinhold # For variables that may have long values, distribute them over multiple 1062c0e8cc1aSIngo Weinhold # lines so that jam doesn't hit the maximum line length. 1063c0e8cc1aSIngo Weinhold variables=" 106466a7f29fSJérôme Duval HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR 1065c0e8cc1aSIngo Weinhold " 1066c0e8cc1aSIngo Weinhold set -- $variables 1067c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 1068c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= " >> "$buildConfigFile" 1069c0e8cc1aSIngo Weinhold get_variable ${2}_$targetArch | xargs -n 1 echo " " \ 1070c0e8cc1aSIngo Weinhold >> "$buildConfigFile" 1071c0e8cc1aSIngo Weinhold echo " ;" >> "$buildConfigFile" 1072c0e8cc1aSIngo Weinhold shift 2 1073c0e8cc1aSIngo Weinhold done 1074c0e8cc1aSIngo Weinholddone 1075b1e5b60cSAxel Dörfler 1076b1e5b60cSAxel Dörfler 10779b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory. 1078338b8dc3SIngo Weinhold 1079338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 1080338b8dc3SIngo Weinhold# automatically generated Jamfile 1081338b8dc3SIngo Weinhold 1082338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 1083338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 1084338b8dc3SIngo Weinhold 1085338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 1086338b8dc3SIngo Weinhold 1087338b8dc3SIngo WeinholdEOF 1088d73993ffSAugustin Cavalier 1089d73993ffSAugustin Cavalierecho "Configured successfully!" 1090