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: 15*825700d3SAugustin Cavalier --help Prints out this help. 16*825700d3SAugustin Cavalier --update Re-runs last configure invocation [must be given 17*825700d3SAugustin Cavalier as first option!] 18e173a1ecSIngo Weinhold --bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo> 19e173a1ecSIngo Weinhold Prepare for a bootstrap build. No pre-built 20e173a1ecSIngo Weinhold packages will be used, instead they will be built 21e173a1ecSIngo Weinhold from the sources (in several phases). 22e173a1ecSIngo Weinhold <haikuporter> is the path to the haikuporter tool 23e173a1ecSIngo Weinhold suitable for the host platform. 24e173a1ecSIngo Weinhold <HaikuPorts cross repo> is the path to a checked 25e173a1ecSIngo Weinhold out HaikuPorts cross-compilation repository. 26e173a1ecSIngo Weinhold <HaikuPorts repo> is the path to a checked out 27e173a1ecSIngo Weinhold HaikuPorts repository. 28c0e8cc1aSIngo Weinhold --build-cross-tools <arch> [ <build tools dir> ] 29338b8dc3SIngo Weinhold Assume cross compilation. <build tools dir> 30338b8dc3SIngo Weinhold defines the location of the build tools sources. 31338b8dc3SIngo Weinhold They will be compiled and placed in the output 32a5b60fa8SOliver Tappe directory under "cross-tools". The HAIKU_* tools 33a5b60fa8SOliver Tappe variables will be set accordingly. 3420ab75e6SIngo Weinhold <arch> specifies the target architecture, either 351b38c341SAlexander von Gluck IV "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm" 36c0e8cc1aSIngo Weinhold This option and --cross-tools-prefix can be 37c0e8cc1aSIngo Weinhold specified multiple times. The first cross tools 38c0e8cc1aSIngo Weinhold specify the primary tools, the subsequent ones the 39c0e8cc1aSIngo Weinhold secondary tools (for "hybrid" images). 40c0e8cc1aSIngo Weinhold For the first --build-cross-tools the 41c0e8cc1aSIngo Weinhold <build tools dir> argument must be specified and 42c0e8cc1aSIngo Weinhold for the subsequent ones it must be omitted. 43eccc7665SIngo Weinhold --cross-tools-prefix <prefix> 44eccc7665SIngo Weinhold Assume cross compilation. <prefix> should be a 45eccc7665SIngo Weinhold path to the directory where the cross 46eccc7665SIngo Weinhold compilation tools are located, plus the platform 470da9c208SIngo Weinhold prefix, e.g. "/path/to/tools/i586-pc-haiku-". 48eccc7665SIngo Weinhold This overrides the HAIKU_* tool variables. 49a66c32ddSIngo Weinhold --distro-compatibility <level> 50a66c32ddSIngo Weinhold The distribution's level of compatibility with 51a66c32ddSIngo Weinhold the official Haiku distribution. The generated 52a66c32ddSIngo Weinhold files will contain the respective trademarks 53a66c32ddSIngo Weinhold accordingly. 54a66c32ddSIngo Weinhold official -- the official Haiku distribution. 55a66c32ddSIngo Weinhold compatible -- a Haiku Compatible (tm) distro. 56a66c32ddSIngo Weinhold default -- any other distro (default value). 572ebcd86dSIngo Weinhold --host-only Configure for building tools for the build host 582ebcd86dSIngo Weinhold only. Haiku cannot be built when configured like 592ebcd86dSIngo Weinhold this. 6067838392SAxel Dörfler --include-patented-code Enable code that is known to implemented patented 6167838392SAxel Dörfler ideas and techniques. If this option is not 6267838392SAxel Dörfler specified, the resulting distribution may still 6367838392SAxel Dörfler implement patented ideas and techniques. This 64*825700d3SAugustin Cavalier option only enables code that is currently known 6567838392SAxel Dörfler to be problematic. 6676fa0be3SIngo Weinhold --include-sources Includes the source code of projects that require 6776fa0be3SIngo Weinhold either an offer of source code or a copy of the 6876fa0be3SIngo Weinhold patched sources. This is preferable when 6976fa0be3SIngo Weinhold distributing on physical mediums. 701974210fSFrançois Revol --include-3rdparty Include 3rdparty/ in the build system. 714880ae01SJessica Hamilton -j<n> Only relevant for --build-cross-tools. Is passed 724880ae01SJessica Hamilton on to the make building the build tools. 73aa2e5ecaSOliver Tappe --no-downloads Do not download anything. Useful when trying to 74aa2e5ecaSOliver Tappe bootstrap and build Haiku from source only. 757c4641d0SOliver Tappe --target=TARGET Select build target platform. 767c4641d0SOliver Tappe [default=${TARGET_PLATFORM}] 77deb1a319SAlexander von Gluck IV valid targets=r5,bone,dano,haiku 78483b28e4SIngo Weinhold --target-arch <arch> Haiku only: Specify the target architecture to 79483b28e4SIngo Weinhold build for. Must be one of the architectures of the 80483b28e4SIngo Weinhold host system. The installed build tools for that 81483b28e4SIngo Weinhold architecture will be used. 82483b28e4SIngo Weinhold This option can be specified multiple times. The 83483b28e4SIngo Weinhold first occurrence specifies the primary 84483b28e4SIngo Weinhold architecture of the Haiku to build, subsequent 85483b28e4SIngo Weinhold ones the secondary architectures. 86d73993ffSAugustin Cavalier --use-clang <arch> Build with host Clang instead of GCC cross 87d73993ffSAugustin Cavalier compiler, targeting <arch> 88eccc7665SIngo Weinhold --use-gcc-pipe Build with GCC option -pipe. Speeds up the build 895a34a443SFrançois Revol process, but uses more memory. 90ed38d2efSJerome Duval --use-gcc-graphite Build with GCC Graphite engine for loop 91ed38d2efSJerome Duval optimizations. Only for gcc 4. 920385b065SIngo Weinhold --use-32bit Use -m32 flag on 64bit host gcc compiler. 93bc96e8f3SIngo Weinhold --use-xattr Use Linux xattr respectively *BSD extattr support 94bc96e8f3SIngo Weinhold for BeOS attribute emulation. Warning: Make sure 95bc96e8f3SIngo Weinhold your file system supports sufficient attribute 96bc96e8f3SIngo Weinhold sizes (4 KB per file for all attributes won't 97bc96e8f3SIngo Weinhold suffice). 98bc96e8f3SIngo Weinhold --use-xattr-ref Use the generic BeOS attribute emulation, but use 99bc96e8f3SIngo Weinhold Linux xattr respectively *BSD extattr support to 100bc96e8f3SIngo Weinhold make it more robust (i.e. attribute mix-ups become 101bc96e8f3SIngo Weinhold less likely). 1024da6cf84SFrançois Revol --with-gdb <gdb sources dir> 1034da6cf84SFrançois Revol specify the path to a GDB source dir, to build 1044da6cf84SFrançois Revol GDB for each arch we build the cross-tools for. 105338b8dc3SIngo Weinhold 106338b8dc3SIngo Weinholdenvironment variables: 10763701e7dSOliver Tappe CC The host compiler. Defaults to "gcc". 10865706842SAugustin Cavalier HAIKU_AR_<arch> The static library archiver for <arch>. 109c0e8cc1aSIngo Weinhold Defaults to "ar". 11065706842SAugustin Cavalier HAIKU_CC_<arch> The compiler for <arch>. Defaults to "gcc". 11165706842SAugustin Cavalier HAIKU_LD_<arch> The <arch> linker. Defaults to "ld". 11265706842SAugustin Cavalier HAIKU_OBJCOPY_<arch> The <arch> objcopy to be used. Defaults to 113c0e8cc1aSIngo Weinhold "objcopy". 11465706842SAugustin Cavalier HAIKU_RANLIB_<arch> The static library indexer for <arch>. Defaults 115c0e8cc1aSIngo Weinhold to "ranlib". 11665706842SAugustin Cavalier HAIKU_STRIP_<arch> The <arch> strip command. Defaults to "strip". 117a04a520bSJonathan Schleifer HAIKU_NASM The nasm assembler (x86 and x86_64 only). 118c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS_<arch> The preprocessor flags for target architecture 119c0e8cc1aSIngo Weinhold <arch>. Defaults to "". 120c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS_<arch> The C flags for target architecture <arch>. 121c0e8cc1aSIngo Weinhold Defaults to "". 122c0e8cc1aSIngo Weinhold HAIKU_CXXFLAGS_<arch> The C++ flags for target architecture <arch>. 123c0e8cc1aSIngo Weinhold Defaults to "". 124c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS_<arch> The linker flags for target architecture <arch>. 125c0e8cc1aSIngo Weinhold Defaults to "". 126c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS_<arch> The flags passed to HAIKU_AR for target 127c0e8cc1aSIngo Weinhold architecture <arch> for archiving. Defaults to 128c0e8cc1aSIngo Weinhold "cru". 129c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS_<arch> The flags passed to HAIKU_AR for target 130c0e8cc1aSIngo Weinhold architecture <arch> for unarchiving. Defaults to 131c0e8cc1aSIngo Weinhold "x". 13264f6da31SIngo Weinhold 133c0e8cc1aSIngo WeinholdNon-default output directories: 13464f6da31SIngo Weinhold By default all objects, build configuration, and other related files are 13564f6da31SIngo Weinhold stored in /path/to/haiku_source/generated. To store objects in a non-default 13664f6da31SIngo Weinhold location, run "../../relative/path/to/haiku_source/configure <options>" from 13764f6da31SIngo Weinhold within your non-default location. "jam [ options ] targets" can then be run 13864f6da31SIngo Weinhold directly inside your non-default location. Another option is to invoke "jam 13964f6da31SIngo Weinhold [ options ] targets" from within haiku_source. This can be accomplished by 14064f6da31SIngo Weinhold either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking 14164f6da31SIngo Weinhold jam or by creating a symlink of haiku_source/generated pointing to your 14264f6da31SIngo Weinhold non-default location and running jam. 14364f6da31SIngo Weinhold 14464f6da31SIngo Weinhold 145022fa244SIngo WeinholdEOF 146022fa244SIngo Weinhold} 147022fa244SIngo Weinhold 148022fa244SIngo Weinhold# assertparam 149022fa244SIngo Weinhold# 150022fa244SIngo Weinhold# Checks whether at least one parameter is left. 151022fa244SIngo Weinhold# 152022fa244SIngo Weinholdassertparam() 153022fa244SIngo Weinhold{ 15420ab75e6SIngo Weinhold if [ $2 -lt 2 ]; then 155022fa244SIngo Weinhold echo $0: \`$1\': Parameter expected. 156022fa244SIngo Weinhold exit 1 157022fa244SIngo Weinhold fi 158022fa244SIngo Weinhold} 159022fa244SIngo Weinhold 16020ab75e6SIngo Weinhold# assertparams 16120ab75e6SIngo Weinhold# 16220ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left. 16320ab75e6SIngo Weinhold# 16420ab75e6SIngo Weinholdassertparams() 16520ab75e6SIngo Weinhold{ 16620ab75e6SIngo Weinhold if [ $3 -le $2 ]; then 16720ab75e6SIngo Weinhold echo $0: \`$1\': Not enough parameters. 16820ab75e6SIngo Weinhold exit 1 16920ab75e6SIngo Weinhold fi 17020ab75e6SIngo Weinhold} 17120ab75e6SIngo Weinhold 172e173a1ecSIngo Weinhold# absolute_path 173e173a1ecSIngo Weinhold# 174e173a1ecSIngo Weinhold# returns the absolute path of a given path. 175e173a1ecSIngo Weinhold# 176e173a1ecSIngo Weinholdabsolute_path() 177e173a1ecSIngo Weinhold{ 1786a4f3954SFrançois Revol if [ "x$1" != "x${1#/}" ]; then 179e173a1ecSIngo Weinhold echo "$1" 180e173a1ecSIngo Weinhold else 181e173a1ecSIngo Weinhold echo "`pwd`/$1" 182e173a1ecSIngo Weinhold fi 183e173a1ecSIngo Weinhold} 184e173a1ecSIngo Weinhold 18539d444a3SArvind S Raj# check_dir_exists 18639d444a3SArvind S Raj# 18739d444a3SArvind S Raj# check if a directory exists or not 18839d444a3SArvind S Raj# 18939d444a3SArvind S Rajcheck_dir_exists() 19039d444a3SArvind S Raj{ 19139d444a3SArvind S Raj if [ -d "$1" ]; then 19239d444a3SArvind S Raj return 0 19339d444a3SArvind S Raj else 19439d444a3SArvind S Raj return 1 19539d444a3SArvind S Raj fi 19639d444a3SArvind S Raj} 19739d444a3SArvind S Raj 198502882dbSJessica Hamilton# check_file_exists 199502882dbSJessica Hamilton# 200502882dbSJessica Hamilton# check if a file exists or not 201502882dbSJessica Hamilton# 202502882dbSJessica Hamiltoncheck_file_exists() 203502882dbSJessica Hamilton{ 204502882dbSJessica Hamilton if [ -f "$1" ]; then 205502882dbSJessica Hamilton return 0 206502882dbSJessica Hamilton else 207502882dbSJessica Hamilton return 1 208502882dbSJessica Hamilton fi 209502882dbSJessica Hamilton} 210502882dbSJessica Hamilton 2119a001156SOliver Tappe# real_path 2129a001156SOliver Tappe# 2139a001156SOliver Tappe# returns the realpath of a symbolic link. 2149a001156SOliver Tappe# 2159a001156SOliver Tappereal_path() 2169a001156SOliver Tappe{ 2179a001156SOliver Tappe perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1" 2189a001156SOliver Tappe} 2199a001156SOliver Tappe 22009c5682dSIngo Weinhold# standard_gcc_settings 22109c5682dSIngo Weinhold# 22209c5682dSIngo Weinhold# Sets the variables for a GCC platform. 22309c5682dSIngo Weinhold# 22409c5682dSIngo Weinholdstandard_gcc_settings() 22509c5682dSIngo Weinhold{ 22665706842SAugustin Cavalier local gcc="$1" 227c0e8cc1aSIngo Weinhold 228138f5fb4SIngo Weinhold if which greadlink > /dev/null 2>&1; then 229b29b48b1SMatt Madia readlink="greadlink -e" 230138f5fb4SIngo Weinhold elif which realpath > /dev/null 2>&1; then 231b29b48b1SMatt Madia readlink=realpath 2329a001156SOliver Tappe elif readlink -e / > /dev/null 2>&1; then 233b29b48b1SMatt Madia readlink="readlink -e" 2349a001156SOliver Tappe else 2359a001156SOliver Tappe readlink=real_path 236b4b6d83cSMatt Madia fi 237138f5fb4SIngo Weinhold 23809c5682dSIngo Weinhold # PLATFORM_LINKLIBS 239c0e8cc1aSIngo Weinhold local gcclib=`$gcc -print-libgcc-file-name` 240c0e8cc1aSIngo Weinhold local gccdir=`dirname ${gcclib}` 2415b0f7b1bSOliver Tappe 242c0e8cc1aSIngo Weinhold local gccRawVersion=`$gcc -dumpversion` 243c0e8cc1aSIngo Weinhold local gccMachine=`$gcc -dumpmachine` 244338b8dc3SIngo Weinhold 245fc8967f1SIngo Weinhold # determine architecture from machine triple 246c0e8cc1aSIngo Weinhold case $gccMachine in 247c0e8cc1aSIngo Weinhold arm-*) targetCpu=arm;; 248c0e8cc1aSIngo Weinhold i?86-*) targetCpu=x86;; 249c0e8cc1aSIngo Weinhold m68k-*) targetCpu=m68k;; 250c0e8cc1aSIngo Weinhold powerpc-*) targetCpu=ppc;; 251c0e8cc1aSIngo Weinhold x86_64-*) targetCpu=x86_64;; 252fc8967f1SIngo Weinhold *) 253c0e8cc1aSIngo Weinhold echo "Unsupported gcc target machine: $gccMachine" >&2 254fc8967f1SIngo Weinhold exit 1 255fc8967f1SIngo Weinhold ;; 256fc8967f1SIngo Weinhold esac 257fc8967f1SIngo Weinhold 258c0e8cc1aSIngo Weinhold local targetArch=$targetCpu 259fc8967f1SIngo Weinhold 260c0e8cc1aSIngo Weinhold case $gccRawVersion in 2616cc8eecfSOliver Tappe 2.9*) 2625b0f7b1bSOliver Tappe # check for correct (most up-to-date) legacy compiler and complain 2635b0f7b1bSOliver Tappe # if an older one is installed 264c0e8cc1aSIngo Weinhold if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then 2655b0f7b1bSOliver Tappe echo "GCC version $haikuRequiredLegacyGCCVersion is required!"; 2665b0f7b1bSOliver Tappe echo "Please download it from www.haiku-os.org..."; 2675b0f7b1bSOliver Tappe exit 1; 2685b0f7b1bSOliver Tappe fi 269aaeadfcbSAlex Smith 270c0e8cc1aSIngo Weinhold targetArch=x86_gcc2 2715b0f7b1bSOliver Tappe ;; 2728b5934c9SIngo Weinhold esac 27365ad1ba3SAlex Smith 274c0e8cc1aSIngo Weinhold local bootLibgcc 275c0e8cc1aSIngo Weinhold local bootLibSupCxx 27666a7f29fSJérôme Duval local bootCxxHeaders 277c0e8cc1aSIngo Weinhold case $gccMachine in 2784591ebc9SAlex Smith x86_64-*) 27966a7f29fSJérôme Duval # Boot loader is 32-bit, need the 32-bit libs and c++ config 28011ae3c5fSOliver Tappe bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` 281c0e8cc1aSIngo Weinhold bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` 28266a7f29fSJérôme Duval 28366a7f29fSJérôme Duval local headersBase=$gccdir/../../../.. 28466a7f29fSJérôme Duval local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion 28566a7f29fSJérôme Duval if [ ! -d $headers ]; then 28666a7f29fSJérôme Duval headers=$headersBase/include/c++/$gccRawVersion 28766a7f29fSJérôme Duval fi 28866a7f29fSJérôme Duval bootCxxHeaders="$headers/$gccMachine/32" 2894591ebc9SAlex Smith ;; 290338b8dc3SIngo Weinhold esac 291c0e8cc1aSIngo Weinhold 292c0e8cc1aSIngo Weinhold # determine whether graphite loop optimization should/can be used 293c0e8cc1aSIngo Weinhold local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu` 294c0e8cc1aSIngo Weinhold if [ -z "$useGraphite" ]; then 295c0e8cc1aSIngo Weinhold useGraphite=$useGccGraphiteDefault 296c0e8cc1aSIngo Weinhold fi 297c0e8cc1aSIngo Weinhold 298c0e8cc1aSIngo Weinhold if [ "$useGraphite" != 0 ]; then 299c0e8cc1aSIngo Weinhold UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1` 300c0e8cc1aSIngo Weinhold if [ $? != 0 ]; then 301c0e8cc1aSIngo Weinhold echo "GCC Graphite loop optimizations cannot be used on $targetArch" 302c0e8cc1aSIngo Weinhold useGraphite=0 303c0e8cc1aSIngo Weinhold fi 304c0e8cc1aSIngo Weinhold fi 305c0e8cc1aSIngo Weinhold 306c0e8cc1aSIngo Weinhold set_variable HAIKU_CPU_$targetArch $targetCpu 307c0e8cc1aSIngo Weinhold 308c0e8cc1aSIngo Weinhold get_build_tool_path CC_$targetArch "$gcc" 309a7bddff1SJonathan Schleifer set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang 310c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion 311c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine 312c0e8cc1aSIngo Weinhold set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir 31366a7f29fSJérôme Duval set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" 31411ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" 31511ae3c5fSOliver Tappe set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc 316c0e8cc1aSIngo Weinhold set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite 317c0e8cc1aSIngo Weinhold 318c0e8cc1aSIngo Weinhold standard_gcc_settings_targetArch=$targetArch 319c0e8cc1aSIngo Weinhold} 320c0e8cc1aSIngo Weinhold 321c0e8cc1aSIngo Weinhold# set_variable 322c0e8cc1aSIngo Weinhold# 323c0e8cc1aSIngo Weinhold# Set the value of a variable. 324c0e8cc1aSIngo Weinhold# 325c0e8cc1aSIngo Weinholdset_variable() 326c0e8cc1aSIngo Weinhold{ 327c0e8cc1aSIngo Weinhold eval "$1=\"$2\"" 328c0e8cc1aSIngo Weinhold} 329c0e8cc1aSIngo Weinhold 330c0e8cc1aSIngo Weinhold# get_variable 331c0e8cc1aSIngo Weinhold# 332c0e8cc1aSIngo Weinhold# Echo the value of a variable. 333c0e8cc1aSIngo Weinhold# 334c0e8cc1aSIngo Weinholdget_variable() 335c0e8cc1aSIngo Weinhold{ 336c0e8cc1aSIngo Weinhold eval "echo \${$1}" 33709c5682dSIngo Weinhold} 33809c5682dSIngo Weinhold 339338b8dc3SIngo Weinhold# set_default_value 340338b8dc3SIngo Weinhold# 341338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 342338b8dc3SIngo Weinhold# 343338b8dc3SIngo Weinholdset_default_value() 344338b8dc3SIngo Weinhold{ 3450838a930SJérôme Duval eval "$1=\${$1-$2}" 346338b8dc3SIngo Weinhold} 347338b8dc3SIngo Weinhold 348338b8dc3SIngo Weinhold# get_build_tool_path 349338b8dc3SIngo Weinhold# 350338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 351338b8dc3SIngo Weinhold# 352338b8dc3SIngo Weinholdget_build_tool_path() 353338b8dc3SIngo Weinhold{ 354338b8dc3SIngo Weinhold local var="HAIKU_$1" 35565706842SAugustin Cavalier local varval="`get_variable $var`" 35665706842SAugustin Cavalier local cmd="$2" 357d73993ffSAugustin Cavalier 358e042a53bSAugustin Cavalier if [ ! -z "$varval" ]; then 359d73993ffSAugustin Cavalier # this variable is already set (probably by user) so grab its contents 360e042a53bSAugustin Cavalier cmd=$varval 361d73993ffSAugustin Cavalier fi 362d73993ffSAugustin Cavalier 363d73993ffSAugustin Cavalier local path=${cmd%% *} 364338b8dc3SIngo Weinhold 365338b8dc3SIngo Weinhold if [ -f "$path" ]; then 36665706842SAugustin Cavalier # get absolute path from relative path 367a559f87aSFrançois Revol local oldPwd="`pwd`" 368a559f87aSFrançois Revol cd "`dirname "$path"`" 369a559f87aSFrançois Revol path="`pwd`/`basename "$path"`" 370338b8dc3SIngo Weinhold cd $oldPwd 371338b8dc3SIngo Weinhold else 3727fe2e06cSMatt Madia which "$path" > /dev/null 2>&1 || { 373d73993ffSAugustin Cavalier echo "Build tool \"$path\" not found (maybe specify it in $var?)" >&2 374338b8dc3SIngo Weinhold exit 1 375338b8dc3SIngo Weinhold } 376338b8dc3SIngo Weinhold fi 377338b8dc3SIngo Weinhold 37865706842SAugustin Cavalier if test "${cmd#* }" != "$cmd"; then 37965706842SAugustin Cavalier # $cmd contains arguments, so preserve them (and only them) 38065706842SAugustin Cavalier cmd=${cmd#* } 38165706842SAugustin Cavalier else 38265706842SAugustin Cavalier # $cmd does not contain arguments, so unset it 38365706842SAugustin Cavalier cmd= 38465706842SAugustin Cavalier fi 38565706842SAugustin Cavalier eval "$var=\"$path $cmd\"" 386338b8dc3SIngo Weinhold} 387338b8dc3SIngo Weinhold 388483b28e4SIngo Weinholdis_in_list() 389483b28e4SIngo Weinhold{ 390483b28e4SIngo Weinhold local element 391483b28e4SIngo Weinhold for element in $2; do 392483b28e4SIngo Weinhold if [ "$1" = "$element" ]; then 393483b28e4SIngo Weinhold return 0 394483b28e4SIngo Weinhold fi 395483b28e4SIngo Weinhold done 396483b28e4SIngo Weinhold return 1 397483b28e4SIngo Weinhold} 398483b28e4SIngo Weinhold 3997f9beaf1SOliver Tappe# check for --help or -h and show usage immediately 4007f9beaf1SOliver Tappeif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then 4018b420c2fSOliver Tappe usage; exit 0; 4028b420c2fSOliver Tappefi 4038b420c2fSOliver Tappe 404c6c03d56SAugustin Cavalier# ensure umask is not too restrictive 405c6c03d56SAugustin Cavalierif [ $(umask) -gt 22 ]; then 406c6c03d56SAugustin Cavalier echo "Your umask is too restrictive (should be: <= 0022; is actually:" $(umask)")" 407c6c03d56SAugustin Cavalier exit 1 408c6c03d56SAugustin Cavalierfi 4098b420c2fSOliver Tappe 410338b8dc3SIngo Weinhold# get cwd and the source directory 411338b8dc3SIngo WeinholdcurrentDir=`pwd` 4126e7c6fe5SIngo Weinholdcd `dirname "$0"` 413338b8dc3SIngo WeinholdsourceDir=`pwd` 4146e7c6fe5SIngo Weinholdcd "$currentDir" 415338b8dc3SIngo Weinhold 41655d267a4SFrançois Revol# backup the passed arguments 41755d267a4SFrançois RevolconfigureArgs="$@" 418*825700d3SAugustin CavalierconfigurePath=$0 419*825700d3SAugustin Cavalier 420*825700d3SAugustin Cavalier# backup relevant environs 421*825700d3SAugustin CavalierconfigureEnvirons= 422*825700d3SAugustin Cavalierfor var in `env`; do 423*825700d3SAugustin Cavalier case "$var" in 424*825700d3SAugustin Cavalier CC\=*|HAIKU*\=*) 425*825700d3SAugustin Cavalier configureEnvirons="$configureEnvirons $var" 426*825700d3SAugustin Cavalier ;; 427*825700d3SAugustin Cavalier esac 428*825700d3SAugustin Cavalierdone 42955d267a4SFrançois Revol 4307c4641d0SOliver Tappe# internal default parameter values 431022fa244SIngo Weinhold# 43252a38012Sejakowatzplatform=`uname` 4335abd9a46SIngo WeinholdplatformMachine=`uname -m` 434c0e8cc1aSIngo WeinholdtargetArchs= 435338b8dc3SIngo WeinholdbuildCrossTools= 43629ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" 43760d8d8fcSIngo WeinholdbuildCrossToolsJobs= 438c2b76f7fSJonathan SchleiferuseClang=0 439c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0 440c0e8cc1aSIngo WeinholdunknownArchIndex=1 441483b28e4SIngo WeinholdhaikuTargetArchs= 4424da6cf84SFrançois RevolgdbSources= 4437c4641d0SOliver Tappe 44463701e7dSOliver Tappeif [ -z "$CC" ]; then 44563701e7dSOliver Tappe CC=gcc 44663701e7dSOliver Tappefi 44763701e7dSOliver Tappe 4487c4641d0SOliver Tappe# exported (BuildSetup) default parameter values 4497c4641d0SOliver Tappe# 45063701e7dSOliver TappeHOST_GCC_RAW_VERSION=`$CC -dumpversion` 45163701e7dSOliver TappeHOST_GCC_MACHINE=`$CC -dumpmachine` 4527c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0 45376fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0 4547c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0 4557c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default 4567c4641d0SOliver TappeTARGET_PLATFORM=haiku 4577c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0 4587986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0 4597986925fSIngo WeinholdHAIKU_HOST_USE_XATTR=0 460bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF=0 4612ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0 462f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r" 46363701e7dSOliver TappeHOST_GCC_LD=`$CC -print-prog-name=ld` 46463701e7dSOliver TappeHOST_GCC_OBJCOPY=`$CC -print-prog-name=objcopy` 4652a5d0aafSIngo WeinholdHOST_SHA256= 466e173a1ecSIngo WeinholdHOST_HAIKU_PORTER= 467e173a1ecSIngo WeinholdHAIKU_PORTS= 468e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS= 469c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP=0 470e70c4c64SPulkoMandyHAIKU_BOOT_BOARD= 471aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0 4722a5d0aafSIngo Weinhold 473c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS= 474c0e8cc1aSIngo Weinhold 475a04a520bSJonathan Schleiferset_default_value HAIKU_NASM nasm 476c0e8cc1aSIngo Weinhold 4773942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then 4782a5d0aafSIngo Weinhold HOST_SHA256=sha256sum 4793942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then 4802a5d0aafSIngo Weinhold HOST_SHA256="sha256 -q" 481b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then 482b5a871b1SNiels Sascha Reedijk HOST_SHA256="shasum -a 256" 4832a5d0aafSIngo Weinholdelse 4842a5d0aafSIngo Weinhold echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2 4852a5d0aafSIngo Weinhold exit 1 4862a5d0aafSIngo Weinholdfi 487338b8dc3SIngo Weinhold 48884edb1a1SAxel DörflerhaikuRequiredLegacyGCCVersion="2.95.3-haiku-2017_07_20" 489a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion 490af4bf973SOliver Tappe # version of legacy gcc required to build haiku 491483b28e4SIngo WeinholdsupportedTargetArchs=" 492483b28e4SIngo Weinhold arm 493483b28e4SIngo Weinhold m68k 494483b28e4SIngo Weinhold ppc 495483b28e4SIngo Weinhold x86 496483b28e4SIngo Weinhold x86_64 497483b28e4SIngo Weinhold x86_gcc2 498483b28e4SIngo Weinhold " 499af4bf973SOliver Tappe 5007c4641d0SOliver Tappe# determine output directory 5017c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then 5027c4641d0SOliver Tappe outputDir=$currentDir/generated 5037c4641d0SOliver Tappeelse 5047c4641d0SOliver Tappe outputDir=$currentDir 5057c4641d0SOliver Tappefi 5067c4641d0SOliver TappebuildOutputDir="$outputDir/build" 5077c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes" 5087c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig" 5097c4641d0SOliver Tappe 5107c4641d0SOliver Tappe# check for update request 5117c4641d0SOliver Tappeif [ "$1" = "--update" ]; then 5127c4641d0SOliver Tappe if ! [ -e "$buildConfigFile" ]; then 5137c4641d0SOliver Tappe echo $0 --update: \'$buildConfigFile\' not found - updating not possible. 5147c4641d0SOliver Tappe exit 1 5157c4641d0SOliver Tappe fi 516*825700d3SAugustin Cavalier # get last configure invocation and flags from BuildConfig and call ourselves with it 517*825700d3SAugustin Cavalier lastPwd=`grep "#d " "$buildConfigFile" | cut -c 4-` 518*825700d3SAugustin Cavalier lastConfig=`grep "#c " "$buildConfigFile" | cut -c 4-` 519*825700d3SAugustin Cavalier lastEnv=`grep "#e " "$buildConfigFile" | cut -c 4-` 520*825700d3SAugustin Cavalier lastArgs=`grep "#a " "$buildConfigFile" | cut -c 4-` 521*825700d3SAugustin Cavalier if [ -z "$lastConfig" ]; then 522*825700d3SAugustin Cavalier echo "$0 --update: The previous configure invocation was not properly" \ 523*825700d3SAugustin Cavalier "encoded into '$buildConfigFile' - updating not possible." 5247c4641d0SOliver Tappe exit 1 5257c4641d0SOliver Tappe fi 526*825700d3SAugustin Cavalier cd $lastPwd 527*825700d3SAugustin Cavalier export $lastEnv 528*825700d3SAugustin Cavalier $lastConfig $lastArgs 529*825700d3SAugustin Cavalier exit $? 5307c4641d0SOliver Tappefi 5317c4641d0SOliver Tappe 532022fa244SIngo Weinhold# parse parameters 533022fa244SIngo Weinhold# 53420ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do 535022fa244SIngo Weinhold case "$1" in 536e173a1ecSIngo Weinhold --bootstrap) 537e173a1ecSIngo Weinhold assertparams "$1" 3 $# 538e173a1ecSIngo Weinhold HOST_HAIKU_PORTER="`absolute_path $2`" 539e173a1ecSIngo Weinhold HAIKU_PORTS_CROSS="`absolute_path $3`" 540e173a1ecSIngo Weinhold HAIKU_PORTS="`absolute_path $4`" 541c9dd05ffSJonathan Schleifer HAIKU_IS_BOOTSTRAP=1 542c9dd05ffSJonathan Schleifer HAIKU_NO_DOWNLOADS=1 543502882dbSJessica Hamilton check_file_exists "$HOST_HAIKU_PORTER" || ( 544502882dbSJessica Hamilton echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2 54539d444a3SArvind S Raj exit 1 54639d444a3SArvind S Raj ) 54739d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS" || ( 54839d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS" >&2 54939d444a3SArvind S Raj exit 1 55039d444a3SArvind S Raj ) 55139d444a3SArvind S Raj check_dir_exists "$HAIKU_PORTS_CROSS" || ( 55239d444a3SArvind S Raj echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2 55339d444a3SArvind S Raj exit 1 55439d444a3SArvind S Raj ) 555e173a1ecSIngo Weinhold shift 4 556e173a1ecSIngo Weinhold ;; 557c0e8cc1aSIngo Weinhold --build-cross-tools) 558c0e8cc1aSIngo Weinhold if [ -z "$buildCrossTools" ]; then 5599b0dd528SIngo Weinhold assertparams "$1" 2 $# 560c0e8cc1aSIngo Weinhold targetArch=$2 5619b0dd528SIngo Weinhold buildCrossTools=$3 5629b0dd528SIngo Weinhold shift 3 563c0e8cc1aSIngo Weinhold else 564c0e8cc1aSIngo Weinhold assertparam "$1" $# 565c0e8cc1aSIngo Weinhold targetArch=$2 566c0e8cc1aSIngo Weinhold shift 2 567c0e8cc1aSIngo Weinhold fi 568c0e8cc1aSIngo Weinhold case "$targetArch" in 569c0e8cc1aSIngo Weinhold x86_gcc2) targetMachine=i586-pc-haiku;; 570c0e8cc1aSIngo Weinhold x86) targetMachine=i586-pc-haiku;; 571c0e8cc1aSIngo Weinhold x86_64) targetMachine=x86_64-unknown-haiku;; 572c0e8cc1aSIngo Weinhold ppc) targetMachine=powerpc-apple-haiku;; 573c0e8cc1aSIngo Weinhold m68k) targetMachine=m68k-unknown-haiku;; 574c0e8cc1aSIngo Weinhold arm) targetMachine=arm-unknown-haiku;; 575c0e8cc1aSIngo Weinhold *) 576c0e8cc1aSIngo Weinhold echo "Unsupported target architecture: $2" >&2 577c0e8cc1aSIngo Weinhold exit 1 578c0e8cc1aSIngo Weinhold ;; 579c0e8cc1aSIngo Weinhold esac 580c0e8cc1aSIngo Weinhold set_variable buildCrossToolsMachine_$targetArch $targetMachine 581c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 582c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 5839b0dd528SIngo Weinhold ;; 5849b0dd528SIngo Weinhold --cross-tools-prefix) 5859b0dd528SIngo Weinhold assertparam "$1" $# 586c0e8cc1aSIngo Weinhold targetArch=unknown${unknownArchIndex} 587c0e8cc1aSIngo Weinhold set_variable crossToolsPrefix_$targetArch "$2" 588c0e8cc1aSIngo Weinhold targetArchs="$targetArchs $targetArch" 589c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 590d68208faSMatt Madia unknownArchIndex=$(($unknownArchIndex + 1)) 5919b0dd528SIngo Weinhold shift 2 5929b0dd528SIngo Weinhold ;; 593a66c32ddSIngo Weinhold --distro-compatibility) 5949b0dd528SIngo Weinhold assertparam "$1" $# 5957c4641d0SOliver Tappe HAIKU_DISTRO_COMPATIBILITY=$2 5967c4641d0SOliver Tappe case "$HAIKU_DISTRO_COMPATIBILITY" in 597a66c32ddSIngo Weinhold official) ;; 598a66c32ddSIngo Weinhold compatible) ;; 599a66c32ddSIngo Weinhold default) ;; 600a66c32ddSIngo Weinhold *) echo "Invalid distro compatibility" \ 6017c4641d0SOliver Tappe "level: $HAIKU_DISTRO_COMPATIBILITY" 602a66c32ddSIngo Weinhold exit 1;; 603a66c32ddSIngo Weinhold esac 6049b0dd528SIngo Weinhold shift 2 6059b0dd528SIngo Weinhold ;; 6062ebcd86dSIngo Weinhold --host-only) HAIKU_HOST_BUILD_ONLY=1; shift 1;; 6077c4641d0SOliver Tappe --include-patented-code) HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;; 60876fa0be3SIngo Weinhold --include-sources) HAIKU_INCLUDE_SOURCES=1; shift 1;; 6097c4641d0SOliver Tappe --include-3rdparty) HAIKU_INCLUDE_3RDPARTY=1; shift 1;; 61060d8d8fcSIngo Weinhold -j*) buildCrossToolsJobs="$1"; shift 1;; 611aa2e5ecaSOliver Tappe --no-downloads) HAIKU_NO_DOWNLOADS=1; shift 1;; 6127c4641d0SOliver Tappe --target=*) TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;; 613483b28e4SIngo Weinhold --target-arch) 614483b28e4SIngo Weinhold assertparam "$1" $# 615483b28e4SIngo Weinhold targetArch=$2 616483b28e4SIngo Weinhold shift 2 617483b28e4SIngo Weinhold if [ ! "$platform" = Haiku ]; then 618483b28e4SIngo Weinhold echo "--target-arch can only be specified on Haiku." >&2 619483b28e4SIngo Weinhold exit 1 620483b28e4SIngo Weinhold fi 621483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 622483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 623483b28e4SIngo Weinhold exit 1 624483b28e4SIngo Weinhold ) 625483b28e4SIngo Weinhold haikuTargetArchs="$haikuTargetArchs $targetArch" 626483b28e4SIngo Weinhold ;; 627d73993ffSAugustin Cavalier --use-clang) 628d73993ffSAugustin Cavalier assertparam "$1" $# 629d73993ffSAugustin Cavalier targetArch=$2 630d73993ffSAugustin Cavalier useClang=1 631d73993ffSAugustin Cavalier case "$targetArch" in 632d73993ffSAugustin Cavalier x86) targetMachine=i586-pc-haiku;; 633d73993ffSAugustin Cavalier x86_64) targetMachine=x86_64-unknown-haiku;; 634d73993ffSAugustin Cavalier *) 635d73993ffSAugustin Cavalier echo "Unsupported target architecture: $2" >&2 636d73993ffSAugustin Cavalier exit 1 637d73993ffSAugustin Cavalier ;; 638d73993ffSAugustin Cavalier esac 63965706842SAugustin Cavalier get_build_tool_path clang clang 64065706842SAugustin Cavalier if [ -n "crossToolsPrefix_$targetArch" ]; then 64165706842SAugustin Cavalier set_variable crossToolsPrefix_$targetArch llvm- 64265706842SAugustin Cavalier fi 643d73993ffSAugustin Cavalier targetArchs="$targetArchs $targetArch" 644d73993ffSAugustin Cavalier HAIKU_PACKAGING_ARCHS= 645d73993ffSAugustin Cavalier shift 2 646d73993ffSAugustin Cavalier ;; 6477c4641d0SOliver Tappe --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;; 648c0e8cc1aSIngo Weinhold --use-gcc-graphite) useGccGraphiteDefault=1; shift 1;; 6497986925fSIngo Weinhold --use-32bit) HAIKU_HOST_USE_32BIT=1; shift 1;; 6507986925fSIngo Weinhold --use-xattr) HAIKU_HOST_USE_XATTR=1; shift 1;; 651bc96e8f3SIngo Weinhold --use-xattr-ref) HAIKU_HOST_USE_XATTR_REF=1; shift 1;; 6524da6cf84SFrançois Revol --with-gdb) gdbSources=$2; shift 2;; 653022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 654022fa244SIngo Weinhold esac 655022fa244SIngo Weinholddone 656022fa244SIngo Weinhold 6570df3cc9cSIngo Weinhold# detect the build platform 658338b8dc3SIngo Weinholdcase "${platform}" in 6597c4641d0SOliver Tappe Darwin) HOST_PLATFORM=darwin ;; 6607c4641d0SOliver Tappe FreeBSD) HOST_PLATFORM=freebsd 6617986925fSIngo Weinhold if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then 6625abd9a46SIngo Weinhold echo Unsupported platform: FreeBSD ${platformMachine} 663308c212cSIngo Weinhold exit 1 664308c212cSIngo Weinhold fi ;; 6657c4641d0SOliver Tappe Haiku) HOST_PLATFORM=haiku_host ;; 6667c4641d0SOliver Tappe Linux) HOST_PLATFORM=linux ;; 6677c4641d0SOliver Tappe OpenBSD) HOST_PLATFORM=openbsd ;; 6687c4641d0SOliver Tappe SunOS) HOST_PLATFORM=sunos ;; 6697c4641d0SOliver Tappe CYGWIN_NT-*) HOST_PLATFORM=cygwin ;; 670338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 6714cbe4925SAxel Dörfler exit 1 ;; 6724cbe4925SAxel Dörfleresac 67352a38012Sejakowatz 6740962132cSAlex Smith# check for case-sensitive filesystem 6750962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null 6760962132cSAlex Smithmkdir haikucasetest 2>/dev/null 6770962132cSAlex SmithcaseInsensitive=$? 67897f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null 6790962132cSAlex Smithif [ $caseInsensitive != 0 ]; then 6803ecc5287SMichael Lotz echo "You need a case-sensitive file-system to build Haiku." 6810962132cSAlex Smith if [ $HOST_PLATFORM = "darwin" ]; then 6827a05e252SJohn Scipione echo "You can create a case-sensitive disk image using Disk Utility." 6833ecc5287SMichael Lotz fi 6840962132cSAlex Smith exit 1 6853ecc5287SMichael Lotzfi 6863ecc5287SMichael Lotz 687f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed 688f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then 689f04f7042SNiels Sascha Reedijk HOST_EXTENDED_REGEX_SED="sed -E" 690f04f7042SNiels Sascha Reedijkfi 691f04f7042SNiels Sascha Reedijk 692cb721c59SFrançois Revol# check if nasm can actually output ELF files 693cb721c59SFrançois Revol# (the stock version in OSX can't) 694cb721c59SFrançois Revol# XXX: should probably only test for x86* arch 6953e6c09cdSAdrien Destuguesif [ "$("$HAIKU_NASM" -hf | grep -c elf'[36][24] ')" -ne "2" ]; then 696cb721c59SFrançois Revol echo "$HAIKU_NASM cannot generate ELF files. Please install a working version." 697cb721c59SFrançois Revol if [ $HOST_PLATFORM = "darwin" ]; then 698cb721c59SFrançois Revol echo "You can install it from Mac Ports." 699cb721c59SFrançois Revol echo "Mac Ports is available at: http://www.macports.org/" 700cb721c59SFrançois Revol fi 701cb721c59SFrançois Revol exit 1 702cb721c59SFrançois Revolfi 703cb721c59SFrançois Revol 704338b8dc3SIngo Weinhold# create output directory 7056e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1 706338b8dc3SIngo Weinhold 7072ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then 7082ebcd86dSIngo Weinhold invalidCommand=$sourceDir/build/scripts/host_build_only 7092ebcd86dSIngo Weinhold HAIKU_AR=$invalidCommand 7102ebcd86dSIngo Weinhold HAIKU_CC=$invalidCommand 7112ebcd86dSIngo Weinhold HAIKU_LD=$invalidCommand 7122ebcd86dSIngo Weinhold HAIKU_OBJCOPY=$invalidCommand 7132ebcd86dSIngo Weinhold HAIKU_RANLIB=$invalidCommand 7142ebcd86dSIngo Weinhold HAIKU_ELFEDIT=$invalidCommand 715d6f80927SJonathan Schleifer HAIKU_NASM=$invalidCommand 7162ebcd86dSIngo Weinhold HAIKU_STRIP=$invalidCommand 7172ebcd86dSIngo Weinholdelse 718c0e8cc1aSIngo Weinhold if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then 719c0e8cc1aSIngo Weinhold targetArchs="$HAIKU_PACKAGING_ARCHS" 720c0e8cc1aSIngo Weinhold fi 721c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS= 722c0e8cc1aSIngo Weinhold 723483b28e4SIngo Weinhold # On Haiku determine target architectures and tools automatically. 724c0e8cc1aSIngo Weinhold if [ -z "$targetArchs" ]; then 725483b28e4SIngo Weinhold if [ $HOST_PLATFORM != haiku_host ]; then 726483b28e4SIngo Weinhold echo "Please specify the build tools to use or build (via" \ 727eaef83a9SJeroen Oortwijn "--cross-tools-prefix or --build-cross-tools) or specify a" \ 728483b28e4SIngo Weinhold "host-only build (--host-only)." >&2 7297f9beaf1SOliver Tappe echo "For more info, invoke $0 --help" 730483b28e4SIngo Weinhold exit 1 731483b28e4SIngo Weinhold fi 732483b28e4SIngo Weinhold 733483b28e4SIngo Weinhold # determine primary architecture 734dda53eaeSIngo Weinhold targetArch=`package list -i /system/packages/haiku-*.hpkg \ 735483b28e4SIngo Weinhold | sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'` 736483b28e4SIngo Weinhold is_in_list "$targetArch" "$supportedTargetArchs" || ( 737483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"" >&2 738483b28e4SIngo Weinhold exit 1 739483b28e4SIngo Weinhold ) 740c0e8cc1aSIngo Weinhold targetArchs=$targetArch 741483b28e4SIngo Weinhold 742c0e8cc1aSIngo Weinhold set_default_value HAIKU_AR_$targetArch ar 743c0e8cc1aSIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc 744c0e8cc1aSIngo Weinhold set_default_value HAIKU_LD_$targetArch ld 745c0e8cc1aSIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy 746c0e8cc1aSIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib 747c0e8cc1aSIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit 748c0e8cc1aSIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip 749483b28e4SIngo Weinhold 750483b28e4SIngo Weinhold # determine secondary architectures 751483b28e4SIngo Weinhold for targetArch in $supportedTargetArchs; do 75280262a91SMatt Madia if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then 753483b28e4SIngo Weinhold targetArchs="$targetArchs $targetArch" 754483b28e4SIngo Weinhold set_default_value HAIKU_AR_$targetArch ar-$targetArch 755483b28e4SIngo Weinhold set_default_value HAIKU_CC_$targetArch gcc-$targetArch 756483b28e4SIngo Weinhold set_default_value HAIKU_LD_$targetArch ld-$targetArch 757483b28e4SIngo Weinhold set_default_value HAIKU_OBJCOPY_$targetArch objcopy-$targetArch 758483b28e4SIngo Weinhold set_default_value HAIKU_RANLIB_$targetArch ranlib-$targetArch 759483b28e4SIngo Weinhold set_default_value HAIKU_ELFEDIT_$targetArch elfedit-$targetArch 760483b28e4SIngo Weinhold set_default_value HAIKU_STRIP_$targetArch strip-$targetArch 761483b28e4SIngo Weinhold fi 762483b28e4SIngo Weinhold done 763483b28e4SIngo Weinhold 764483b28e4SIngo Weinhold # The target architectures might have been specified explicitly. 765483b28e4SIngo Weinhold if [ -n "$haikuTargetArchs" ]; then 766483b28e4SIngo Weinhold for targetArch in $haikuTargetArchs; do 767483b28e4SIngo Weinhold is_in_list "$targetArch" "$targetArchs" || ( 768483b28e4SIngo Weinhold echo "Unsupported target architecture: \"$targetArch\"." \ 769483b28e4SIngo Weinhold "Only native architectures of the host platform can" \ 770483b28e4SIngo Weinhold "be specified." >&2 771483b28e4SIngo Weinhold exit 1 772483b28e4SIngo Weinhold ) 773483b28e4SIngo Weinhold done 774483b28e4SIngo Weinhold targetArchs="$haikuTargetArchs" 775483b28e4SIngo Weinhold fi 776c0e8cc1aSIngo Weinhold fi 777c0e8cc1aSIngo Weinhold 77868ccc989SIngo Weinhold isPrimaryArch=1 779c0e8cc1aSIngo Weinhold for targetArch in $targetArchs; do 780c0e8cc1aSIngo Weinhold # Note: targetArch is "unknown<n>" at this point, if a cross-tools 781c0e8cc1aSIngo Weinhold # prefix was specified. The standard_gcc_settings call below will get 782c0e8cc1aSIngo Weinhold # the actual architecture. 783c0e8cc1aSIngo Weinhold 784c0e8cc1aSIngo Weinhold crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch` 785c0e8cc1aSIngo Weinhold 786338b8dc3SIngo Weinhold # build cross tools from sources 787c0e8cc1aSIngo Weinhold if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then 788c0e8cc1aSIngo Weinhold crossToolsDir="$outputDir/cross-tools-$targetArch" 789c0e8cc1aSIngo Weinhold targetMachine=`get_variable buildCrossToolsMachine_$targetArch` 790c0e8cc1aSIngo Weinhold script="$buildCrossToolsScript" 7918304ec7cSIngo Weinhold scriptArgs= 792c0e8cc1aSIngo Weinhold if [ $targetArch != x86_gcc2 ]; then 7938304ec7cSIngo Weinhold script="${script}_gcc4" 7948304ec7cSIngo Weinhold scriptArgs="$targetMachine" 7951e93288eSJérôme Duval set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch \ 7961e93288eSJérôme Duval $useGccGraphiteDefault 797c0e8cc1aSIngo Weinhold fi 79868ccc989SIngo Weinhold secondaryArch= 79968ccc989SIngo Weinhold if [ -z "$isPrimaryArch" ]; then 80068ccc989SIngo Weinhold secondaryArch=$targetArch 80168ccc989SIngo Weinhold fi 80286de8c37SIngo Weinhold 80386de8c37SIngo Weinhold case $HOST_PLATFORM in 80486de8c37SIngo Weinhold freebsd|openbsd) MAKE=gmake;; 80586de8c37SIngo Weinhold *) MAKE=make;; 80686de8c37SIngo Weinhold esac 80786de8c37SIngo Weinhold 808*825700d3SAugustin Cavalier if [ ! -d "$crossToolsDir" ]; then 80986de8c37SIngo Weinhold MAKE=$MAKE \ 81068ccc989SIngo Weinhold SECONDARY_ARCH=$secondaryArch \ 811c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE=`get_variable \ 812c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE_$targetArch` \ 813b3ece905SJérôme Duval HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \ 8144da6cf84SFrançois Revol HAIKU_USE_GDB="$gdbSources" \ 8158304ec7cSIngo Weinhold "$script" $scriptArgs "$sourceDir" "$buildCrossTools" \ 8168304ec7cSIngo Weinhold "$crossToolsDir" $buildCrossToolsJobs || exit 1 817*825700d3SAugustin Cavalier else 818*825700d3SAugustin Cavalier echo "$targetArch crosstools already exist in $crossToolsDir; skipping build" 819*825700d3SAugustin Cavalier fi 820c0e8cc1aSIngo Weinhold crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-" 821338b8dc3SIngo Weinhold fi 822338b8dc3SIngo Weinhold 823c0e8cc1aSIngo Weinhold # prepare gcc settings and get the actual target architecture 824a7bddff1SJonathan Schleifer if [ $useClang = 1 ]; then 82565706842SAugustin Cavalier gcc="$HAIKU_clang -target ${targetMachine} -no-integrated-as" 8261f6fe055SAugustin Cavalier 8271f6fe055SAugustin Cavalier # Clang's compiler intrinsics are not compatible with GCC's or even 8281f6fe055SAugustin Cavalier # across versions of Clang, so we must collect them for use in the build. 8291f6fe055SAugustin Cavalier mkdir -p "$outputDir/clang_headers" || exit 1 8301f6fe055SAugustin Cavalier clangHeadersDir=`$gcc -print-resource-dir`/include/ 8311f6fe055SAugustin Cavalier cp $clangHeadersDir/*intrin* $clangHeadersDir/mm3* "$outputDir/clang_headers" || exit 1 832d73993ffSAugustin Cavalier elif [ -z "${crossToolsPrefix}" ]; then 833d73993ffSAugustin Cavalier gcc=`get_variable HAIKU_CC_$targetArch` 834a7bddff1SJonathan Schleifer else 835c0e8cc1aSIngo Weinhold gcc="${crossToolsPrefix}gcc" 836a7bddff1SJonathan Schleifer fi 837c0e8cc1aSIngo Weinhold standard_gcc_settings "$gcc" 838c0e8cc1aSIngo Weinhold targetArch=$standard_gcc_settings_targetArch 839338b8dc3SIngo Weinhold 840c0e8cc1aSIngo Weinhold # set default values for flags 841c0e8cc1aSIngo Weinhold set_default_value HAIKU_CPPFLAGS_$targetArch "" 842c0e8cc1aSIngo Weinhold set_default_value HAIKU_CCFLAGS_$targetArch "" 843c0e8cc1aSIngo Weinhold set_default_value HAIKU_CXXFLAGS_$targetArch "" 844c0e8cc1aSIngo Weinhold set_default_value HAIKU_LDFLAGS_$targetArch "" 845c0e8cc1aSIngo Weinhold set_default_value HAIKU_ARFLAGS_$targetArch cru 846c0e8cc1aSIngo Weinhold set_default_value HAIKU_UNARFLAGS_$targetArch x 847338b8dc3SIngo Weinhold 848c0e8cc1aSIngo Weinhold # Override the cross tools variables, if the tools were built or a 849c0e8cc1aSIngo Weinhold # prefix was specified. 850b7777272SAlex Smith if [ -n "$crossToolsPrefix" ]; then 851c0e8cc1aSIngo Weinhold get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar 852c0e8cc1aSIngo Weinhold get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld 853c0e8cc1aSIngo Weinhold get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy 854c0e8cc1aSIngo Weinhold get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib 855c0e8cc1aSIngo Weinhold get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip 856c0e8cc1aSIngo Weinhold 857c0e8cc1aSIngo Weinhold case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in 858133e4131SJérôme Duval 4.*|5.*|6.*|7.*|8.*) 859c0e8cc1aSIngo Weinhold get_build_tool_path ELFEDIT_$targetArch \ 860c0e8cc1aSIngo Weinhold ${crossToolsPrefix}elfedit 861bd16f0ddSAlex Smith ;; 862bd16f0ddSAlex Smith esac 86352a38012Sejakowatz fi 86452a38012Sejakowatz 865ef57df3dSIngo Weinhold # check whether the Haiku compiler really targets Haiku 866c0e8cc1aSIngo Weinhold targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` 867c0e8cc1aSIngo Weinhold case "$targetMachine" in 868eedc3d0bSIngo Weinhold *-*-haiku) ;; 869c0e8cc1aSIngo Weinhold *) 870c0e8cc1aSIngo Weinhold echo The compiler specified as Haiku target compiler is not a \ 871c0e8cc1aSIngo Weinhold valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2 872eedc3d0bSIngo Weinhold echo compiler: $HAIKU_CC 873c0e8cc1aSIngo Weinhold echo compiler is configured for target: $targetMachine 874eedc3d0bSIngo Weinhold exit 1 ;; 875eedc3d0bSIngo Weinhold esac 876c0e8cc1aSIngo Weinhold 877c0e8cc1aSIngo Weinhold HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch" 87868ccc989SIngo Weinhold isPrimaryArch= 879c0e8cc1aSIngo Weinhold done 8802ebcd86dSIngo Weinholdfi 881eedc3d0bSIngo Weinhold 88252a38012Sejakowatz# Generate BuildConfig 8837c4641d0SOliver Tappecat << EOF > "$buildConfigFile" 884*825700d3SAugustin Cavalier# -- WARNING -- 885*825700d3SAugustin Cavalier# This file was AUTOMATICALLY GENERATED by configure, and will be completely 886*825700d3SAugustin Cavalier# overwritten the next time configure is run. 887*825700d3SAugustin Cavalier# 888*825700d3SAugustin Cavalier#d ${currentDir} 889*825700d3SAugustin Cavalier#c ${configurePath} 890*825700d3SAugustin Cavalier#e ${configureEnvirons} 891*825700d3SAugustin Cavalier#a ${configureArgs} 89252a38012Sejakowatz 8937c4641d0SOliver TappeTARGET_PLATFORM ?= "${TARGET_PLATFORM}" ; 8947c4641d0SOliver TappeHOST_PLATFORM ?= "${HOST_PLATFORM}" ; 895338b8dc3SIngo Weinhold 8967c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE ?= "${HAIKU_INCLUDE_PATENTED_CODE}" ; 89776fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES ?= "${HAIKU_INCLUDE_SOURCES}" ; 8987c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY ?= "${HAIKU_INCLUDE_3RDPARTY}" ; 8997c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY ?= "${HAIKU_DISTRO_COMPATIBILITY}" ; 9007c4641d0SOliver TappeHAIKU_USE_GCC_PIPE ?= "${HAIKU_USE_GCC_PIPE}" ; 9017986925fSIngo WeinholdHAIKU_HOST_USE_32BIT ?= "${HAIKU_HOST_USE_32BIT}" ; 9027986925fSIngo WeinholdHAIKU_HOST_USE_XATTR ?= "${HAIKU_HOST_USE_XATTR}" ; 903bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF ?= "${HAIKU_HOST_USE_XATTR_REF}" ; 9042ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ; 905eccc7665SIngo Weinhold 906c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ; 90765ad1ba3SAlex Smith 908aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS ?= "${HAIKU_NO_DOWNLOADS}" ; 909aa2e5ecaSOliver Tappe 9107c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR ?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ; 911338b8dc3SIngo Weinhold 912d6f80927SJonathan SchleiferHAIKU_NASM ?= ${HAIKU_NASM} ; 913e70c4c64SPulkoMandyHAIKU_BOOT_BOARD ?= ${HAIKU_BOOT_BOARD} ; 914338b8dc3SIngo Weinhold 915f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED ?= ${HOST_EXTENDED_REGEX_SED} ; 9167c4641d0SOliver TappeHOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ; 9177c4641d0SOliver TappeHOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ; 9187c4641d0SOliver TappeHOST_LD ?= ${HOST_GCC_LD} ; 9197c4641d0SOliver TappeHOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ; 9202a5d0aafSIngo WeinholdHOST_SHA256 ?= ${HOST_SHA256} ; 9218b5934c9SIngo Weinhold 922e173a1ecSIngo WeinholdHOST_HAIKU_PORTER ?= ${HOST_HAIKU_PORTER} ; 923e173a1ecSIngo WeinholdHAIKU_PORTS ?= ${HAIKU_PORTS} ; 924e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS ?= ${HAIKU_PORTS_CROSS} ; 925c9dd05ffSJonathan SchleiferHAIKU_IS_BOOTSTRAP ?= ${HAIKU_IS_BOOTSTRAP} ; 926e173a1ecSIngo Weinhold 927c4786ea6SlilloEOF 928c4786ea6Slillo 929c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do 930c0e8cc1aSIngo Weinhold variables=" 931c0e8cc1aSIngo Weinhold HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION 932c0e8cc1aSIngo Weinhold HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE 933c0e8cc1aSIngo Weinhold HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR 934c0e8cc1aSIngo Weinhold HAIKU_CPU HAIKU_CPU 935c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC 936c0e8cc1aSIngo Weinhold HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX 937c0e8cc1aSIngo Weinhold HAIKU_AR HAIKU_AR 938c0e8cc1aSIngo Weinhold HAIKU_CC HAIKU_CC 939c2b76f7fSJonathan Schleifer HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG 940c0e8cc1aSIngo Weinhold HAIKU_LD HAIKU_LD 941c0e8cc1aSIngo Weinhold HAIKU_OBJCOPY HAIKU_OBJCOPY 942c0e8cc1aSIngo Weinhold HAIKU_RANLIB HAIKU_RANLIB 943c0e8cc1aSIngo Weinhold HAIKU_ELFEDIT HAIKU_ELFEDIT 944c0e8cc1aSIngo Weinhold HAIKU_STRIP HAIKU_STRIP 945c0e8cc1aSIngo Weinhold HAIKU_CPPFLAGS HAIKU_CPPFLAGS 946c0e8cc1aSIngo Weinhold HAIKU_CCFLAGS HAIKU_CCFLAGS 947c0e8cc1aSIngo Weinhold HAIKU_C++FLAGS HAIKU_CXXFLAGS 948c0e8cc1aSIngo Weinhold HAIKU_LDFLAGS HAIKU_LDFLAGS 949c0e8cc1aSIngo Weinhold HAIKU_ARFLAGS HAIKU_ARFLAGS 950c0e8cc1aSIngo Weinhold HAIKU_UNARFLAGS HAIKU_UNARFLAGS 951c0e8cc1aSIngo Weinhold HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE 952c0e8cc1aSIngo Weinhold " 953c0e8cc1aSIngo Weinhold set -- $variables 954c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 955c0e8cc1aSIngo Weinhold value=`get_variable ${2}_$targetArch` 956c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile" 957c0e8cc1aSIngo Weinhold shift 2 958c0e8cc1aSIngo Weinhold done 959b1e5b60cSAxel Dörfler 960c0e8cc1aSIngo Weinhold # For variables that may have long values, distribute them over multiple 961c0e8cc1aSIngo Weinhold # lines so that jam doesn't hit the maximum line length. 962c0e8cc1aSIngo Weinhold variables=" 96366a7f29fSJérôme Duval HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR 964c0e8cc1aSIngo Weinhold " 965c0e8cc1aSIngo Weinhold set -- $variables 966c0e8cc1aSIngo Weinhold while [ $# -ge 2 ]; do 967c0e8cc1aSIngo Weinhold echo "${1}_${targetArch} ?= " >> "$buildConfigFile" 968c0e8cc1aSIngo Weinhold get_variable ${2}_$targetArch | xargs -n 1 echo " " \ 969c0e8cc1aSIngo Weinhold >> "$buildConfigFile" 970c0e8cc1aSIngo Weinhold echo " ;" >> "$buildConfigFile" 971c0e8cc1aSIngo Weinhold shift 2 972c0e8cc1aSIngo Weinhold done 973c0e8cc1aSIngo Weinholddone 974b1e5b60cSAxel Dörfler 975b1e5b60cSAxel Dörfler 9769b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory. 977338b8dc3SIngo Weinhold 978338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 979338b8dc3SIngo Weinhold# automatically generated Jamfile 980338b8dc3SIngo Weinhold 981338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 982338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 983338b8dc3SIngo Weinhold 984338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 985338b8dc3SIngo Weinhold 986338b8dc3SIngo WeinholdEOF 987d73993ffSAugustin Cavalier 988d73993ffSAugustin Cavalierecho "Configured successfully!" 989