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: 15e173a1ecSIngo Weinhold --bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo> 16e173a1ecSIngo Weinhold Prepare for a bootstrap build. No pre-built 17e173a1ecSIngo Weinhold packages will be used, instead they will be built 18e173a1ecSIngo Weinhold from the sources (in several phases). 19e173a1ecSIngo Weinhold <haikuporter> is the path to the haikuporter tool 20e173a1ecSIngo Weinhold suitable for the host platform. 21e173a1ecSIngo Weinhold <HaikuPorts cross repo> is the path to a checked 22e173a1ecSIngo Weinhold out HaikuPorts cross-compilation repository. 23e173a1ecSIngo Weinhold <HaikuPorts repo> is the path to a checked out 24e173a1ecSIngo Weinhold HaikuPorts repository. 25c0e8cc1aSIngo Weinhold --build-cross-tools <arch> [ <build tools dir> ] 26338b8dc3SIngo Weinhold Assume cross compilation. <build tools dir> 27338b8dc3SIngo Weinhold defines the location of the build tools sources. 28338b8dc3SIngo Weinhold They will be compiled and placed in the output 29a5b60fa8SOliver Tappe directory under "cross-tools". The HAIKU_* tools 30a5b60fa8SOliver Tappe variables will be set accordingly. 3120ab75e6SIngo Weinhold <arch> specifies the target architecture, either 321b38c341SAlexander von Gluck IV "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm" 33c0e8cc1aSIngo Weinhold This option and --cross-tools-prefix can be 34c0e8cc1aSIngo Weinhold specified multiple times. The first cross tools 35c0e8cc1aSIngo Weinhold specify the primary tools, the subsequent ones the 36c0e8cc1aSIngo Weinhold secondary tools (for "hybrid" images). 37c0e8cc1aSIngo Weinhold For the first --build-cross-tools the 38c0e8cc1aSIngo Weinhold <build tools dir> argument must be specified and 39c0e8cc1aSIngo Weinhold for the subsequent ones it must be omitted. 40eccc7665SIngo Weinhold --cross-tools-prefix <prefix> 41eccc7665SIngo Weinhold Assume cross compilation. <prefix> should be a 42eccc7665SIngo Weinhold path to the directory where the cross 43eccc7665SIngo Weinhold compilation tools are located, plus the platform 440da9c208SIngo Weinhold prefix, e.g. "/path/to/tools/i586-pc-haiku-". 45eccc7665SIngo Weinhold This overrides the HAIKU_* tool variables. 46a66c32ddSIngo Weinhold --distro-compatibility <level> 47a66c32ddSIngo Weinhold The distribution's level of compatibility with 48a66c32ddSIngo Weinhold the official Haiku distribution. The generated 49a66c32ddSIngo Weinhold files will contain the respective trademarks 50a66c32ddSIngo Weinhold accordingly. 51a66c32ddSIngo Weinhold official -- the official Haiku distribution. 52a66c32ddSIngo Weinhold compatible -- a Haiku Compatible (tm) distro. 53a66c32ddSIngo Weinhold default -- any other distro (default value). 5460d8d8fcSIngo Weinhold --enable-multiuser Enable experimental multiuser support. 55eccc7665SIngo Weinhold --help Prints out this help. 562ebcd86dSIngo Weinhold --host-only Configure for building tools for the build host 572ebcd86dSIngo Weinhold only. Haiku cannot be built when configured like 582ebcd86dSIngo Weinhold this. 59eccc7665SIngo Weinhold --include-gpl-addons Include GPL licensed add-ons. 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 6467838392SAxel Dörfler option only disables 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}] 77ea74aafdSJeroen Oortwijn valid targets=r5,bone,dano,haiku,host 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. 86e70c4c64SPulkoMandy --target-board <board> ARM only: Specify the board to build for. Must be 879c5e234cSAlexander von Gluck IV one of beagle,rpi1,rpi2,cubieboard4,verdex,overo. 88961fc581SFrançois Revol --update re-runs last configure invocation [must be given 897c4641d0SOliver Tappe as first option!] 90c2b76f7fSJonathan Schleifer --use-clang Build with host Clang instead of GCC cross 91c2b76f7fSJonathan Schleifer compiler 92eccc7665SIngo Weinhold --use-gcc-pipe Build with GCC option -pipe. Speeds up the build 935a34a443SFrançois Revol process, but uses more memory. 94ed38d2efSJerome Duval --use-gcc-graphite Build with GCC Graphite engine for loop 95ed38d2efSJerome Duval optimizations. Only for gcc 4. 960385b065SIngo Weinhold --use-32bit Use -m32 flag on 64bit host gcc compiler. 97bc96e8f3SIngo Weinhold --use-xattr Use Linux xattr respectively *BSD extattr support 98bc96e8f3SIngo Weinhold for BeOS attribute emulation. Warning: Make sure 99bc96e8f3SIngo Weinhold your file system supports sufficient attribute 100bc96e8f3SIngo Weinhold sizes (4 KB per file for all attributes won't 101bc96e8f3SIngo Weinhold suffice). 102bc96e8f3SIngo Weinhold --use-xattr-ref Use the generic BeOS attribute emulation, but use 103bc96e8f3SIngo Weinhold Linux xattr respectively *BSD extattr support to 104bc96e8f3SIngo Weinhold make it more robust (i.e. attribute mix-ups become 105bc96e8f3SIngo Weinhold less likely). 106*4da6cf84SFrançois Revol --with-gdb <gdb sources dir> 107*4da6cf84SFrançois Revol specify the path to a GDB source dir, to build 108*4da6cf84SFrançois Revol GDB for each arch we build the cross-tools for. 109338b8dc3SIngo Weinhold 110338b8dc3SIngo Weinholdenvironment variables: 11163701e7dSOliver Tappe CC The host compiler. Defaults to "gcc". 112c0e8cc1aSIngo Weinhold HAIKU_AR_x86_gcc2 The static library archiver for x86_gcc2. 113c0e8cc1aSIngo Weinhold Defaults to "ar". 114c0e8cc1aSIngo Weinhold HAIKU_CC_x86_gcc2 The x86_gcc2 compiler. Defaults to "gcc". 115c0e8cc1aSIngo Weinhold HAIKU_LD_x86_gcc2 The x86_gcc2 linker. Defaults to "ld". 116c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY_x86_gcc2 The x86_gcc2 objcopy to be used. Defaults to 117c0e8cc1aSIngo Weinhold "objcopy". 118c0e8cc1aSIngo Weinhold HAIKU_RANLIB_x86_gcc2 The static library indexer for x86_gcc2. Defaults 119c0e8cc1aSIngo Weinhold to "ranlib". 120c0e8cc1aSIngo Weinhold HAIKU_STRIP_x86_gcc2 The x86_gcc2 strip command. Defaults to "strip". 121a04a520bSJonathan Schleifer HAIKU_NASM The nasm assembler (x86 and x86_64 only). 122c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture 123c0e8cc1aSIngo Weinhold <arch>. Defaults to "". 124c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>. 125c0e8cc1aSIngo Weinhold Defaults to "". 126c0e8cc1aSIngo Weinhold HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>. 127c0e8cc1aSIngo Weinhold Defaults to "". 128c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>. 129c0e8cc1aSIngo Weinhold Defaults to "". 130c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target 131c0e8cc1aSIngo Weinhold architecture <arch> for archiving. Defaults to 132c0e8cc1aSIngo Weinhold "cru". 133c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target 134c0e8cc1aSIngo Weinhold architecture <arch> for unarchiving. Defaults to 135c0e8cc1aSIngo Weinhold "x". 13664f6da31SIngo Weinhold 137c0e8cc1aSIngo WeinholdNon-default output directories: 13864f6da31SIngo Weinhold By default all objects, build configuration, and other related files are 13964f6da31SIngo Weinhold stored in /path/to/haiku_source/generated. To store objects in a non-default 14064f6da31SIngo Weinhold location, run "../../relative/path/to/haiku_source/configure <options>" from 14164f6da31SIngo Weinhold within your non-default location. "jam [ options ] targets" can then be run 14264f6da31SIngo Weinhold directly inside your non-default location. Another option is to invoke "jam 14364f6da31SIngo Weinhold [ options ] targets" from within haiku_source. This can be accomplished by 14464f6da31SIngo Weinhold either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking 14564f6da31SIngo Weinhold jam or by creating a symlink of haiku_source/generated pointing to your 14664f6da31SIngo Weinhold non-default location and running jam. 14764f6da31SIngo Weinhold 14864f6da31SIngo Weinhold 149022fa244SIngo WeinholdEOF 150022fa244SIngo Weinhold} 151022fa244SIngo Weinhold 152022fa244SIngo Weinhold# assertparam 153022fa244SIngo Weinhold# 154022fa244SIngo Weinhold# Checks whether at least one parameter is left. 155022fa244SIngo Weinhold# 156022fa244SIngo Weinholdassertparam() 157022fa244SIngo Weinhold{ 15820ab75e6SIngo Weinhold if [ $2 -lt 2 ]; then 159022fa244SIngo Weinhold echo $0: \`$1\': Parameter expected. 160022fa244SIngo Weinhold exit 1 161022fa244SIngo Weinhold fi 162022fa244SIngo Weinhold} 163022fa244SIngo Weinhold 16420ab75e6SIngo Weinhold# assertparams 16520ab75e6SIngo Weinhold# 16620ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left. 16720ab75e6SIngo Weinhold# 16820ab75e6SIngo Weinholdassertparams() 16920ab75e6SIngo Weinhold{ 17020ab75e6SIngo Weinhold if [ $3 -le $2 ]; then 17120ab75e6SIngo Weinhold echo $0: \`$1\': Not enough parameters. 17220ab75e6SIngo Weinhold exit 1 17320ab75e6SIngo Weinhold fi 17420ab75e6SIngo Weinhold} 17520ab75e6SIngo Weinhold 176e173a1ecSIngo Weinhold# absolute_path 177e173a1ecSIngo Weinhold# 178e173a1ecSIngo Weinhold# returns the absolute path of a given path. 179e173a1ecSIngo Weinhold# 180e173a1ecSIngo Weinholdabsolute_path() 181e173a1ecSIngo Weinhold{ 1826a4f3954SFrançois Revol if [ "x$1" != "x${1#/}" ]; then 183e173a1ecSIngo Weinhold echo "$1" 184e173a1ecSIngo Weinhold else 185e173a1ecSIngo Weinhold echo "`pwd`/$1" 186e173a1ecSIngo Weinhold fi 187e173a1ecSIngo Weinhold} 188e173a1ecSIngo Weinhold 18939d444a3SArvind S Raj# check_dir_exists 19039d444a3SArvind S Raj# 19139d444a3SArvind S Raj# check if a directory exists or not 19239d444a3SArvind S Raj# 19339d444a3SArvind S Rajcheck_dir_exists() 19439d444a3SArvind S Raj{ 19539d444a3SArvind S Raj if [ -d "$1" ]; then 19639d444a3SArvind S Raj return 0 19739d444a3SArvind S Raj else 19839d444a3SArvind S Raj return 1 19939d444a3SArvind S Raj fi 20039d444a3SArvind S Raj} 20139d444a3SArvind S Raj 202502882dbSJessica Hamilton# check_file_exists 203502882dbSJessica Hamilton# 204502882dbSJessica Hamilton# check if a file exists or not 205502882dbSJessica Hamilton# 206502882dbSJessica Hamiltoncheck_file_exists() 207502882dbSJessica Hamilton{ 208502882dbSJessica Hamilton if [ -f "$1" ]; then 209502882dbSJessica Hamilton return 0 210502882dbSJessica Hamilton else 211502882dbSJessica Hamilton return 1 212502882dbSJessica Hamilton fi 213502882dbSJessica Hamilton} 214502882dbSJessica Hamilton 2159a001156SOliver Tappe# real_path 2169a001156SOliver Tappe# 2179a001156SOliver Tappe# returns the realpath of a symbolic link. 2189a001156SOliver Tappe# 2199a001156SOliver Tappereal_path() 2209a001156SOliver Tappe{ 2219a001156SOliver Tappe perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1" 2229a001156SOliver Tappe} 2239a001156SOliver Tappe 22409c5682dSIngo Weinhold# standard_gcc_settings 22509c5682dSIngo Weinhold# 22609c5682dSIngo Weinhold# Sets the variables for a GCC platform. 22709c5682dSIngo Weinhold# 22809c5682dSIngo Weinholdstandard_gcc_settings() 22909c5682dSIngo Weinhold{ 230c0e8cc1aSIngo Weinhold local gcc=$1 231c0e8cc1aSIngo Weinhold 232138f5fb4SIngo Weinhold if which greadlink > /dev/null 2>&1; then 233b29b48b1SMatt Madia readlink="greadlink -e" 234138f5fb4SIngo Weinhold elif which realpath > /dev/null 2>&1; then 235b29b48b1SMatt Madia readlink=realpath 2369a001156SOliver Tappe elif readlink -e / > /dev/null 2>&1; then 237b29b48b1SMatt Madia readlink="readlink -e" 2389a001156SOliver Tappe else 2399a001156SOliver Tappe readlink=real_path 240b4b6d83cSMatt Madia fi 241138f5fb4SIngo Weinhold 24209c5682dSIngo Weinhold # PLATFORM_LINKLIBS 243c0e8cc1aSIngo Weinhold local gcclib=`$gcc -print-libgcc-file-name` 244c0e8cc1aSIngo Weinhold local gccdir=`dirname ${gcclib}` 2455b0f7b1bSOliver Tappe 246c0e8cc1aSIngo Weinhold local gccRawVersion=`$gcc -dumpversion` 247c0e8cc1aSIngo Weinhold local gccMachine=`$gcc -dumpmachine` 248338b8dc3SIngo Weinhold 249fc8967f1SIngo Weinhold # determine architecture from machine triple 250c0e8cc1aSIngo Weinhold case $gccMachine in 251c0e8cc1aSIngo Weinhold arm-*) targetCpu=arm;; 252c0e8cc1aSIngo Weinhold i?86-*) targetCpu=x86;; 253c0e8cc1aSIngo Weinhold m68k-*) targetCpu=m68k;; 254c0e8cc1aSIngo Weinhold powerpc-*) targetCpu=ppc;; 255c0e8cc1aSIngo Weinhold x86_64-*) targetCpu=x86_64;; 256fc8967f1SIngo Weinhold *) 257c0e8cc1aSIngo Weinhold echo "Unsupported gcc target machine: $gccMachine" >&2 258fc8967f1SIngo Weinhold exit 1 259fc8967f1SIngo Weinhold ;; 260fc8967f1SIngo Weinhold esac 261fc8967f1SIngo Weinhold 262c0e8cc1aSIngo Weinhold local targetArch=$targetCpu 263fc8967f1SIngo Weinhold 264c0e8cc1aSIngo Weinhold case $gccRawVersion in 2656cc8eecfSOliver Tappe 2.9*) 2665b0f7b1bSOliver Tappe # check for correct (most up-to-date) legacy compiler and complain 2675b0f7b1bSOliver Tappe # if an older one is installed 268c0e8cc1aSIngo Weinhold if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then 2695b0f7b1bSOliver Tappe echo "GCC version $haikuRequiredLegacyGCCVersion is required!"; 2705b0f7b1bSOliver Tappe echo "Please download it from www.haiku-os.org..."; 2715b0f7b1bSOliver Tappe exit 1; 2725b0f7b1bSOliver Tappe fi 273aaeadfcbSAlex Smith 274c0e8cc1aSIngo Weinhold targetArch=x86_gcc2 2755b0f7b1bSOliver Tappe ;; 2768b5934c9SIngo Weinhold esac 27765ad1ba3SAlex Smith 278c0e8cc1aSIngo Weinhold local bootLibgcc 279c0e8cc1aSIngo Weinhold local bootLibSupCxx 28066a7f29fSJérôme Duval local bootCxxHeaders 281c0e8cc1aSIngo Weinhold case $gccMachine in 2824591ebc9SAlex Smith x86_64-*) 28366a7f29fSJérôme Duval # Boot loader is 32-bit, need the 32-bit libs and c++ config 28411ae3c5fSOliver Tappe bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` 285c0e8cc1aSIngo Weinhold bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` 28666a7f29fSJérôme Duval 28766a7f29fSJérôme Duval local headersBase=$gccdir/../../../.. 28866a7f29fSJérôme Duval local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion 28966a7f29fSJérôme Duval if [ ! -d $headers ]; then 29066a7f29fSJérôme Duval headers=$headersBase/include/c++/$gccRawVersion 29166a7f29fSJérôme Duval fi 29266a7f29fSJérôme Duval bootCxxHeaders="$headers/$gccMachine/32" 2934591ebc9SAlex Smith ;; 294338b8dc3SIngo Weinhold esac 295c0e8cc1aSIngo Weinhold 296c0e8cc1aSIngo Weinhold # determine whether graphite loop optimization should/can be used 297c0e8cc1aSIngo Weinhold local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu` 298c0e8cc1aSIngo Weinhold if [ -z "$useGraphite" ]; then 299c0e8cc1aSIngo Weinhold useGraphite=$useGccGraphiteDefault 300c0e8cc1aSIngo Weinhold fi 301c0e8cc1aSIngo Weinhold 302c0e8cc1aSIngo Weinhold if [ "$useGraphite" != 0 ]; then 303c0e8cc1aSIngo Weinhold UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1` 304c0e8cc1aSIngo Weinhold if [ $? != 0 ]; then 305c0e8cc1aSIngo Weinhold echo "GCC Graphite loop optimizations cannot be used on $targetArch" 306c0e8cc1aSIngo Weinhold useGraphite=0 307c0e8cc1aSIngo Weinhold fi 308c0e8cc1aSIngo Weinhold fi 309c0e8cc1aSIngo Weinhold 310c0e8cc1aSIngo Weinhold set_variable HAIKU_CPU_$targetArch $targetCpu 311c0e8cc1aSIngo Weinhold 312c0e8cc1aSIngo Weinhold get_build_tool_path CC_$targetArch "$gcc" 313a7bddff1SJonathan Schleifer set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang 314c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion 315c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine 316c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir 31766a7f29fSJérôme Duval set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" 31811ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" 31911ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc 320c0e8cc1aSIngo Weinhold set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite 321c0e8cc1aSIngo Weinhold 322c0e8cc1aSIngo Weinhold standard_gcc_settings_targetArch=$targetArch 323c0e8cc1aSIngo Weinhold} 324c0e8cc1aSIngo Weinhold 325c0e8cc1aSIngo Weinhold# set_variable 326c0e8cc1aSIngo Weinhold# 327c0e8cc1aSIngo Weinhold# Set the value of a variable. 328c0e8cc1aSIngo Weinhold# 329c0e8cc1aSIngo Weinholdset_variable() 330c0e8cc1aSIngo Weinhold{ 331c0e8cc1aSIngo Weinhold eval "$1=\"$2\"" 332c0e8cc1aSIngo Weinhold} 333c0e8cc1aSIngo Weinhold 334c0e8cc1aSIngo Weinhold# get_variable 335c0e8cc1aSIngo Weinhold# 336c0e8cc1aSIngo Weinhold# Echo the value of a variable. 337c0e8cc1aSIngo Weinhold# 338c0e8cc1aSIngo Weinholdget_variable() 339c0e8cc1aSIngo Weinhold{ 340c0e8cc1aSIngo Weinhold eval "echo \${$1}" 34109c5682dSIngo Weinhold} 34209c5682dSIngo Weinhold 343338b8dc3SIngo Weinhold# set_default_value 344338b8dc3SIngo Weinhold# 345338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 346338b8dc3SIngo Weinhold# 347338b8dc3SIngo Weinholdset_default_value() 348338b8dc3SIngo Weinhold{ 3490838a930SJérôme Duval eval "$1=\${$1-$2}" 350338b8dc3SIngo Weinhold} 351338b8dc3SIngo Weinhold 352338b8dc3SIngo Weinhold# get_build_tool_path 353338b8dc3SIngo Weinhold# 354338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 355338b8dc3SIngo Weinhold# 356338b8dc3SIngo Weinholdget_build_tool_path() 357338b8dc3SIngo Weinhold{ 358338b8dc3SIngo Weinhold local var="HAIKU_$1" 359a7bddff1SJonathan Schleifer local cmd=$2 360a7bddff1SJonathan Schleifer local path=${2%% *} 361338b8dc3SIngo Weinhold 362338b8dc3SIngo Weinhold if [ -f "$path" ]; then 363338b8dc3SIngo Weinhold # get absolute path 364a559f87aSFrançois Revol local oldPwd="`pwd`" 365a559f87aSFrançois Revol cd "`dirname "$path"`" 366a559f87aSFrançois Revol path="`pwd`/`basename "$path"`" 367338b8dc3SIngo Weinhold cd $oldPwd 368338b8dc3SIngo Weinhold else 3697fe2e06cSMatt Madia which "$path" > /dev/null 2>&1 || { 370338b8dc3SIngo Weinhold echo "Build tool \"$path\" not found." >&2 371338b8dc3SIngo Weinhold exit 1 372338b8dc3SIngo Weinhold } 373338b8dc3SIngo Weinhold fi 374338b8dc3SIngo Weinhold 375a7bddff1SJonathan Schleifer eval "$var=\"$path ${cmd#${2%% *}}\"" 376338b8dc3SIngo Weinhold} 377338b8dc3SIngo Weinhold 378483b28e4SIngo Weinholdis_in_list() 379483b28e4SIngo Weinhold{ 380483b28e4SIngo Weinhold local element 381483b28e4SIngo Weinhold for element in $2; do 382483b28e4SIngo Weinhold if [ "$1" = "$element" ]; then 383483b28e4SIngo Weinhold return 0 384483b28e4SIngo Weinhold fi 385483b28e4SIngo Weinhold done 386483b28e4SIngo Weinhold return 1 387483b28e4SIngo Weinhold} 388483b28e4SIngo Weinhold 3897f9beaf1SOliver Tappe# check for --help or -h and show usage immediately 3907f9beaf1SOliver Tappeif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then 3918b420c2fSOliver Tappe usage; exit 0; 3928b420c2fSOliver Tappefi 3938b420c2fSOliver Tappe 3948b420c2fSOliver Tappe 395338b8dc3SIngo Weinhold# get cwd and the source directory 396338b8dc3SIngo WeinholdcurrentDir=`pwd` 3976e7c6fe5SIngo Weinholdcd `dirname "$0"` 398338b8dc3SIngo WeinholdsourceDir=`pwd` 3996e7c6fe5SIngo Weinholdcd "$currentDir" 400338b8dc3SIngo Weinhold 40155d267a4SFrançois Revol# backup the passed arguments 40255d267a4SFrançois RevolconfigureArgs="$@" 40355d267a4SFrançois Revol 4047c4641d0SOliver Tappe# internal default parameter values 405022fa244SIngo Weinhold# 40652a38012Sejakowatzplatform=`uname` 4075abd9a46SIngo WeinholdplatformMachine=`uname -m` 408c0e8cc1aSIngo WeinholdtargetArchs= 409338b8dc3SIngo WeinholdbuildCrossTools= 41029ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" 41160d8d8fcSIngo WeinholdbuildCrossToolsJobs= 412c2b76f7fSJonathan SchleiferuseClang=0 413c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0 414c0e8cc1aSIngo WeinholdunknownArchIndex=1 415483b28e4SIngo WeinholdhaikuTargetArchs= 416*4da6cf84SFrançois RevolgdbSources= 4177c4641d0SOliver Tappe 41863701e7dSOliver Tappeif [ -z "$CC" ]; then 41963701e7dSOliver Tappe CC=gcc 42063701e7dSOliver Tappefi 42163701e7dSOliver Tappe 4227c4641d0SOliver Tappe# exported (BuildSetup) default parameter values 4237c4641d0SOliver Tappe# 42463701e7dSOliver TappeHOST_GCC_RAW_VERSION=`$CC -dumpversion` 42563701e7dSOliver TappeHOST_GCC_MACHINE=`$CC -dumpmachine` 4267c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS=0 4277c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0 42876fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0 4297c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0 4307c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER=0 4317c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default 4327c4641d0SOliver TappeTARGET_PLATFORM=haiku 4337c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0 4347986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0 4357986925fSIngo WeinholdHAIKU_HOST_USE_XATTR=0 436bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF=0 4372ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0 438f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r" 43963701e7dSOliver TappeHOST_GCC_LD=`$CC -print-prog-name=ld` 44063701e7dSOliver TappeHOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy` 4412a5d0aafSIngo WeinholdHOST_SHA256= 442e173a1ecSIngo WeinholdHOST_HAIKU_PORTER= 443e173a1ecSIngo WeinholdHAIKU_PORTS= 444e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS= 445c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP=0 446e70c4c64SPulkoMandyHAIKU_BOOT_BOARD= 447aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0 4482a5d0aafSIngo Weinhold 449c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS= 450c0e8cc1aSIngo Weinhold 451a04a520bSJonathan Schleiferset_default_value HAIKU_NASM nasm 452c0e8cc1aSIngo Weinhold 4533942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then 4542a5d0aafSIngo Weinhold HOST_SHA256=sha256sum 4553942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then 4562a5d0aafSIngo Weinhold HOST_SHA256="sha256 -q" 457b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then 458b5a871b1SNiels Sascha Reedijk HOST_SHA256="shasum -a 256" 4592a5d0aafSIngo Weinholdelse 4602a5d0aafSIngo Weinhold echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2 4612a5d0aafSIngo Weinhold exit 1 4622a5d0aafSIngo Weinholdfi 463338b8dc3SIngo Weinhold 464410d94cfSOliver TappehaikuRequiredLegacyGCCVersion="2.95.3-haiku-2014_07_26" 465a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion 466af4bf973SOliver Tappe # version of legacy gcc required to build haiku 467483b28e4SIngo WeinholdsupportedTargetArchs=" 468483b28e4SIngo Weinhold arm 469483b28e4SIngo Weinhold m68k 470483b28e4SIngo Weinhold ppc 471483b28e4SIngo Weinhold x86 472483b28e4SIngo Weinhold x86_64 473483b28e4SIngo Weinhold x86_gcc2 474483b28e4SIngo Weinhold " 475e70c4c64SPulkoMandysupportedTargetBoards=" 476e70c4c64SPulkoMandy beagle 477427d40adSAlexander von Gluck IV rpi1 478427d40adSAlexander von Gluck IV rpi2 4799c5e234cSAlexander von Gluck IV cubieboard4 480e70c4c64SPulkoMandy verdex 48187236c4fSAlexander von Gluck IV overo 482e70c4c64SPulkoMandy " 483af4bf973SOliver Tappe 4847c4641d0SOliver Tappe# determine output directory 4857c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then 4867c4641d0SOliver Tappe outputDir=$currentDir/generated 4877c4641d0SOliver Tappeelse 4887c4641d0SOliver Tappe outputDir=$currentDir 4897c4641d0SOliver Tappefi 4907c4641d0SOliver TappebuildOutputDir="$outputDir/build" 4917c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes" 4927c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig" 4937c4641d0SOliver Tappe 4947c4641d0SOliver Tappe# check for update request 4957c4641d0SOliver Tappeif [ "$1" = "--update" ]; then 4967c4641d0SOliver Tappe if ! [ -e "$buildConfigFile" ]; then 4977c4641d0SOliver Tappe echo $0 --update: \'$buildConfigFile\' not found - updating not possible. 4987c4641d0SOliver Tappe exit 1 4997c4641d0SOliver Tappe fi 5007c4641d0SOliver Tappe if ! type perl >/dev/null 2>&1; then 5017c4641d0SOliver Tappe echo $0 --update: \'perl\' not found - updating not possible. 5027c4641d0SOliver Tappe exit 1 5037c4641d0SOliver Tappe fi 5047c4641d0SOliver Tappe # convert BuildConfig from jam format to shell format and evaluate it 5057c4641d0SOliver Tappe shellConfigFile="${buildConfigFile}.shell" 5067c4641d0SOliver Tappe perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \ 5077c4641d0SOliver Tappe <"$buildConfigFile" >"$shellConfigFile" 5087c4641d0SOliver Tappe . "$shellConfigFile" 5097c4641d0SOliver Tappe rm "$shellConfigFile" 5107c4641d0SOliver Tappe shift 5117c4641d0SOliver Tappefi 5127c4641d0SOliver Tappe 513022fa244SIngo Weinhold# parse parameters 514022fa244SIngo Weinhold# 51520ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do 516022fa244SIngo Weinhold case "$1" in 517e173a1ecSIngo Weinhold --bootstrap) 518e173a1ecSIngo Weinhold assertparams "$1" 3 $# 519e173a1ecSIngo Weinhold HOST_HAIKU_PORTER="`absolute_path $2`" 520e173a1ecSIngo Weinhold HAIKU_PORTS_CROSS="`absolute_path $3`" 521e173a1ecSIngo Weinhold HAIKU_PORTS="`absolute_path $4`" 522c9dd05ffSJonathan Schleifer HAIKU_IS_BOOTSTRAP=1 523c9dd05ffSJonathan Schleifer HAIKU_NO_DOWNLOADS=1 524502882dbSJessica Hamilton check_file_exists "$HOST_HAIKU_PORTER" || ( 525502882dbSJessica Hamilton echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2 52639d444a3SArvind S Raj exit 1 52739d444a3SArvind S Raj ) 52839d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS" || ( 52939d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS" >&2 53039d444a3SArvind S Raj exit 1 53139d444a3SArvind S Raj ) 53239d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS_CROSS" || ( 53339d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2 53439d444a3SArvind S Raj exit 1 53539d444a3SArvind S Raj ) 536e173a1ecSIngo Weinhold shift 4 537e173a1ecSIngo Weinhold ;; 538c0e8cc1aSIngo Weinhold --build-cross-tools) 539c0e8cc1aSIngo Weinhold if [ -z "$buildCrossTools" ]; then 5409b0dd528SIngo Weinhold assertparams "$1" 2 $# 541c0e8cc1aSIngo Weinhold targetArch=$2 5429b0dd528SIngo Weinhold buildCrossTools=$3 5439b0dd528SIngo Weinhold shift 3 544c0e8cc1aSIngo Weinhold else 545c0e8cc1aSIngo Weinhold assertparam "$1" $# 546c0e8cc1aSIngo Weinhold targetArch=$2 547c0e8cc1aSIngo Weinhold shift 2 548c0e8cc1aSIngo Weinhold fi 549c0e8cc1aSIngo Weinhold case "$targetArch" in 550c0e8cc1aSIngo Weinhold x86_gcc2) targetMachine=i586-pc-haiku;; 551c0e8cc1aSIngo Weinhold x86) targetMachine=i586-pc-haiku;; 552c0e8cc1aSIngo Weinhold x86_64) targetMachine=x86_64-unknown-haiku;; 553c0e8cc1aSIngo Weinhold ppc) targetMachine=powerpc-apple-haiku;; 554c0e8cc1aSIngo Weinhold m68k) targetMachine=m68k-unknown-haiku;; 555c0e8cc1aSIngo Weinhold arm) targetMachine=arm-unknown-haiku;; 556c0e8cc1aSIngo Weinhold *) 557c0e8cc1aSIngo Weinhold echo "Unsupported target architecture: $2" >&2 558c0e8cc1aSIngo Weinhold exit 1 559c0e8cc1aSIngo Weinhold ;; 560c0e8cc1aSIngo Weinhold esac 561c0e8cc1aSIngo Weinhold set_variable buildCrossToolsMachine_$targetArch $targetMachine 562c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 563c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 5649b0dd528SIngo Weinhold ;; 5659b0dd528SIngo Weinhold --cross-tools-prefix) 5669b0dd528SIngo Weinhold assertparam "$1" $# 567c0e8cc1aSIngo Weinhold targetArch=unknown${unknownArchIndex} 568c0e8cc1aSIngo Weinhold set_variable crossToolsPrefix_$targetArch "$2" 569c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 570c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 571d68208faSMatt Madia unknownArchIndex=$(($unknownArchIndex + 1)) 5729b0dd528SIngo Weinhold shift 2 5739b0dd528SIngo Weinhold ;; 574a66c32ddSIngo Weinhold --distro-compatibility) 5759b0dd528SIngo Weinhold assertparam "$1" $# 5767c4641d0SOliver Tappe HAIKU_DISTRO_COMPATIBILITY=$2 5777c4641d0SOliver Tappe case "$HAIKU_DISTRO_COMPATIBILITY" in 578a66c32ddSIngo Weinhold official) ;; 579a66c32ddSIngo Weinhold compatible) ;; 580a66c32ddSIngo Weinhold default) ;; 581a66c32ddSIngo Weinhold *) echo "Invalid distro compatibility" \ 5827c4641d0SOliver Tappe "level: $HAIKU_DISTRO_COMPATIBILITY" 583a66c32ddSIngo Weinhold exit 1;; 584a66c32ddSIngo Weinhold esac 5859b0dd528SIngo Weinhold shift 2 5869b0dd528SIngo Weinhold ;; 5877c4641d0SOliver Tappe --enable-multiuser) HAIKU_ENABLE_MULTIUSER=1; shift 1;; 5882ebcd86dSIngo Weinhold --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;; 5897c4641d0SOliver Tappe --include-gpl-addons) HAIKU_INCLUDE_GPL_ADDONS=1; shift 1;; 5907c4641d0SOliver Tappe --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;; 59176fa0be3SIngo Weinhold --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;; 5927c4641d0SOliver Tappe --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;; 59360d8d8fcSIngo Weinhold -j*) buildCrossToolsJobs="$1"; shift 1;; 594aa2e5ecaSOliver Tappe --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;; 5957c4641d0SOliver Tappe --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;; 596483b28e4SIngo Weinhold --target-arch) 597483b28e4SIngo Weinhold assertparam "$1" $# 598483b28e4SIngo Weinhold targetArch=$2 599483b28e4SIngo Weinhold shift 2 600483b28e4SIngo Weinhold if [ ! "$platform" = Haiku ]; then 601483b28e4SIngo Weinhold echo "--target-arch can only be specified on Haiku." >&2 602483b28e4SIngo Weinhold exit 1 603483b28e4SIngo Weinhold fi 604483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 605483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 606483b28e4SIngo Weinhold exit 1 607483b28e4SIngo Weinhold ) 608483b28e4SIngo Weinhold haikuTargetArchs="$haikuTargetArchs $targetArch" 609483b28e4SIngo Weinhold ;; 610e70c4c64SPulkoMandy --target-board) 611e70c4c64SPulkoMandy assertparam "$1" $# 612e70c4c64SPulkoMandy HAIKU_BOOT_BOARD=$2 613e70c4c64SPulkoMandy is_in_list "$HAIKU_BOOT_BOARD" "$supportedTargetBoards" || ( 614e70c4c64SPulkoMandy echo "Unsupported target board: \"$HAIKU_BOOT_BOARD\"" >&2 615e70c4c64SPulkoMandy exit 1 616e70c4c64SPulkoMandy ) 617e70c4c64SPulkoMandy shift 2 618e70c4c64SPulkoMandy ;; 619c2b76f7fSJonathan Schleifer --use-clang) useClang=1; shift 1;; 6207c4641d0SOliver Tappe --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;; 621c0e8cc1aSIngo Weinhold --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;; 6227986925fSIngo Weinhold --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;; 6237986925fSIngo Weinhold --use-xattr) HAIKU_HOST_USE_XATTR=1; shift 1;; 624bc96e8f3SIngo Weinhold --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF=1; shift 1;; 625*4da6cf84SFrançois Revol --with-gdb) gdbSources=$2; shift 2;; 626022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 627022fa244SIngo Weinhold esac 628022fa244SIngo Weinholddone 629022fa244SIngo Weinhold 6300df3cc9cSIngo Weinhold# detect the build platform 631338b8dc3SIngo Weinholdcase "${platform}" in 6327c4641d0SOliver Tappe Darwin) HOST_PLATFORM=darwin ;; 6337c4641d0SOliver Tappe FreeBSD) HOST_PLATFORM=freebsd 6347986925fSIngo Weinhold if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then 6355abd9a46SIngo Weinhold echo Unsupported platform: FreeBSD ${platformMachine} 636308c212cSIngo Weinhold exit 1 637308c212cSIngo Weinhold fi ;; 6387c4641d0SOliver Tappe Haiku) HOST_PLATFORM=haiku_host ;; 6397c4641d0SOliver Tappe Linux) HOST_PLATFORM=linux ;; 6407c4641d0SOliver Tappe OpenBSD) HOST_PLATFORM=openbsd ;; 6417c4641d0SOliver Tappe SunOS) HOST_PLATFORM=sunos ;; 6427c4641d0SOliver Tappe CYGWIN_NT-*) HOST_PLATFORM=cygwin ;; 643338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 6444cbe4925SAxel Dörfler exit 1 ;; 6454cbe4925SAxel Dörfleresac 64652a38012Sejakowatz 6470962132cSAlex Smith# check for case-sensitive filesystem 6480962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null 6490962132cSAlex Smithmkdir haikucasetest 2>/dev/null 6500962132cSAlex SmithcaseInsensitive=$? 65197f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null 6520962132cSAlex Smithif [ $caseInsensitive != 0 ]; then 6533ecc5287SMichael Lotz echo "You need a case-sensitive file-system to build Haiku." 6540962132cSAlex Smith if [ $HOST_PLATFORM = "darwin" ]; then 6557a05e252SJohn Scipione echo "You can create a case-sensitive disk image using Disk Utility." 6563ecc5287SMichael Lotz fi 6570962132cSAlex Smith exit 1 6583ecc5287SMichael Lotzfi 6593ecc5287SMichael Lotz 660f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed 661f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then 662f04f7042SNiels Sascha Reedijk HOST_EXTENDED_REGEX_SED="sed -E" 663f04f7042SNiels Sascha Reedijkfi 664f04f7042SNiels Sascha Reedijk 665cb721c59SFrançois Revol# check if nasm can actually output ELF files 666cb721c59SFrançois Revol# (the stock version in OSX can't) 667cb721c59SFrançois Revol# XXX: should probably only test for x86* arch 6683e6c09cdSAdrien Destuguesif [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then 669cb721c59SFrançois Revol echo "$HAIKU_NASM cannot generate ELF files. Please install a working version." 670cb721c59SFrançois Revol if [ $HOST_PLATFORM = "darwin" ]; then 671cb721c59SFrançois Revol echo "You can install it from Mac Ports." 672cb721c59SFrançois Revol echo "Mac Ports is available at: http://www.macports.org/" 673cb721c59SFrançois Revol fi 674cb721c59SFrançois Revol exit 1 675cb721c59SFrançois Revolfi 676cb721c59SFrançois Revol 677338b8dc3SIngo Weinhold# create output directory 6786e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1 679338b8dc3SIngo Weinhold 6802ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then 6812ebcd86dSIngo Weinhold invalidCommand=$sourceDir/build/scripts/host_build_only 6822ebcd86dSIngo Weinhold HAIKU_AR=$invalidCommand 6832ebcd86dSIngo Weinhold HAIKU_CC=$invalidCommand 6842ebcd86dSIngo Weinhold HAIKU_LD=$invalidCommand 6852ebcd86dSIngo Weinhold HAIKU_OBJCOPY=$invalidCommand 6862ebcd86dSIngo Weinhold HAIKU_RANLIB=$invalidCommand 6872ebcd86dSIngo Weinhold HAIKU_ELFEDIT=$invalidCommand 688d6f80927SJonathan Schleifer HAIKU_NASM=$invalidCommand 6892ebcd86dSIngo Weinhold HAIKU_STRIP=$invalidCommand 6902ebcd86dSIngo Weinholdelse 691c0e8cc1aSIngo Weinhold if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then 692c0e8cc1aSIngo Weinhold targetArchs="$HAIKU_PACKAGING_ARCHS" 693c0e8cc1aSIngo Weinhold fi 694c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 695c0e8cc1aSIngo Weinhold 696483b28e4SIngo Weinhold # On Haiku determine target architectures and tools automatically. 697c0e8cc1aSIngo Weinhold if [ -z "$targetArchs" ]; then 698483b28e4SIngo Weinhold if [ $HOST_PLATFORM != haiku_host ]; then 699483b28e4SIngo Weinhold echo "Please specify the build tools to use or build (via" \ 700eaef83a9SJeroen Oortwijn "--cross-tools-prefix or --build-cross-tools) or specify a" \ 701483b28e4SIngo Weinhold "host-only build (--host-only)." >&2 7027f9beaf1SOliver Tappe echo "For more info, invoke $0 --help" 703483b28e4SIngo Weinhold exit 1 704483b28e4SIngo Weinhold fi 705483b28e4SIngo Weinhold 706483b28e4SIngo Weinhold # determine primary architecture 707dda53eaeSIngo Weinhold targetArch=`package list -i /system/packages/haiku-*.hpkg \ 708483b28e4SIngo Weinhold | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'` 709483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 710483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 711483b28e4SIngo Weinhold exit 1 712483b28e4SIngo Weinhold ) 713c0e8cc1aSIngo Weinhold targetArchs=$targetArch 714483b28e4SIngo Weinhold 715c0e8cc1aSIngo Weinhold set_default_value HAIKU_AR_$targetArch ar 716c0e8cc1aSIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc 717c0e8cc1aSIngo Weinhold set_default_value HAIKU_LD_$targetArch ld 718c0e8cc1aSIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy 719c0e8cc1aSIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib 720c0e8cc1aSIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit 721c0e8cc1aSIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip 722483b28e4SIngo Weinhold 723483b28e4SIngo Weinhold # determine secondary architectures 724483b28e4SIngo Weinhold for targetArch in $supportedTargetArchs; do 72580262a91SMatt Madia if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then 726483b28e4SIngo Weinhold targetArchs="$targetArchs $targetArch" 727483b28e4SIngo Weinhold set_default_value HAIKU_AR_$targetArch ar-$targetArch 728483b28e4SIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc-$targetArch 729483b28e4SIngo Weinhold set_default_value HAIKU_LD_$targetArch ld-$targetArch 730483b28e4SIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch 731483b28e4SIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch 732483b28e4SIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch 733483b28e4SIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip-$targetArch 734483b28e4SIngo Weinhold fi 735483b28e4SIngo Weinhold done 736483b28e4SIngo Weinhold 737483b28e4SIngo Weinhold # The target architectures might have been specified explicitly. 738483b28e4SIngo Weinhold if [ -n "$haikuTargetArchs" ]; then 739483b28e4SIngo Weinhold for targetArch in $haikuTargetArchs; do 740483b28e4SIngo Weinhold is_in_list "$targetArch" "$targetArchs" || ( 741483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"." \ 742483b28e4SIngo Weinhold "Only native architectures of the host platform can" \ 743483b28e4SIngo Weinhold "be specified." >&2 744483b28e4SIngo Weinhold exit 1 745483b28e4SIngo Weinhold ) 746483b28e4SIngo Weinhold done 747483b28e4SIngo Weinhold targetArchs="$haikuTargetArchs" 748483b28e4SIngo Weinhold fi 749c0e8cc1aSIngo Weinhold fi 750c0e8cc1aSIngo Weinhold 75168ccc989SIngo Weinhold isPrimaryArch=1 752c0e8cc1aSIngo Weinhold for targetArch in $targetArchs; do 753c0e8cc1aSIngo Weinhold # Note: targetArch is "unknown<n>" at this point, if a cross-tools 754c0e8cc1aSIngo Weinhold # prefix was specified. The standard_gcc_settings call below will get 755c0e8cc1aSIngo Weinhold # the actual architecture. 756c0e8cc1aSIngo Weinhold 757c0e8cc1aSIngo Weinhold crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch` 758c0e8cc1aSIngo Weinhold 759338b8dc3SIngo Weinhold # build cross tools from sources 760c0e8cc1aSIngo Weinhold if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then 761c0e8cc1aSIngo Weinhold crossToolsDir="$outputDir/cross-tools-$targetArch" 762c0e8cc1aSIngo Weinhold targetMachine=`get_variable buildCrossToolsMachine_$targetArch` 763c0e8cc1aSIngo Weinhold script="$buildCrossToolsScript" 7648304ec7cSIngo Weinhold scriptArgs= 765c0e8cc1aSIngo Weinhold if [ $targetArch != x86_gcc2 ]; then 7668304ec7cSIngo Weinhold script="${script}_gcc4" 7678304ec7cSIngo Weinhold scriptArgs="$targetMachine" 7681e93288eSJérôme Duval set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \ 7691e93288eSJérôme Duval $useGccGraphiteDefault 770c0e8cc1aSIngo Weinhold fi 77168ccc989SIngo Weinhold secondaryArch= 77268ccc989SIngo Weinhold if [ -z "$isPrimaryArch" ]; then 77368ccc989SIngo Weinhold secondaryArch=$targetArch 77468ccc989SIngo Weinhold fi 77586de8c37SIngo Weinhold 77686de8c37SIngo Weinhold case $HOST_PLATFORM in 77786de8c37SIngo Weinhold freebsd|openbsd) MAKE=gmake;; 77886de8c37SIngo Weinhold *) MAKE=make;; 77986de8c37SIngo Weinhold esac 78086de8c37SIngo Weinhold 78186de8c37SIngo Weinhold MAKE=$MAKE \ 78268ccc989SIngo Weinhold SECONDARY_ARCH=$secondaryArch \ 783c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE=`get_variable \ 784c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE_$targetArch` \ 785b3ece905SJérôme Duval HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \ 786*4da6cf84SFrançois Revol HAIKU_USE_GDB="$gdbSources" \ 7878304ec7cSIngo Weinhold "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \ 7888304ec7cSIngo Weinhold "$crossToolsDir" $buildCrossToolsJobs || exit 1 789c0e8cc1aSIngo Weinhold crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-" 790338b8dc3SIngo Weinhold fi 791338b8dc3SIngo Weinhold 792c0e8cc1aSIngo Weinhold # prepare gcc settings and get the actual target architecture 793a7bddff1SJonathan Schleifer if [ $useClang = 1 ]; then 794a7bddff1SJonathan Schleifer target=${crossToolsPrefix##*/} 795a7bddff1SJonathan Schleifer target=${target%-} 796c6fb0e2cSJonathan Schleifer gcc="clang -target ${target} -no-integrated-as" 797a7bddff1SJonathan Schleifer else 798c0e8cc1aSIngo Weinhold gcc="${crossToolsPrefix}gcc" 799a7bddff1SJonathan Schleifer fi 800c0e8cc1aSIngo Weinhold if [ -z "${crossToolsPrefix}" ]; then 801c0e8cc1aSIngo Weinhold gcc=`get_variable HAIKU_CC_$targetArch` 802338b8dc3SIngo Weinhold fi 803c0e8cc1aSIngo Weinhold standard_gcc_settings "$gcc" 804c0e8cc1aSIngo Weinhold targetArch=$standard_gcc_settings_targetArch 805338b8dc3SIngo Weinhold 806c0e8cc1aSIngo Weinhold # set default values for flags 807c0e8cc1aSIngo Weinhold set_default_value HAIKU_CPPFLAGS_$targetArch "" 808c0e8cc1aSIngo Weinhold set_default_value HAIKU_CCFLAGS_$targetArch "" 809c0e8cc1aSIngo Weinhold set_default_value HAIKU_CXXFLAGS_$targetArch "" 810c0e8cc1aSIngo Weinhold set_default_value HAIKU_LDFLAGS_$targetArch "" 811c0e8cc1aSIngo Weinhold set_default_value HAIKU_ARFLAGS_$targetArch cru 812c0e8cc1aSIngo Weinhold set_default_value HAIKU_UNARFLAGS_$targetArch x 813338b8dc3SIngo Weinhold 814c0e8cc1aSIngo Weinhold # Override the cross tools variables, if the tools were built or a 815c0e8cc1aSIngo Weinhold # prefix was specified. 816b7777272SAlex Smith if [ -n "$crossToolsPrefix" ]; then 817c0e8cc1aSIngo Weinhold get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar 818c0e8cc1aSIngo Weinhold get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld 819c0e8cc1aSIngo Weinhold get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy 820c0e8cc1aSIngo Weinhold get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib 821c0e8cc1aSIngo Weinhold get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip 822c0e8cc1aSIngo Weinhold 823c0e8cc1aSIngo Weinhold case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in 824c9dba742SJérôme Duval 4.*|5.*|6.*|7.*) 825c0e8cc1aSIngo Weinhold get_build_tool_path ELFEDIT_$targetArch \ 826c0e8cc1aSIngo Weinhold ${crossToolsPrefix}elfedit 827bd16f0ddSAlex Smith ;; 828bd16f0ddSAlex Smith esac 82952a38012Sejakowatz fi 83052a38012Sejakowatz 831ef57df3dSIngo Weinhold # check whether the Haiku compiler really targets Haiku 832c0e8cc1aSIngo Weinhold targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` 833c0e8cc1aSIngo Weinhold case "$targetMachine" in 834eedc3d0bSIngo Weinhold *-*-haiku) ;; 835c0e8cc1aSIngo Weinhold *) 836c0e8cc1aSIngo Weinhold echo The compiler specified as Haiku target compiler is not a \ 837c0e8cc1aSIngo Weinhold valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2 838eedc3d0bSIngo Weinhold echo compiler: $HAIKU_CC 839c0e8cc1aSIngo Weinhold echo compiler is configured for target: $targetMachine 840eedc3d0bSIngo Weinhold exit 1 ;; 841eedc3d0bSIngo Weinhold esac 842c0e8cc1aSIngo Weinhold 843c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch" 84468ccc989SIngo Weinhold isPrimaryArch= 845c0e8cc1aSIngo Weinhold done 8462ebcd86dSIngo Weinholdfi 847eedc3d0bSIngo Weinhold 84852a38012Sejakowatz# Generate BuildConfig 8497c4641d0SOliver Tappecat << EOF > "$buildConfigFile" 85052a38012Sejakowatz# BuildConfig 851ab2540c4SIngo Weinhold# Note: This file has been automatically generated by configure with the 852ab2540c4SIngo Weinhold# following arguments: 85355d267a4SFrançois Revol# ${configureArgs} 85452a38012Sejakowatz 8557c4641d0SOliver TappeTARGET_PLATFORM ?= "${TARGET_PLATFORM}" ; 8567c4641d0SOliver TappeHOST_PLATFORM ?= "${HOST_PLATFORM}" ; 857338b8dc3SIngo Weinhold 8587c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS ?= "${HAIKU_INCLUDE_GPL_ADDONS}" ; 8597c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ; 86076fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ; 8617c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ; 8627c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER ?= "${HAIKU_ENABLE_MULTIUSER}" ; 8637c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ; 8647c4641d0SOliver TappeHAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ; 8657986925fSIngo WeinholdHAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ; 8667986925fSIngo WeinholdHAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ; 867bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ; 8682ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ; 869eccc7665SIngo Weinhold 870c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ; 87165ad1ba3SAlex Smith 872aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ; 873aa2e5ecaSOliver Tappe 8747c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ; 875338b8dc3SIngo Weinhold 876d6f80927SJonathan SchleiferHAIKU_NASM ?= ${HAIKU_NASM} ; 877e70c4c64SPulkoMandyHAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ; 878338b8dc3SIngo Weinhold 879f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ; 8807c4641d0SOliver TappeHOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ; 8817c4641d0SOliver TappeHOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ; 8827c4641d0SOliver TappeHOST_LD ?= ${HOST_GCC_LD} ; 8837c4641d0SOliver TappeHOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ; 8842a5d0aafSIngo WeinholdHOST_SHA256 ?= ${HOST_SHA256} ; 8858b5934c9SIngo Weinhold 886e173a1ecSIngo WeinholdHOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ; 887e173a1ecSIngo WeinholdHAIKU_PORTS ?= ${HAIKU_PORTS} ; 888e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ; 889c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ; 890e173a1ecSIngo Weinhold 891c4786ea6SlilloEOF 892c4786ea6Slillo 893c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do 894c0e8cc1aSIngo Weinhold variables=" 895c0e8cc1aSIngo Weinhold HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION 896c0e8cc1aSIngo Weinhold HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE 897c0e8cc1aSIngo Weinhold HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR 898c0e8cc1aSIngo Weinhold HAIKU_CPU HAIKU_CPU 899c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC 900c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX 901c0e8cc1aSIngo Weinhold HAIKU_AR HAIKU_AR 902c0e8cc1aSIngo Weinhold HAIKU_CC HAIKU_CC 903c2b76f7fSJonathan Schleifer HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG 904c0e8cc1aSIngo Weinhold HAIKU_LD HAIKU_LD 905c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY HAIKU_OBJCOPY 906c0e8cc1aSIngo Weinhold HAIKU_RANLIB HAIKU_RANLIB 907c0e8cc1aSIngo Weinhold HAIKU_ELFEDIT HAIKU_ELFEDIT 908c0e8cc1aSIngo Weinhold HAIKU_STRIP HAIKU_STRIP 909c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS HAIKU_CPPFLAGS 910c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS HAIKU_CCFLAGS 911c0e8cc1aSIngo Weinhold HAIKU_C++FLAGS HAIKU_CXXFLAGS 912c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS HAIKU_LDFLAGS 913c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS HAIKU_ARFLAGS 914c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS HAIKU_UNARFLAGS 915c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE 916c0e8cc1aSIngo Weinhold " 917c0e8cc1aSIngo Weinhold set -- $variables 918c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 919c0e8cc1aSIngo Weinhold value=`get_variable ${2}_$targetArch` 920c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile" 921c0e8cc1aSIngo Weinhold shift 2 922c0e8cc1aSIngo Weinhold done 923b1e5b60cSAxel Dörfler 924c0e8cc1aSIngo Weinhold # For variables that may have long values, distribute them over multiple 925c0e8cc1aSIngo Weinhold # lines so that jam doesn't hit the maximum line length. 926c0e8cc1aSIngo Weinhold variables=" 92766a7f29fSJérôme Duval HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR 928c0e8cc1aSIngo Weinhold " 929c0e8cc1aSIngo Weinhold set -- $variables 930c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 931c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= " >> "$buildConfigFile" 932c0e8cc1aSIngo Weinhold get_variable ${2}_$targetArch | xargs -n 1 echo " " \ 933c0e8cc1aSIngo Weinhold >> "$buildConfigFile" 934c0e8cc1aSIngo Weinhold echo " ;" >> "$buildConfigFile" 935c0e8cc1aSIngo Weinhold shift 2 936c0e8cc1aSIngo Weinhold done 937c0e8cc1aSIngo Weinholddone 938b1e5b60cSAxel Dörfler 939b1e5b60cSAxel Dörfler 9409b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory. 941338b8dc3SIngo Weinhold 942338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 943338b8dc3SIngo Weinhold# automatically generated Jamfile 944338b8dc3SIngo Weinhold 945338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 946338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 947338b8dc3SIngo Weinhold 948338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 949338b8dc3SIngo Weinhold 950338b8dc3SIngo WeinholdEOF 951