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. 5967838392SAxel Dörfler --include-patented-code Enable code that is known to implemented patented 6067838392SAxel Dörfler ideas and techniques. If this option is not 6167838392SAxel Dörfler specified, the resulting distribution may still 6267838392SAxel Dörfler implement patented ideas and techniques. This 6367838392SAxel Dörfler option only disables code that is currently known 6467838392SAxel Dörfler to be problematic. 6576fa0be3SIngo Weinhold --include-sources Includes the source code of projects that require 6676fa0be3SIngo Weinhold either an offer of source code or a copy of the 6776fa0be3SIngo Weinhold patched sources. This is preferable when 6876fa0be3SIngo Weinhold distributing on physical mediums. 691974210fSFrançois Revol --include-3rdparty Include 3rdparty/ in the build system. 704880ae01SJessica Hamilton -j<n> Only relevant for --build-cross-tools. Is passed 714880ae01SJessica Hamilton on to the make building the build tools. 72aa2e5ecaSOliver Tappe --no-downloads Do not download anything. Useful when trying to 73aa2e5ecaSOliver Tappe bootstrap and build Haiku from source only. 747c4641d0SOliver Tappe --target=TARGET Select build target platform. 757c4641d0SOliver Tappe [default=${TARGET_PLATFORM}] 76deb1a319SAlexander von Gluck IV valid targets=r5,bone,dano,haiku 77483b28e4SIngo Weinhold --target-arch <arch> Haiku only: Specify the target architecture to 78483b28e4SIngo Weinhold build for. Must be one of the architectures of the 79483b28e4SIngo Weinhold host system. The installed build tools for that 80483b28e4SIngo Weinhold architecture will be used. 81483b28e4SIngo Weinhold This option can be specified multiple times. The 82483b28e4SIngo Weinhold first occurrence specifies the primary 83483b28e4SIngo Weinhold architecture of the Haiku to build, subsequent 84483b28e4SIngo Weinhold ones the secondary architectures. 85961fc581SFrançois Revol --update re-runs last configure invocation [must be given 867c4641d0SOliver Tappe as first option!] 87d73993ffSAugustin Cavalier --use-clang <arch> Build with host Clang instead of GCC cross 88d73993ffSAugustin Cavalier compiler, targeting <arch> 89eccc7665SIngo Weinhold --use-gcc-pipe Build with GCC option -pipe. Speeds up the build 905a34a443SFrançois Revol process, but uses more memory. 91ed38d2efSJerome Duval --use-gcc-graphite Build with GCC Graphite engine for loop 92ed38d2efSJerome Duval optimizations. Only for gcc 4. 930385b065SIngo Weinhold --use-32bit Use -m32 flag on 64bit host gcc compiler. 94bc96e8f3SIngo Weinhold --use-xattr Use Linux xattr respectively *BSD extattr support 95bc96e8f3SIngo Weinhold for BeOS attribute emulation. Warning: Make sure 96bc96e8f3SIngo Weinhold your file system supports sufficient attribute 97bc96e8f3SIngo Weinhold sizes (4 KB per file for all attributes won't 98bc96e8f3SIngo Weinhold suffice). 99bc96e8f3SIngo Weinhold --use-xattr-ref Use the generic BeOS attribute emulation, but use 100bc96e8f3SIngo Weinhold Linux xattr respectively *BSD extattr support to 101bc96e8f3SIngo Weinhold make it more robust (i.e. attribute mix-ups become 102bc96e8f3SIngo Weinhold less likely). 1034da6cf84SFrançois Revol --with-gdb <gdb sources dir> 1044da6cf84SFrançois Revol specify the path to a GDB source dir, to build 1054da6cf84SFrançois Revol GDB for each arch we build the cross-tools for. 106338b8dc3SIngo Weinhold 107338b8dc3SIngo Weinholdenvironment variables: 10863701e7dSOliver Tappe CC The host compiler. Defaults to "gcc". 109*65706842SAugustin Cavalier HAIKU_AR_<arch> The static library archiver for <arch>. 110c0e8cc1aSIngo Weinhold Defaults to "ar". 111*65706842SAugustin Cavalier HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc". 112*65706842SAugustin Cavalier HAIKU_LD_<arch> The <arch> linker. Defaults to "ld". 113*65706842SAugustin Cavalier HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to 114c0e8cc1aSIngo Weinhold "objcopy". 115*65706842SAugustin Cavalier HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults 116c0e8cc1aSIngo Weinhold to "ranlib". 117*65706842SAugustin Cavalier HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip". 118a04a520bSJonathan Schleifer HAIKU_NASM The nasm assembler (x86 and x86_64 only). 119c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture 120c0e8cc1aSIngo Weinhold <arch>. Defaults to "". 121c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>. 122c0e8cc1aSIngo Weinhold Defaults to "". 123c0e8cc1aSIngo Weinhold HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>. 124c0e8cc1aSIngo Weinhold Defaults to "". 125c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>. 126c0e8cc1aSIngo Weinhold Defaults to "". 127c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target 128c0e8cc1aSIngo Weinhold architecture <arch> for archiving. Defaults to 129c0e8cc1aSIngo Weinhold "cru". 130c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target 131c0e8cc1aSIngo Weinhold architecture <arch> for unarchiving. Defaults to 132c0e8cc1aSIngo Weinhold "x". 13364f6da31SIngo Weinhold 134c0e8cc1aSIngo WeinholdNon-default output directories: 13564f6da31SIngo Weinhold By default all objects, build configuration, and other related files are 13664f6da31SIngo Weinhold stored in /path/to/haiku_source/generated. To store objects in a non-default 13764f6da31SIngo Weinhold location, run "../../relative/path/to/haiku_source/configure <options>" from 13864f6da31SIngo Weinhold within your non-default location. "jam [ options ] targets" can then be run 13964f6da31SIngo Weinhold directly inside your non-default location. Another option is to invoke "jam 14064f6da31SIngo Weinhold [ options ] targets" from within haiku_source. This can be accomplished by 14164f6da31SIngo Weinhold either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking 14264f6da31SIngo Weinhold jam or by creating a symlink of haiku_source/generated pointing to your 14364f6da31SIngo Weinhold non-default location and running jam. 14464f6da31SIngo Weinhold 14564f6da31SIngo Weinhold 146022fa244SIngo WeinholdEOF 147022fa244SIngo Weinhold} 148022fa244SIngo Weinhold 149022fa244SIngo Weinhold# assertparam 150022fa244SIngo Weinhold# 151022fa244SIngo Weinhold# Checks whether at least one parameter is left. 152022fa244SIngo Weinhold# 153022fa244SIngo Weinholdassertparam() 154022fa244SIngo Weinhold{ 15520ab75e6SIngo Weinhold if [ $2 -lt 2 ]; then 156022fa244SIngo Weinhold echo $0: \`$1\': Parameter expected. 157022fa244SIngo Weinhold exit 1 158022fa244SIngo Weinhold fi 159022fa244SIngo Weinhold} 160022fa244SIngo Weinhold 16120ab75e6SIngo Weinhold# assertparams 16220ab75e6SIngo Weinhold# 16320ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left. 16420ab75e6SIngo Weinhold# 16520ab75e6SIngo Weinholdassertparams() 16620ab75e6SIngo Weinhold{ 16720ab75e6SIngo Weinhold if [ $3 -le $2 ]; then 16820ab75e6SIngo Weinhold echo $0: \`$1\': Not enough parameters. 16920ab75e6SIngo Weinhold exit 1 17020ab75e6SIngo Weinhold fi 17120ab75e6SIngo Weinhold} 17220ab75e6SIngo Weinhold 173e173a1ecSIngo Weinhold# absolute_path 174e173a1ecSIngo Weinhold# 175e173a1ecSIngo Weinhold# returns the absolute path of a given path. 176e173a1ecSIngo Weinhold# 177e173a1ecSIngo Weinholdabsolute_path() 178e173a1ecSIngo Weinhold{ 1796a4f3954SFrançois Revol if [ "x$1" != "x${1#/}" ]; then 180e173a1ecSIngo Weinhold echo "$1" 181e173a1ecSIngo Weinhold else 182e173a1ecSIngo Weinhold echo "`pwd`/$1" 183e173a1ecSIngo Weinhold fi 184e173a1ecSIngo Weinhold} 185e173a1ecSIngo Weinhold 18639d444a3SArvind S Raj# check_dir_exists 18739d444a3SArvind S Raj# 18839d444a3SArvind S Raj# check if a directory exists or not 18939d444a3SArvind S Raj# 19039d444a3SArvind S Rajcheck_dir_exists() 19139d444a3SArvind S Raj{ 19239d444a3SArvind S Raj if [ -d "$1" ]; then 19339d444a3SArvind S Raj return 0 19439d444a3SArvind S Raj else 19539d444a3SArvind S Raj return 1 19639d444a3SArvind S Raj fi 19739d444a3SArvind S Raj} 19839d444a3SArvind S Raj 199502882dbSJessica Hamilton# check_file_exists 200502882dbSJessica Hamilton# 201502882dbSJessica Hamilton# check if a file exists or not 202502882dbSJessica Hamilton# 203502882dbSJessica Hamiltoncheck_file_exists() 204502882dbSJessica Hamilton{ 205502882dbSJessica Hamilton if [ -f "$1" ]; then 206502882dbSJessica Hamilton return 0 207502882dbSJessica Hamilton else 208502882dbSJessica Hamilton return 1 209502882dbSJessica Hamilton fi 210502882dbSJessica Hamilton} 211502882dbSJessica Hamilton 2129a001156SOliver Tappe# real_path 2139a001156SOliver Tappe# 2149a001156SOliver Tappe# returns the realpath of a symbolic link. 2159a001156SOliver Tappe# 2169a001156SOliver Tappereal_path() 2179a001156SOliver Tappe{ 2189a001156SOliver Tappe perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1" 2199a001156SOliver Tappe} 2209a001156SOliver Tappe 22109c5682dSIngo Weinhold# standard_gcc_settings 22209c5682dSIngo Weinhold# 22309c5682dSIngo Weinhold# Sets the variables for a GCC platform. 22409c5682dSIngo Weinhold# 22509c5682dSIngo Weinholdstandard_gcc_settings() 22609c5682dSIngo Weinhold{ 227*65706842SAugustin Cavalier local gcc="$1" 228c0e8cc1aSIngo Weinhold 229138f5fb4SIngo Weinhold if which greadlink > /dev/null 2>&1; then 230b29b48b1SMatt Madia readlink="greadlink -e" 231138f5fb4SIngo Weinhold elif which realpath > /dev/null 2>&1; then 232b29b48b1SMatt Madia readlink=realpath 2339a001156SOliver Tappe elif readlink -e / > /dev/null 2>&1; then 234b29b48b1SMatt Madia readlink="readlink -e" 2359a001156SOliver Tappe else 2369a001156SOliver Tappe readlink=real_path 237b4b6d83cSMatt Madia fi 238138f5fb4SIngo Weinhold 23909c5682dSIngo Weinhold # PLATFORM_LINKLIBS 240c0e8cc1aSIngo Weinhold local gcclib=`$gcc -print-libgcc-file-name` 241c0e8cc1aSIngo Weinhold local gccdir=`dirname ${gcclib}` 2425b0f7b1bSOliver Tappe 243c0e8cc1aSIngo Weinhold local gccRawVersion=`$gcc -dumpversion` 244c0e8cc1aSIngo Weinhold local gccMachine=`$gcc -dumpmachine` 245338b8dc3SIngo Weinhold 246fc8967f1SIngo Weinhold # determine architecture from machine triple 247c0e8cc1aSIngo Weinhold case $gccMachine in 248c0e8cc1aSIngo Weinhold arm-*) targetCpu=arm;; 249c0e8cc1aSIngo Weinhold i?86-*) targetCpu=x86;; 250c0e8cc1aSIngo Weinhold m68k-*) targetCpu=m68k;; 251c0e8cc1aSIngo Weinhold powerpc-*) targetCpu=ppc;; 252c0e8cc1aSIngo Weinhold x86_64-*) targetCpu=x86_64;; 253fc8967f1SIngo Weinhold *) 254c0e8cc1aSIngo Weinhold echo "Unsupported gcc target machine: $gccMachine" >&2 255fc8967f1SIngo Weinhold exit 1 256fc8967f1SIngo Weinhold ;; 257fc8967f1SIngo Weinhold esac 258fc8967f1SIngo Weinhold 259c0e8cc1aSIngo Weinhold local targetArch=$targetCpu 260fc8967f1SIngo Weinhold 261c0e8cc1aSIngo Weinhold case $gccRawVersion in 2626cc8eecfSOliver Tappe 2.9*) 2635b0f7b1bSOliver Tappe # check for correct (most up-to-date) legacy compiler and complain 2645b0f7b1bSOliver Tappe # if an older one is installed 265c0e8cc1aSIngo Weinhold if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then 2665b0f7b1bSOliver Tappe echo "GCC version $haikuRequiredLegacyGCCVersion is required!"; 2675b0f7b1bSOliver Tappe echo "Please download it from www.haiku-os.org..."; 2685b0f7b1bSOliver Tappe exit 1; 2695b0f7b1bSOliver Tappe fi 270aaeadfcbSAlex Smith 271c0e8cc1aSIngo Weinhold targetArch=x86_gcc2 2725b0f7b1bSOliver Tappe ;; 2738b5934c9SIngo Weinhold esac 27465ad1ba3SAlex Smith 275c0e8cc1aSIngo Weinhold local bootLibgcc 276c0e8cc1aSIngo Weinhold local bootLibSupCxx 27766a7f29fSJérôme Duval local bootCxxHeaders 278c0e8cc1aSIngo Weinhold case $gccMachine in 2794591ebc9SAlex Smith x86_64-*) 28066a7f29fSJérôme Duval # Boot loader is 32-bit, need the 32-bit libs and c++ config 28111ae3c5fSOliver Tappe bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` 282c0e8cc1aSIngo Weinhold bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` 28366a7f29fSJérôme Duval 28466a7f29fSJérôme Duval local headersBase=$gccdir/../../../.. 28566a7f29fSJérôme Duval local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion 28666a7f29fSJérôme Duval if [ ! -d $headers ]; then 28766a7f29fSJérôme Duval headers=$headersBase/include/c++/$gccRawVersion 28866a7f29fSJérôme Duval fi 28966a7f29fSJérôme Duval bootCxxHeaders="$headers/$gccMachine/32" 2904591ebc9SAlex Smith ;; 291338b8dc3SIngo Weinhold esac 292c0e8cc1aSIngo Weinhold 293c0e8cc1aSIngo Weinhold # determine whether graphite loop optimization should/can be used 294c0e8cc1aSIngo Weinhold local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu` 295c0e8cc1aSIngo Weinhold if [ -z "$useGraphite" ]; then 296c0e8cc1aSIngo Weinhold useGraphite=$useGccGraphiteDefault 297c0e8cc1aSIngo Weinhold fi 298c0e8cc1aSIngo Weinhold 299c0e8cc1aSIngo Weinhold if [ "$useGraphite" != 0 ]; then 300c0e8cc1aSIngo Weinhold UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1` 301c0e8cc1aSIngo Weinhold if [ $? != 0 ]; then 302c0e8cc1aSIngo Weinhold echo "GCC Graphite loop optimizations cannot be used on $targetArch" 303c0e8cc1aSIngo Weinhold useGraphite=0 304c0e8cc1aSIngo Weinhold fi 305c0e8cc1aSIngo Weinhold fi 306c0e8cc1aSIngo Weinhold 307c0e8cc1aSIngo Weinhold set_variable HAIKU_CPU_$targetArch $targetCpu 308c0e8cc1aSIngo Weinhold 309c0e8cc1aSIngo Weinhold get_build_tool_path CC_$targetArch "$gcc" 310a7bddff1SJonathan Schleifer set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang 311c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion 312c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine 313c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir 31466a7f29fSJérôme Duval set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" 31511ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" 31611ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc 317c0e8cc1aSIngo Weinhold set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite 318c0e8cc1aSIngo Weinhold 319c0e8cc1aSIngo Weinhold standard_gcc_settings_targetArch=$targetArch 320c0e8cc1aSIngo Weinhold} 321c0e8cc1aSIngo Weinhold 322c0e8cc1aSIngo Weinhold# set_variable 323c0e8cc1aSIngo Weinhold# 324c0e8cc1aSIngo Weinhold# Set the value of a variable. 325c0e8cc1aSIngo Weinhold# 326c0e8cc1aSIngo Weinholdset_variable() 327c0e8cc1aSIngo Weinhold{ 328c0e8cc1aSIngo Weinhold eval "$1=\"$2\"" 329c0e8cc1aSIngo Weinhold} 330c0e8cc1aSIngo Weinhold 331c0e8cc1aSIngo Weinhold# get_variable 332c0e8cc1aSIngo Weinhold# 333c0e8cc1aSIngo Weinhold# Echo the value of a variable. 334c0e8cc1aSIngo Weinhold# 335c0e8cc1aSIngo Weinholdget_variable() 336c0e8cc1aSIngo Weinhold{ 337c0e8cc1aSIngo Weinhold eval "echo \${$1}" 33809c5682dSIngo Weinhold} 33909c5682dSIngo Weinhold 340338b8dc3SIngo Weinhold# set_default_value 341338b8dc3SIngo Weinhold# 342338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 343338b8dc3SIngo Weinhold# 344338b8dc3SIngo Weinholdset_default_value() 345338b8dc3SIngo Weinhold{ 3460838a930SJérôme Duval eval "$1=\${$1-$2}" 347338b8dc3SIngo Weinhold} 348338b8dc3SIngo Weinhold 349338b8dc3SIngo Weinhold# get_build_tool_path 350338b8dc3SIngo Weinhold# 351338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 352338b8dc3SIngo Weinhold# 353338b8dc3SIngo Weinholdget_build_tool_path() 354338b8dc3SIngo Weinhold{ 355338b8dc3SIngo Weinhold local var="HAIKU_$1" 356*65706842SAugustin Cavalier local varval="`get_variable $var`" 357*65706842SAugustin Cavalier local cmd="$2" 358d73993ffSAugustin Cavalier 359e042a53bSAugustin Cavalier if [ ! -z "$varval" ]; then 360d73993ffSAugustin Cavalier # this variable is already set (probably by user) so grab its contents 361e042a53bSAugustin Cavalier cmd=$varval 362d73993ffSAugustin Cavalier fi 363d73993ffSAugustin Cavalier 364d73993ffSAugustin Cavalier local path=${cmd%% *} 365338b8dc3SIngo Weinhold 366338b8dc3SIngo Weinhold if [ -f "$path" ]; then 367*65706842SAugustin Cavalier # get absolute path from relative path 368a559f87aSFrançois Revol local oldPwd="`pwd`" 369a559f87aSFrançois Revol cd "`dirname "$path"`" 370a559f87aSFrançois Revol path="`pwd`/`basename "$path"`" 371338b8dc3SIngo Weinhold cd $oldPwd 372338b8dc3SIngo Weinhold else 3737fe2e06cSMatt Madia which "$path" > /dev/null 2>&1 || { 374d73993ffSAugustin Cavalier echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2 375338b8dc3SIngo Weinhold exit 1 376338b8dc3SIngo Weinhold } 377338b8dc3SIngo Weinhold fi 378338b8dc3SIngo Weinhold 379*65706842SAugustin Cavalier if test "${cmd#* }" != "$cmd"; then 380*65706842SAugustin Cavalier # $cmd contains arguments, so preserve them (and only them) 381*65706842SAugustin Cavalier cmd=${cmd#* } 382*65706842SAugustin Cavalier else 383*65706842SAugustin Cavalier # $cmd does not contain arguments, so unset it 384*65706842SAugustin Cavalier cmd= 385*65706842SAugustin Cavalier fi 386*65706842SAugustin Cavalier eval "$var=\"$path $cmd\"" 387338b8dc3SIngo Weinhold} 388338b8dc3SIngo Weinhold 389483b28e4SIngo Weinholdis_in_list() 390483b28e4SIngo Weinhold{ 391483b28e4SIngo Weinhold local element 392483b28e4SIngo Weinhold for element in $2; do 393483b28e4SIngo Weinhold if [ "$1" = "$element" ]; then 394483b28e4SIngo Weinhold return 0 395483b28e4SIngo Weinhold fi 396483b28e4SIngo Weinhold done 397483b28e4SIngo Weinhold return 1 398483b28e4SIngo Weinhold} 399483b28e4SIngo Weinhold 4007f9beaf1SOliver Tappe# check for --help or -h and show usage immediately 4017f9beaf1SOliver Tappeif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then 4028b420c2fSOliver Tappe usage; exit 0; 4038b420c2fSOliver Tappefi 4048b420c2fSOliver Tappe 405c6c03d56SAugustin Cavalier# ensure umask is not too restrictive 406c6c03d56SAugustin Cavalierif [ $(umask) -gt 22 ]; then 407c6c03d56SAugustin Cavalier echo "Your umask is too restrictive (should be: <= 0022; is actually:" $(umask)")" 408c6c03d56SAugustin Cavalier exit 1 409c6c03d56SAugustin Cavalierfi 4108b420c2fSOliver Tappe 411338b8dc3SIngo Weinhold# get cwd and the source directory 412338b8dc3SIngo WeinholdcurrentDir=`pwd` 4136e7c6fe5SIngo Weinholdcd `dirname "$0"` 414338b8dc3SIngo WeinholdsourceDir=`pwd` 4156e7c6fe5SIngo Weinholdcd "$currentDir" 416338b8dc3SIngo Weinhold 41755d267a4SFrançois Revol# backup the passed arguments 41855d267a4SFrançois RevolconfigureArgs="$@" 41955d267a4SFrançois Revol 4207c4641d0SOliver Tappe# internal default parameter values 421022fa244SIngo Weinhold# 42252a38012Sejakowatzplatform=`uname` 4235abd9a46SIngo WeinholdplatformMachine=`uname -m` 424c0e8cc1aSIngo WeinholdtargetArchs= 425338b8dc3SIngo WeinholdbuildCrossTools= 42629ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" 42760d8d8fcSIngo WeinholdbuildCrossToolsJobs= 428c2b76f7fSJonathan SchleiferuseClang=0 429c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0 430c0e8cc1aSIngo WeinholdunknownArchIndex=1 431483b28e4SIngo WeinholdhaikuTargetArchs= 4324da6cf84SFrançois RevolgdbSources= 4337c4641d0SOliver Tappe 43463701e7dSOliver Tappeif [ -z "$CC" ]; then 43563701e7dSOliver Tappe CC=gcc 43663701e7dSOliver Tappefi 43763701e7dSOliver Tappe 4387c4641d0SOliver Tappe# exported (BuildSetup) default parameter values 4397c4641d0SOliver Tappe# 44063701e7dSOliver TappeHOST_GCC_RAW_VERSION=`$CC -dumpversion` 44163701e7dSOliver TappeHOST_GCC_MACHINE=`$CC -dumpmachine` 4427c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0 44376fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0 4447c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0 4457c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER=0 4467c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default 4477c4641d0SOliver TappeTARGET_PLATFORM=haiku 4487c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0 4497986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0 4507986925fSIngo WeinholdHAIKU_HOST_USE_XATTR=0 451bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF=0 4522ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0 453f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r" 45463701e7dSOliver TappeHOST_GCC_LD=`$CC -print-prog-name=ld` 45563701e7dSOliver TappeHOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy` 4562a5d0aafSIngo WeinholdHOST_SHA256= 457e173a1ecSIngo WeinholdHOST_HAIKU_PORTER= 458e173a1ecSIngo WeinholdHAIKU_PORTS= 459e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS= 460c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP=0 461e70c4c64SPulkoMandyHAIKU_BOOT_BOARD= 462aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0 4632a5d0aafSIngo Weinhold 464c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS= 465c0e8cc1aSIngo Weinhold 466a04a520bSJonathan Schleiferset_default_value HAIKU_NASM nasm 467c0e8cc1aSIngo Weinhold 4683942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then 4692a5d0aafSIngo Weinhold HOST_SHA256=sha256sum 4703942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then 4712a5d0aafSIngo Weinhold HOST_SHA256="sha256 -q" 472b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then 473b5a871b1SNiels Sascha Reedijk HOST_SHA256="shasum -a 256" 4742a5d0aafSIngo Weinholdelse 4752a5d0aafSIngo Weinhold echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2 4762a5d0aafSIngo Weinhold exit 1 4772a5d0aafSIngo Weinholdfi 478338b8dc3SIngo Weinhold 47984edb1a1SAxel DörflerhaikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20" 480a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion 481af4bf973SOliver Tappe # version of legacy gcc required to build haiku 482483b28e4SIngo WeinholdsupportedTargetArchs=" 483483b28e4SIngo Weinhold arm 484483b28e4SIngo Weinhold m68k 485483b28e4SIngo Weinhold ppc 486483b28e4SIngo Weinhold x86 487483b28e4SIngo Weinhold x86_64 488483b28e4SIngo Weinhold x86_gcc2 489483b28e4SIngo Weinhold " 490af4bf973SOliver Tappe 4917c4641d0SOliver Tappe# determine output directory 4927c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then 4937c4641d0SOliver Tappe outputDir=$currentDir/generated 4947c4641d0SOliver Tappeelse 4957c4641d0SOliver Tappe outputDir=$currentDir 4967c4641d0SOliver Tappefi 4977c4641d0SOliver TappebuildOutputDir="$outputDir/build" 4987c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes" 4997c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig" 5007c4641d0SOliver Tappe 5017c4641d0SOliver Tappe# check for update request 5027c4641d0SOliver Tappeif [ "$1" = "--update" ]; then 5037c4641d0SOliver Tappe if ! [ -e "$buildConfigFile" ]; then 5047c4641d0SOliver Tappe echo $0 --update: \'$buildConfigFile\' not found - updating not possible. 5057c4641d0SOliver Tappe exit 1 5067c4641d0SOliver Tappe fi 5077c4641d0SOliver Tappe if ! type perl >/dev/null 2>&1; then 5087c4641d0SOliver Tappe echo $0 --update: \'perl\' not found - updating not possible. 5097c4641d0SOliver Tappe exit 1 5107c4641d0SOliver Tappe fi 5117c4641d0SOliver Tappe # convert BuildConfig from jam format to shell format and evaluate it 5127c4641d0SOliver Tappe shellConfigFile="${buildConfigFile}.shell" 5137c4641d0SOliver Tappe perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \ 5147c4641d0SOliver Tappe <"$buildConfigFile" >"$shellConfigFile" 5157c4641d0SOliver Tappe . "$shellConfigFile" 5167c4641d0SOliver Tappe rm "$shellConfigFile" 5177c4641d0SOliver Tappe shift 5187c4641d0SOliver Tappefi 5197c4641d0SOliver Tappe 520022fa244SIngo Weinhold# parse parameters 521022fa244SIngo Weinhold# 52220ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do 523022fa244SIngo Weinhold case "$1" in 524e173a1ecSIngo Weinhold --bootstrap) 525e173a1ecSIngo Weinhold assertparams "$1" 3 $# 526e173a1ecSIngo Weinhold HOST_HAIKU_PORTER="`absolute_path $2`" 527e173a1ecSIngo Weinhold HAIKU_PORTS_CROSS="`absolute_path $3`" 528e173a1ecSIngo Weinhold HAIKU_PORTS="`absolute_path $4`" 529c9dd05ffSJonathan Schleifer HAIKU_IS_BOOTSTRAP=1 530c9dd05ffSJonathan Schleifer HAIKU_NO_DOWNLOADS=1 531502882dbSJessica Hamilton check_file_exists "$HOST_HAIKU_PORTER" || ( 532502882dbSJessica Hamilton echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2 53339d444a3SArvind S Raj exit 1 53439d444a3SArvind S Raj ) 53539d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS" || ( 53639d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS" >&2 53739d444a3SArvind S Raj exit 1 53839d444a3SArvind S Raj ) 53939d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS_CROSS" || ( 54039d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2 54139d444a3SArvind S Raj exit 1 54239d444a3SArvind S Raj ) 543e173a1ecSIngo Weinhold shift 4 544e173a1ecSIngo Weinhold ;; 545c0e8cc1aSIngo Weinhold --build-cross-tools) 546c0e8cc1aSIngo Weinhold if [ -z "$buildCrossTools" ]; then 5479b0dd528SIngo Weinhold assertparams "$1" 2 $# 548c0e8cc1aSIngo Weinhold targetArch=$2 5499b0dd528SIngo Weinhold buildCrossTools=$3 5509b0dd528SIngo Weinhold shift 3 551c0e8cc1aSIngo Weinhold else 552c0e8cc1aSIngo Weinhold assertparam "$1" $# 553c0e8cc1aSIngo Weinhold targetArch=$2 554c0e8cc1aSIngo Weinhold shift 2 555c0e8cc1aSIngo Weinhold fi 556c0e8cc1aSIngo Weinhold case "$targetArch" in 557c0e8cc1aSIngo Weinhold x86_gcc2) targetMachine=i586-pc-haiku;; 558c0e8cc1aSIngo Weinhold x86) targetMachine=i586-pc-haiku;; 559c0e8cc1aSIngo Weinhold x86_64) targetMachine=x86_64-unknown-haiku;; 560c0e8cc1aSIngo Weinhold ppc) targetMachine=powerpc-apple-haiku;; 561c0e8cc1aSIngo Weinhold m68k) targetMachine=m68k-unknown-haiku;; 562c0e8cc1aSIngo Weinhold arm) targetMachine=arm-unknown-haiku;; 563c0e8cc1aSIngo Weinhold *) 564c0e8cc1aSIngo Weinhold echo "Unsupported target architecture: $2" >&2 565c0e8cc1aSIngo Weinhold exit 1 566c0e8cc1aSIngo Weinhold ;; 567c0e8cc1aSIngo Weinhold esac 568c0e8cc1aSIngo Weinhold set_variable buildCrossToolsMachine_$targetArch $targetMachine 569c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 570c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 5719b0dd528SIngo Weinhold ;; 5729b0dd528SIngo Weinhold --cross-tools-prefix) 5739b0dd528SIngo Weinhold assertparam "$1" $# 574c0e8cc1aSIngo Weinhold targetArch=unknown${unknownArchIndex} 575c0e8cc1aSIngo Weinhold set_variable crossToolsPrefix_$targetArch "$2" 576c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 577c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 578d68208faSMatt Madia unknownArchIndex=$(($unknownArchIndex + 1)) 5799b0dd528SIngo Weinhold shift 2 5809b0dd528SIngo Weinhold ;; 581a66c32ddSIngo Weinhold --distro-compatibility) 5829b0dd528SIngo Weinhold assertparam "$1" $# 5837c4641d0SOliver Tappe HAIKU_DISTRO_COMPATIBILITY=$2 5847c4641d0SOliver Tappe case "$HAIKU_DISTRO_COMPATIBILITY" in 585a66c32ddSIngo Weinhold official) ;; 586a66c32ddSIngo Weinhold compatible) ;; 587a66c32ddSIngo Weinhold default) ;; 588a66c32ddSIngo Weinhold *) echo "Invalid distro compatibility" \ 5897c4641d0SOliver Tappe "level: $HAIKU_DISTRO_COMPATIBILITY" 590a66c32ddSIngo Weinhold exit 1;; 591a66c32ddSIngo Weinhold esac 5929b0dd528SIngo Weinhold shift 2 5939b0dd528SIngo Weinhold ;; 5947c4641d0SOliver Tappe --enable-multiuser) HAIKU_ENABLE_MULTIUSER=1; shift 1;; 5952ebcd86dSIngo Weinhold --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;; 5967c4641d0SOliver Tappe --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;; 59776fa0be3SIngo Weinhold --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;; 5987c4641d0SOliver Tappe --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;; 59960d8d8fcSIngo Weinhold -j*) buildCrossToolsJobs="$1"; shift 1;; 600aa2e5ecaSOliver Tappe --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;; 6017c4641d0SOliver Tappe --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;; 602483b28e4SIngo Weinhold --target-arch) 603483b28e4SIngo Weinhold assertparam "$1" $# 604483b28e4SIngo Weinhold targetArch=$2 605483b28e4SIngo Weinhold shift 2 606483b28e4SIngo Weinhold if [ ! "$platform" = Haiku ]; then 607483b28e4SIngo Weinhold echo "--target-arch can only be specified on Haiku." >&2 608483b28e4SIngo Weinhold exit 1 609483b28e4SIngo Weinhold fi 610483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 611483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 612483b28e4SIngo Weinhold exit 1 613483b28e4SIngo Weinhold ) 614483b28e4SIngo Weinhold haikuTargetArchs="$haikuTargetArchs $targetArch" 615483b28e4SIngo Weinhold ;; 616d73993ffSAugustin Cavalier --use-clang) 617d73993ffSAugustin Cavalier assertparam "$1" $# 618d73993ffSAugustin Cavalier targetArch=$2 619d73993ffSAugustin Cavalier useClang=1 620d73993ffSAugustin Cavalier case "$targetArch" in 621d73993ffSAugustin Cavalier x86) targetMachine=i586-pc-haiku;; 622d73993ffSAugustin Cavalier x86_64) targetMachine=x86_64-unknown-haiku;; 623d73993ffSAugustin Cavalier *) 624d73993ffSAugustin Cavalier echo "Unsupported target architecture: $2" >&2 625d73993ffSAugustin Cavalier exit 1 626d73993ffSAugustin Cavalier ;; 627d73993ffSAugustin Cavalier esac 628*65706842SAugustin Cavalier get_build_tool_path clang clang 629*65706842SAugustin Cavalier if [ -n "crossToolsPrefix_$targetArch" ]; then 630*65706842SAugustin Cavalier set_variable crossToolsPrefix_$targetArch llvm- 631*65706842SAugustin Cavalier fi 632d73993ffSAugustin Cavalier targetArchs="$targetArchs $targetArch" 633d73993ffSAugustin Cavalier HAIKU_PACKAGING_ARCHS= 634d73993ffSAugustin Cavalier shift 2 635d73993ffSAugustin Cavalier ;; 6367c4641d0SOliver Tappe --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;; 637c0e8cc1aSIngo Weinhold --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;; 6387986925fSIngo Weinhold --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;; 6397986925fSIngo Weinhold --use-xattr) HAIKU_HOST_USE_XATTR=1; shift 1;; 640bc96e8f3SIngo Weinhold --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF=1; shift 1;; 6414da6cf84SFrançois Revol --with-gdb) gdbSources=$2; shift 2;; 642022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 643022fa244SIngo Weinhold esac 644022fa244SIngo Weinholddone 645022fa244SIngo Weinhold 6460df3cc9cSIngo Weinhold# detect the build platform 647338b8dc3SIngo Weinholdcase "${platform}" in 6487c4641d0SOliver Tappe Darwin) HOST_PLATFORM=darwin ;; 6497c4641d0SOliver Tappe FreeBSD) HOST_PLATFORM=freebsd 6507986925fSIngo Weinhold if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then 6515abd9a46SIngo Weinhold echo Unsupported platform: FreeBSD ${platformMachine} 652308c212cSIngo Weinhold exit 1 653308c212cSIngo Weinhold fi ;; 6547c4641d0SOliver Tappe Haiku) HOST_PLATFORM=haiku_host ;; 6557c4641d0SOliver Tappe Linux) HOST_PLATFORM=linux ;; 6567c4641d0SOliver Tappe OpenBSD) HOST_PLATFORM=openbsd ;; 6577c4641d0SOliver Tappe SunOS) HOST_PLATFORM=sunos ;; 6587c4641d0SOliver Tappe CYGWIN_NT-*) HOST_PLATFORM=cygwin ;; 659338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 6604cbe4925SAxel Dörfler exit 1 ;; 6614cbe4925SAxel Dörfleresac 66252a38012Sejakowatz 6630962132cSAlex Smith# check for case-sensitive filesystem 6640962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null 6650962132cSAlex Smithmkdir haikucasetest 2>/dev/null 6660962132cSAlex SmithcaseInsensitive=$? 66797f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null 6680962132cSAlex Smithif [ $caseInsensitive != 0 ]; then 6693ecc5287SMichael Lotz echo "You need a case-sensitive file-system to build Haiku." 6700962132cSAlex Smith if [ $HOST_PLATFORM = "darwin" ]; then 6717a05e252SJohn Scipione echo "You can create a case-sensitive disk image using Disk Utility." 6723ecc5287SMichael Lotz fi 6730962132cSAlex Smith exit 1 6743ecc5287SMichael Lotzfi 6753ecc5287SMichael Lotz 676f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed 677f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then 678f04f7042SNiels Sascha Reedijk HOST_EXTENDED_REGEX_SED="sed -E" 679f04f7042SNiels Sascha Reedijkfi 680f04f7042SNiels Sascha Reedijk 681cb721c59SFrançois Revol# check if nasm can actually output ELF files 682cb721c59SFrançois Revol# (the stock version in OSX can't) 683cb721c59SFrançois Revol# XXX: should probably only test for x86* arch 6843e6c09cdSAdrien Destuguesif [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then 685cb721c59SFrançois Revol echo "$HAIKU_NASM cannot generate ELF files. Please install a working version." 686cb721c59SFrançois Revol if [ $HOST_PLATFORM = "darwin" ]; then 687cb721c59SFrançois Revol echo "You can install it from Mac Ports." 688cb721c59SFrançois Revol echo "Mac Ports is available at: http://www.macports.org/" 689cb721c59SFrançois Revol fi 690cb721c59SFrançois Revol exit 1 691cb721c59SFrançois Revolfi 692cb721c59SFrançois Revol 693338b8dc3SIngo Weinhold# create output directory 6946e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1 695338b8dc3SIngo Weinhold 6962ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then 6972ebcd86dSIngo Weinhold invalidCommand=$sourceDir/build/scripts/host_build_only 6982ebcd86dSIngo Weinhold HAIKU_AR=$invalidCommand 6992ebcd86dSIngo Weinhold HAIKU_CC=$invalidCommand 7002ebcd86dSIngo Weinhold HAIKU_LD=$invalidCommand 7012ebcd86dSIngo Weinhold HAIKU_OBJCOPY=$invalidCommand 7022ebcd86dSIngo Weinhold HAIKU_RANLIB=$invalidCommand 7032ebcd86dSIngo Weinhold HAIKU_ELFEDIT=$invalidCommand 704d6f80927SJonathan Schleifer HAIKU_NASM=$invalidCommand 7052ebcd86dSIngo Weinhold HAIKU_STRIP=$invalidCommand 7062ebcd86dSIngo Weinholdelse 707c0e8cc1aSIngo Weinhold if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then 708c0e8cc1aSIngo Weinhold targetArchs="$HAIKU_PACKAGING_ARCHS" 709c0e8cc1aSIngo Weinhold fi 710c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 711c0e8cc1aSIngo Weinhold 712483b28e4SIngo Weinhold # On Haiku determine target architectures and tools automatically. 713c0e8cc1aSIngo Weinhold if [ -z "$targetArchs" ]; then 714483b28e4SIngo Weinhold if [ $HOST_PLATFORM != haiku_host ]; then 715483b28e4SIngo Weinhold echo "Please specify the build tools to use or build (via" \ 716eaef83a9SJeroen Oortwijn "--cross-tools-prefix or --build-cross-tools) or specify a" \ 717483b28e4SIngo Weinhold "host-only build (--host-only)." >&2 7187f9beaf1SOliver Tappe echo "For more info, invoke $0 --help" 719483b28e4SIngo Weinhold exit 1 720483b28e4SIngo Weinhold fi 721483b28e4SIngo Weinhold 722483b28e4SIngo Weinhold # determine primary architecture 723dda53eaeSIngo Weinhold targetArch=`package list -i /system/packages/haiku-*.hpkg \ 724483b28e4SIngo Weinhold | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'` 725483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 726483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 727483b28e4SIngo Weinhold exit 1 728483b28e4SIngo Weinhold ) 729c0e8cc1aSIngo Weinhold targetArchs=$targetArch 730483b28e4SIngo Weinhold 731c0e8cc1aSIngo Weinhold set_default_value HAIKU_AR_$targetArch ar 732c0e8cc1aSIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc 733c0e8cc1aSIngo Weinhold set_default_value HAIKU_LD_$targetArch ld 734c0e8cc1aSIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy 735c0e8cc1aSIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib 736c0e8cc1aSIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit 737c0e8cc1aSIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip 738483b28e4SIngo Weinhold 739483b28e4SIngo Weinhold # determine secondary architectures 740483b28e4SIngo Weinhold for targetArch in $supportedTargetArchs; do 74180262a91SMatt Madia if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then 742483b28e4SIngo Weinhold targetArchs="$targetArchs $targetArch" 743483b28e4SIngo Weinhold set_default_value HAIKU_AR_$targetArch ar-$targetArch 744483b28e4SIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc-$targetArch 745483b28e4SIngo Weinhold set_default_value HAIKU_LD_$targetArch ld-$targetArch 746483b28e4SIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch 747483b28e4SIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch 748483b28e4SIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch 749483b28e4SIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip-$targetArch 750483b28e4SIngo Weinhold fi 751483b28e4SIngo Weinhold done 752483b28e4SIngo Weinhold 753483b28e4SIngo Weinhold # The target architectures might have been specified explicitly. 754483b28e4SIngo Weinhold if [ -n "$haikuTargetArchs" ]; then 755483b28e4SIngo Weinhold for targetArch in $haikuTargetArchs; do 756483b28e4SIngo Weinhold is_in_list "$targetArch" "$targetArchs" || ( 757483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"." \ 758483b28e4SIngo Weinhold "Only native architectures of the host platform can" \ 759483b28e4SIngo Weinhold "be specified." >&2 760483b28e4SIngo Weinhold exit 1 761483b28e4SIngo Weinhold ) 762483b28e4SIngo Weinhold done 763483b28e4SIngo Weinhold targetArchs="$haikuTargetArchs" 764483b28e4SIngo Weinhold fi 765c0e8cc1aSIngo Weinhold fi 766c0e8cc1aSIngo Weinhold 76768ccc989SIngo Weinhold isPrimaryArch=1 768c0e8cc1aSIngo Weinhold for targetArch in $targetArchs; do 769c0e8cc1aSIngo Weinhold # Note: targetArch is "unknown<n>" at this point, if a cross-tools 770c0e8cc1aSIngo Weinhold # prefix was specified. The standard_gcc_settings call below will get 771c0e8cc1aSIngo Weinhold # the actual architecture. 772c0e8cc1aSIngo Weinhold 773c0e8cc1aSIngo Weinhold crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch` 774c0e8cc1aSIngo Weinhold 775338b8dc3SIngo Weinhold # build cross tools from sources 776c0e8cc1aSIngo Weinhold if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then 777c0e8cc1aSIngo Weinhold crossToolsDir="$outputDir/cross-tools-$targetArch" 778c0e8cc1aSIngo Weinhold targetMachine=`get_variable buildCrossToolsMachine_$targetArch` 779c0e8cc1aSIngo Weinhold script="$buildCrossToolsScript" 7808304ec7cSIngo Weinhold scriptArgs= 781c0e8cc1aSIngo Weinhold if [ $targetArch != x86_gcc2 ]; then 7828304ec7cSIngo Weinhold script="${script}_gcc4" 7838304ec7cSIngo Weinhold scriptArgs="$targetMachine" 7841e93288eSJérôme Duval set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \ 7851e93288eSJérôme Duval $useGccGraphiteDefault 786c0e8cc1aSIngo Weinhold fi 78768ccc989SIngo Weinhold secondaryArch= 78868ccc989SIngo Weinhold if [ -z "$isPrimaryArch" ]; then 78968ccc989SIngo Weinhold secondaryArch=$targetArch 79068ccc989SIngo Weinhold fi 79186de8c37SIngo Weinhold 79286de8c37SIngo Weinhold case $HOST_PLATFORM in 79386de8c37SIngo Weinhold freebsd|openbsd) MAKE=gmake;; 79486de8c37SIngo Weinhold *) MAKE=make;; 79586de8c37SIngo Weinhold esac 79686de8c37SIngo Weinhold 79786de8c37SIngo Weinhold MAKE=$MAKE \ 79868ccc989SIngo Weinhold SECONDARY_ARCH=$secondaryArch \ 799c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE=`get_variable \ 800c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE_$targetArch` \ 801b3ece905SJérôme Duval HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \ 8024da6cf84SFrançois Revol HAIKU_USE_GDB="$gdbSources" \ 8038304ec7cSIngo Weinhold "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \ 8048304ec7cSIngo Weinhold "$crossToolsDir" $buildCrossToolsJobs || exit 1 805c0e8cc1aSIngo Weinhold crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-" 806338b8dc3SIngo Weinhold fi 807338b8dc3SIngo Weinhold 808c0e8cc1aSIngo Weinhold # prepare gcc settings and get the actual target architecture 809a7bddff1SJonathan Schleifer if [ $useClang = 1 ]; then 810*65706842SAugustin Cavalier gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as" 811d73993ffSAugustin Cavalier elif [ -z "${crossToolsPrefix}" ]; then 812d73993ffSAugustin Cavalier gcc=`get_variable HAIKU_CC_$targetArch` 813a7bddff1SJonathan Schleifer else 814c0e8cc1aSIngo Weinhold gcc="${crossToolsPrefix}gcc" 815a7bddff1SJonathan Schleifer fi 816c0e8cc1aSIngo Weinhold standard_gcc_settings "$gcc" 817c0e8cc1aSIngo Weinhold targetArch=$standard_gcc_settings_targetArch 818338b8dc3SIngo Weinhold 819c0e8cc1aSIngo Weinhold # set default values for flags 820c0e8cc1aSIngo Weinhold set_default_value HAIKU_CPPFLAGS_$targetArch "" 821c0e8cc1aSIngo Weinhold set_default_value HAIKU_CCFLAGS_$targetArch "" 822c0e8cc1aSIngo Weinhold set_default_value HAIKU_CXXFLAGS_$targetArch "" 823c0e8cc1aSIngo Weinhold set_default_value HAIKU_LDFLAGS_$targetArch "" 824c0e8cc1aSIngo Weinhold set_default_value HAIKU_ARFLAGS_$targetArch cru 825c0e8cc1aSIngo Weinhold set_default_value HAIKU_UNARFLAGS_$targetArch x 826338b8dc3SIngo Weinhold 827c0e8cc1aSIngo Weinhold # Override the cross tools variables, if the tools were built or a 828c0e8cc1aSIngo Weinhold # prefix was specified. 829b7777272SAlex Smith if [ -n "$crossToolsPrefix" ]; then 830c0e8cc1aSIngo Weinhold get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar 831c0e8cc1aSIngo Weinhold get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld 832c0e8cc1aSIngo Weinhold get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy 833c0e8cc1aSIngo Weinhold get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib 834c0e8cc1aSIngo Weinhold get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip 835c0e8cc1aSIngo Weinhold 836c0e8cc1aSIngo Weinhold case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in 837133e4131SJérôme Duval 4.*|5.*|6.*|7.*|8.*) 838c0e8cc1aSIngo Weinhold get_build_tool_path ELFEDIT_$targetArch \ 839c0e8cc1aSIngo Weinhold ${crossToolsPrefix}elfedit 840bd16f0ddSAlex Smith ;; 841bd16f0ddSAlex Smith esac 84252a38012Sejakowatz fi 84352a38012Sejakowatz 844ef57df3dSIngo Weinhold # check whether the Haiku compiler really targets Haiku 845c0e8cc1aSIngo Weinhold targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` 846c0e8cc1aSIngo Weinhold case "$targetMachine" in 847eedc3d0bSIngo Weinhold *-*-haiku) ;; 848c0e8cc1aSIngo Weinhold *) 849c0e8cc1aSIngo Weinhold echo The compiler specified as Haiku target compiler is not a \ 850c0e8cc1aSIngo Weinhold valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2 851eedc3d0bSIngo Weinhold echo compiler: $HAIKU_CC 852c0e8cc1aSIngo Weinhold echo compiler is configured for target: $targetMachine 853eedc3d0bSIngo Weinhold exit 1 ;; 854eedc3d0bSIngo Weinhold esac 855c0e8cc1aSIngo Weinhold 856c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch" 85768ccc989SIngo Weinhold isPrimaryArch= 858c0e8cc1aSIngo Weinhold done 8592ebcd86dSIngo Weinholdfi 860eedc3d0bSIngo Weinhold 86152a38012Sejakowatz# Generate BuildConfig 8627c4641d0SOliver Tappecat << EOF > "$buildConfigFile" 86352a38012Sejakowatz# BuildConfig 864ab2540c4SIngo Weinhold# Note: This file has been automatically generated by configure with the 865ab2540c4SIngo Weinhold# following arguments: 86655d267a4SFrançois Revol# ${configureArgs} 86752a38012Sejakowatz 8687c4641d0SOliver TappeTARGET_PLATFORM ?= "${TARGET_PLATFORM}" ; 8697c4641d0SOliver TappeHOST_PLATFORM ?= "${HOST_PLATFORM}" ; 870338b8dc3SIngo Weinhold 8717c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ; 87276fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ; 8737c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ; 8747c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER ?= "${HAIKU_ENABLE_MULTIUSER}" ; 8757c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ; 8767c4641d0SOliver TappeHAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ; 8777986925fSIngo WeinholdHAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ; 8787986925fSIngo WeinholdHAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ; 879bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ; 8802ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ; 881eccc7665SIngo Weinhold 882c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ; 88365ad1ba3SAlex Smith 884aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ; 885aa2e5ecaSOliver Tappe 8867c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ; 887338b8dc3SIngo Weinhold 888d6f80927SJonathan SchleiferHAIKU_NASM ?= ${HAIKU_NASM} ; 889e70c4c64SPulkoMandyHAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ; 890338b8dc3SIngo Weinhold 891f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ; 8927c4641d0SOliver TappeHOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ; 8937c4641d0SOliver TappeHOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ; 8947c4641d0SOliver TappeHOST_LD ?= ${HOST_GCC_LD} ; 8957c4641d0SOliver TappeHOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ; 8962a5d0aafSIngo WeinholdHOST_SHA256 ?= ${HOST_SHA256} ; 8978b5934c9SIngo Weinhold 898e173a1ecSIngo WeinholdHOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ; 899e173a1ecSIngo WeinholdHAIKU_PORTS ?= ${HAIKU_PORTS} ; 900e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ; 901c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ; 902e173a1ecSIngo Weinhold 903c4786ea6SlilloEOF 904c4786ea6Slillo 905c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do 906c0e8cc1aSIngo Weinhold variables=" 907c0e8cc1aSIngo Weinhold HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION 908c0e8cc1aSIngo Weinhold HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE 909c0e8cc1aSIngo Weinhold HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR 910c0e8cc1aSIngo Weinhold HAIKU_CPU HAIKU_CPU 911c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC 912c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX 913c0e8cc1aSIngo Weinhold HAIKU_AR HAIKU_AR 914c0e8cc1aSIngo Weinhold HAIKU_CC HAIKU_CC 915c2b76f7fSJonathan Schleifer HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG 916c0e8cc1aSIngo Weinhold HAIKU_LD HAIKU_LD 917c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY HAIKU_OBJCOPY 918c0e8cc1aSIngo Weinhold HAIKU_RANLIB HAIKU_RANLIB 919c0e8cc1aSIngo Weinhold HAIKU_ELFEDIT HAIKU_ELFEDIT 920c0e8cc1aSIngo Weinhold HAIKU_STRIP HAIKU_STRIP 921c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS HAIKU_CPPFLAGS 922c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS HAIKU_CCFLAGS 923c0e8cc1aSIngo Weinhold HAIKU_C++FLAGS HAIKU_CXXFLAGS 924c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS HAIKU_LDFLAGS 925c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS HAIKU_ARFLAGS 926c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS HAIKU_UNARFLAGS 927c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE 928c0e8cc1aSIngo Weinhold " 929c0e8cc1aSIngo Weinhold set -- $variables 930c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 931c0e8cc1aSIngo Weinhold value=`get_variable ${2}_$targetArch` 932c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile" 933c0e8cc1aSIngo Weinhold shift 2 934c0e8cc1aSIngo Weinhold done 935b1e5b60cSAxel Dörfler 936c0e8cc1aSIngo Weinhold # For variables that may have long values, distribute them over multiple 937c0e8cc1aSIngo Weinhold # lines so that jam doesn't hit the maximum line length. 938c0e8cc1aSIngo Weinhold variables=" 93966a7f29fSJérôme Duval HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR 940c0e8cc1aSIngo Weinhold " 941c0e8cc1aSIngo Weinhold set -- $variables 942c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 943c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= " >> "$buildConfigFile" 944c0e8cc1aSIngo Weinhold get_variable ${2}_$targetArch | xargs -n 1 echo " " \ 945c0e8cc1aSIngo Weinhold >> "$buildConfigFile" 946c0e8cc1aSIngo Weinhold echo " ;" >> "$buildConfigFile" 947c0e8cc1aSIngo Weinhold shift 2 948c0e8cc1aSIngo Weinhold done 949c0e8cc1aSIngo Weinholddone 950b1e5b60cSAxel Dörfler 951b1e5b60cSAxel Dörfler 9529b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory. 953338b8dc3SIngo Weinhold 954338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 955338b8dc3SIngo Weinhold# automatically generated Jamfile 956338b8dc3SIngo Weinhold 957338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 958338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 959338b8dc3SIngo Weinhold 960338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 961338b8dc3SIngo Weinhold 962338b8dc3SIngo WeinholdEOF 963d73993ffSAugustin Cavalier 964d73993ffSAugustin Cavalierecho "Configured successfully!" 965