xref: /haiku/configure (revision 4880ae0122d5504c7b7bffd01442501d1307a2dd)
152a38012Sejakowatz#!/bin/sh
252a38012Sejakowatz#
3338b8dc3SIngo Weinhold# configure [ <options> ]
4614026d7Sshatty
539d444a3SArvind S Raj# set flag to exit script when exit command is executed
639d444a3SArvind S Rajset -e
739d444a3SArvind S Raj
8022fa244SIngo Weinhold# usage
9022fa244SIngo Weinhold#
10022fa244SIngo Weinhold# Prints usage.
11022fa244SIngo Weinhold#
12022fa244SIngo Weinholdusage()
13022fa244SIngo Weinhold{
14022fa244SIngo Weinhold	cat << EOF
15022fa244SIngo Weinhold
16022fa244SIngo WeinholdUsage: $0 <options>
17022fa244SIngo Weinholdoptions:
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).
5760d8d8fcSIngo Weinhold  --enable-multiuser          Enable experimental multiuser support.
58eccc7665SIngo Weinhold  --help                      Prints out this help.
592ebcd86dSIngo Weinhold  --host-only                 Configure for building tools for the build host
602ebcd86dSIngo Weinhold                              only. Haiku cannot be built when configured like
612ebcd86dSIngo Weinhold                              this.
62eccc7665SIngo Weinhold  --include-gpl-addons        Include GPL licensed add-ons.
6367838392SAxel Dörfler  --include-patented-code     Enable code that is known to implemented patented
6467838392SAxel Dörfler                              ideas and techniques. If this option is not
6567838392SAxel Dörfler                              specified, the resulting distribution may still
6667838392SAxel Dörfler                              implement patented ideas and techniques. This
6767838392SAxel Dörfler                              option only disables code that is currently known
6867838392SAxel Dörfler                              to be problematic.
6976fa0be3SIngo Weinhold  --include-sources           Includes the source code of projects that require
7076fa0be3SIngo Weinhold                              either an offer of source code or a copy of the
7176fa0be3SIngo Weinhold                              patched sources. This is preferable when
7276fa0be3SIngo Weinhold                              distributing on physical mediums.
731974210fSFrançois Revol  --include-3rdparty          Include 3rdparty/ in the build system.
74*4880ae01SJessica Hamilton  -j<n>                       Only relevant for --build-cross-tools. Is passed
75*4880ae01SJessica Hamilton                              on to the make building the build tools.
76aa2e5ecaSOliver Tappe  --no-downloads              Do not download anything. Useful when trying to
77aa2e5ecaSOliver Tappe                              bootstrap and build Haiku from source only.
7886d7e283SOliver Tappe  --remote-user <username>    Use given username when logging into
7986d7e283SOliver Tappe                              git.haiku-os.org (via ssh).
807c4641d0SOliver Tappe  --target=TARGET             Select build target platform.
817c4641d0SOliver Tappe                              [default=${TARGET_PLATFORM}]
82a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
83483b28e4SIngo Weinhold  --target-arch <arch>        Haiku only: Specify the target architecture to
84483b28e4SIngo Weinhold                              build for. Must be one of the architectures of the
85483b28e4SIngo Weinhold                              host system. The installed build tools for that
86483b28e4SIngo Weinhold                              architecture will be used.
87483b28e4SIngo Weinhold                              This option can be specified multiple times. The
88483b28e4SIngo Weinhold                              first occurrence specifies the primary
89483b28e4SIngo Weinhold                              architecture of the Haiku to build, subsequent
90483b28e4SIngo Weinhold                              ones the secondary architectures.
91e70c4c64SPulkoMandy  --target-board <board>      ARM only: Specify the board to build for. Must be
92c0b833b1SAlexander von Gluck IV                              one of beagle,raspberry_pi,verdex.
937c4641d0SOliver Tappe  --update                    re-runs last configure invocation [must be given
947c4641d0SOliver Tappe                              as first option!]
95c2b76f7fSJonathan Schleifer  --use-clang                 Build with host Clang instead of GCC cross
96c2b76f7fSJonathan Schleifer                              compiler
97eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
985a34a443SFrançois Revol                              process, but uses more memory.
99ed38d2efSJerome Duval  --use-gcc-graphite          Build with GCC Graphite engine for loop
100ed38d2efSJerome Duval                              optimizations. Only for gcc 4.
1010385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
102bc96e8f3SIngo Weinhold  --use-xattr                 Use Linux xattr respectively *BSD extattr support
103bc96e8f3SIngo Weinhold                              for BeOS attribute emulation. Warning: Make sure
104bc96e8f3SIngo Weinhold                              your file system supports sufficient attribute
105bc96e8f3SIngo Weinhold                              sizes (4 KB per file for all attributes won't
106bc96e8f3SIngo Weinhold                              suffice).
107bc96e8f3SIngo Weinhold  --use-xattr-ref             Use the generic BeOS attribute emulation, but use
108bc96e8f3SIngo Weinhold                              Linux xattr respectively *BSD extattr support to
109bc96e8f3SIngo Weinhold                              make it more robust (i.e. attribute mix-ups become
110bc96e8f3SIngo Weinhold                              less likely).
111338b8dc3SIngo Weinhold
112338b8dc3SIngo Weinholdenvironment variables:
113c0e8cc1aSIngo Weinhold  HAIKU_AR_x86_gcc2           The static library archiver for x86_gcc2.
114c0e8cc1aSIngo Weinhold                              Defaults to "ar".
115c0e8cc1aSIngo Weinhold  HAIKU_CC_x86_gcc2           The x86_gcc2 compiler. Defaults to "gcc".
116c0e8cc1aSIngo Weinhold  HAIKU_LD_x86_gcc2           The x86_gcc2 linker. Defaults to "ld".
117c0e8cc1aSIngo Weinhold  HAIKU_OBJCOPY_x86_gcc2      The x86_gcc2 objcopy to be used. Defaults to
118c0e8cc1aSIngo Weinhold                              "objcopy".
119c0e8cc1aSIngo Weinhold  HAIKU_RANLIB_x86_gcc2       The static library indexer for x86_gcc2. Defaults
120c0e8cc1aSIngo Weinhold                              to "ranlib".
121c0e8cc1aSIngo Weinhold  HAIKU_STRIP_x86_gcc2        The x86_gcc2 strip command. Defaults to "strip".
122a04a520bSJonathan Schleifer  HAIKU_NASM                  The nasm assembler (x86 and x86_64 only).
123c0e8cc1aSIngo Weinhold  HAIKU_CPPFLAGS_<arch>       The preprocessor flags for target architecture
124c0e8cc1aSIngo Weinhold                              <arch>. Defaults to "".
125c0e8cc1aSIngo Weinhold  HAIKU_CCFLAGS_<arch>        The C flags for target architecture <arch>.
126c0e8cc1aSIngo Weinhold                              Defaults to "".
127c0e8cc1aSIngo Weinhold  HAIKU_CXXFLAGS_<arch>       The C++ flags for target architecture <arch>.
128c0e8cc1aSIngo Weinhold                              Defaults to "".
129c0e8cc1aSIngo Weinhold  HAIKU_LDFLAGS_<arch>        The linker flags for target architecture <arch>.
130c0e8cc1aSIngo Weinhold                              Defaults to "".
131c0e8cc1aSIngo Weinhold  HAIKU_ARFLAGS_<arch>        The flags passed to HAIKU_AR for target
132c0e8cc1aSIngo Weinhold                              architecture <arch> for archiving. Defaults to
133c0e8cc1aSIngo Weinhold                              "cru".
134c0e8cc1aSIngo Weinhold  HAIKU_UNARFLAGS_<arch>      The flags passed to HAIKU_AR for target
135c0e8cc1aSIngo Weinhold                              architecture <arch> for unarchiving. Defaults to
136c0e8cc1aSIngo Weinhold                              "x".
13764f6da31SIngo Weinhold
138c0e8cc1aSIngo WeinholdNon-default output directories:
13964f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
14064f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
14164f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
14264f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
14364f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
14464f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
14564f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
14664f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
14764f6da31SIngo Weinhold  non-default location and running jam.
14864f6da31SIngo Weinhold
14964f6da31SIngo Weinhold
150022fa244SIngo WeinholdEOF
151022fa244SIngo Weinhold}
152022fa244SIngo Weinhold
153022fa244SIngo Weinhold# assertparam
154022fa244SIngo Weinhold#
155022fa244SIngo Weinhold# Checks whether at least one parameter is left.
156022fa244SIngo Weinhold#
157022fa244SIngo Weinholdassertparam()
158022fa244SIngo Weinhold{
15920ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
160022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
161022fa244SIngo Weinhold		exit 1
162022fa244SIngo Weinhold	fi
163022fa244SIngo Weinhold}
164022fa244SIngo Weinhold
16520ab75e6SIngo Weinhold# assertparams
16620ab75e6SIngo Weinhold#
16720ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
16820ab75e6SIngo Weinhold#
16920ab75e6SIngo Weinholdassertparams()
17020ab75e6SIngo Weinhold{
17120ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
17220ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
17320ab75e6SIngo Weinhold		exit 1
17420ab75e6SIngo Weinhold	fi
17520ab75e6SIngo Weinhold}
17620ab75e6SIngo Weinhold
177e173a1ecSIngo Weinhold# absolute_path
178e173a1ecSIngo Weinhold#
179e173a1ecSIngo Weinhold# returns the absolute path of a given path.
180e173a1ecSIngo Weinhold#
181e173a1ecSIngo Weinholdabsolute_path()
182e173a1ecSIngo Weinhold{
1836a4f3954SFrançois Revol	if [ "x$1" != "x${1#/}" ]; then
184e173a1ecSIngo Weinhold		echo "$1"
185e173a1ecSIngo Weinhold	else
186e173a1ecSIngo Weinhold		echo "`pwd`/$1"
187e173a1ecSIngo Weinhold	fi
188e173a1ecSIngo Weinhold}
189e173a1ecSIngo Weinhold
19039d444a3SArvind S Raj# check_dir_exists
19139d444a3SArvind S Raj#
19239d444a3SArvind S Raj# check if a directory exists or not
19339d444a3SArvind S Raj#
19439d444a3SArvind S Rajcheck_dir_exists()
19539d444a3SArvind S Raj{
19639d444a3SArvind S Raj	if [ -d "$1" ]; then
19739d444a3SArvind S Raj		return 0
19839d444a3SArvind S Raj	else
19939d444a3SArvind S Raj		return 1
20039d444a3SArvind S Raj	fi
20139d444a3SArvind S Raj}
20239d444a3SArvind S Raj
203502882dbSJessica Hamilton# check_file_exists
204502882dbSJessica Hamilton#
205502882dbSJessica Hamilton# check if a file exists or not
206502882dbSJessica Hamilton#
207502882dbSJessica Hamiltoncheck_file_exists()
208502882dbSJessica Hamilton{
209502882dbSJessica Hamilton	if [ -f "$1" ]; then
210502882dbSJessica Hamilton		return 0
211502882dbSJessica Hamilton	else
212502882dbSJessica Hamilton		return 1
213502882dbSJessica Hamilton	fi
214502882dbSJessica Hamilton}
215502882dbSJessica Hamilton
2169a001156SOliver Tappe# real_path
2179a001156SOliver Tappe#
2189a001156SOliver Tappe# returns the realpath of a symbolic link.
2199a001156SOliver Tappe#
2209a001156SOliver Tappereal_path()
2219a001156SOliver Tappe{
2229a001156SOliver Tappe	perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1"
2239a001156SOliver Tappe}
2249a001156SOliver Tappe
22509c5682dSIngo Weinhold# standard_gcc_settings
22609c5682dSIngo Weinhold#
22709c5682dSIngo Weinhold# Sets the variables for a GCC platform.
22809c5682dSIngo Weinhold#
22909c5682dSIngo Weinholdstandard_gcc_settings()
23009c5682dSIngo Weinhold{
231c0e8cc1aSIngo Weinhold	local gcc=$1
232c0e8cc1aSIngo Weinhold
233138f5fb4SIngo Weinhold	if which greadlink > /dev/null 2>&1; then
234b29b48b1SMatt Madia		readlink="greadlink -e"
235138f5fb4SIngo Weinhold	elif which realpath > /dev/null 2>&1; then
236b29b48b1SMatt Madia		readlink=realpath
2379a001156SOliver Tappe	elif readlink -e / > /dev/null 2>&1; then
238b29b48b1SMatt Madia		readlink="readlink -e"
2399a001156SOliver Tappe	else
2409a001156SOliver Tappe		readlink=real_path
241b4b6d83cSMatt Madia	fi
242138f5fb4SIngo Weinhold
24309c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
244c0e8cc1aSIngo Weinhold	local gcclib=`$gcc -print-libgcc-file-name`
245c0e8cc1aSIngo Weinhold	local gccdir=`dirname ${gcclib}`
2465b0f7b1bSOliver Tappe
247c0e8cc1aSIngo Weinhold	local gccRawVersion=`$gcc -dumpversion`
248c0e8cc1aSIngo Weinhold	local gccMachine=`$gcc -dumpmachine`
249338b8dc3SIngo Weinhold
250c0e8cc1aSIngo Weinhold	local libgcc=${gccdir}/libgcc.a
2518b5934c9SIngo Weinhold
252fc8967f1SIngo Weinhold	# determine architecture from machine triple
253c0e8cc1aSIngo Weinhold	case $gccMachine in
254c0e8cc1aSIngo Weinhold		arm-*)		targetCpu=arm;;
255c0e8cc1aSIngo Weinhold		i?86-*)		targetCpu=x86;;
256c0e8cc1aSIngo Weinhold		m68k-*)		targetCpu=m68k;;
257c0e8cc1aSIngo Weinhold		powerpc-*)	targetCpu=ppc;;
258c0e8cc1aSIngo Weinhold		x86_64-*)	targetCpu=x86_64;;
259fc8967f1SIngo Weinhold		*)
260c0e8cc1aSIngo Weinhold			echo "Unsupported gcc target machine: $gccMachine" >&2
261fc8967f1SIngo Weinhold			exit 1
262fc8967f1SIngo Weinhold			;;
263fc8967f1SIngo Weinhold	esac
264fc8967f1SIngo Weinhold
265c0e8cc1aSIngo Weinhold	local targetArch=$targetCpu
266c0e8cc1aSIngo Weinhold	local staticLibStdCxx
267c0e8cc1aSIngo Weinhold	local sharedLibStdCxx
268c0e8cc1aSIngo Weinhold	local staticLibSupCxx
269c0e8cc1aSIngo Weinhold	local sharedLibSupCxx
270c0e8cc1aSIngo Weinhold	local kernelLibgcc
271c0e8cc1aSIngo Weinhold	local cxxHeaders
272fc8967f1SIngo Weinhold
273c0e8cc1aSIngo Weinhold	case $gccRawVersion in
2748b5934c9SIngo Weinhold		4.*)
2755b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
2765b0f7b1bSOliver Tappe			# compiler
277c0e8cc1aSIngo Weinhold			staticLibStdCxx=`$gcc -print-file-name=libstdc++.a`
278c0e8cc1aSIngo Weinhold			sharedLibStdCxx=`$gcc -print-file-name=libstdc++.so`
279c0e8cc1aSIngo Weinhold			staticLibSupCxx=`$gcc -print-file-name=libsupc++.a`
280c0e8cc1aSIngo Weinhold			sharedLibSupCxx=`$gcc -print-file-name=libsupc++.so`
28114210488SMichael Lotz
282aaeadfcbSAlex Smith			# If the architecture has separate runtime libraries for the
283aaeadfcbSAlex Smith			# kernel, use them.
284c0e8cc1aSIngo Weinhold			kernelLibgcc=`$gcc -print-file-name=libgcc-kernel.a`
285c0e8cc1aSIngo Weinhold			if [ $kernelLibgcc = libgcc-kernel.a ]; then
286c0e8cc1aSIngo Weinhold				kernelLibgcc=$libgcc
287aaeadfcbSAlex Smith			fi
288c0e8cc1aSIngo Weinhold			kernelLibSupCxx=`$gcc -print-file-name=libsupc++-kernel.a`
289c0e8cc1aSIngo Weinhold			if [ $kernelLibSupCxx = libsupc++-kernel.a ]; then
290c0e8cc1aSIngo Weinhold				kernelLibSupCxx=$staticLibSupCxx
291aaeadfcbSAlex Smith			fi
292aaeadfcbSAlex Smith
293c0e8cc1aSIngo Weinhold			local headersBase=$gccdir/../../../..
294c0e8cc1aSIngo Weinhold			local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion
295c0e8cc1aSIngo Weinhold			if [ ! -d $headers ]; then
296c0e8cc1aSIngo Weinhold				headers=$headersBase/include/c++/$gccRawVersion
29714210488SMichael Lotz			fi
29814210488SMichael Lotz
299c0e8cc1aSIngo Weinhold			cxxHeaders=$headers
300c0e8cc1aSIngo Weinhold			for d in $gccMachine backward ext; do
30129ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
30229ef597dSIngo Weinhold				# too long for jam (512 bytes max).
303c0e8cc1aSIngo Weinhold				cxxHeaders="$cxxHeaders $headers/$d"
3048b5934c9SIngo Weinhold			done
305274b450aSMarcus Overhagen
3063f9f9f9aSIngo Weinhold			# Unset the HAIKU_{SHARED,STATIC}_LIB{STD,SUP}CXX variables, if the
3073f9f9f9aSIngo Weinhold			# compiler didn't give us actual file names. Otherwise resolve
3083f9f9f9aSIngo Weinhold			# symlinks to avoid problems when copying the libraries to the
3093f9f9f9aSIngo Weinhold			# image.
3108b5934c9SIngo Weinhold
311c0e8cc1aSIngo Weinhold			if [ $staticLibStdCxx = libstdc++.a ]; then
312c0e8cc1aSIngo Weinhold				staticLibStdCxx=
3133f9f9f9aSIngo Weinhold			else
314c0e8cc1aSIngo Weinhold				staticLibStdCxx=`$readlink $staticLibStdCxx`
3158b5934c9SIngo Weinhold			fi
3163f9f9f9aSIngo Weinhold
317c0e8cc1aSIngo Weinhold			if [ $sharedLibStdCxx = libstdc++.so ]; then
318c0e8cc1aSIngo Weinhold				sharedLibStdCxx=
3193f9f9f9aSIngo Weinhold			else
320c0e8cc1aSIngo Weinhold				sharedLibStdCxx=`$readlink $sharedLibStdCxx`
321ffe8b20cSIngo Weinhold			fi
3223f9f9f9aSIngo Weinhold
323c0e8cc1aSIngo Weinhold			if [ $staticLibSupCxx = libsupc++.a ]; then
324c0e8cc1aSIngo Weinhold				staticLibSupCxx=
3253f9f9f9aSIngo Weinhold			else
326c0e8cc1aSIngo Weinhold				staticLibSupCxx=`$readlink $staticLibSupCxx`
327c89fc875SIngo Weinhold			fi
3283f9f9f9aSIngo Weinhold
329c0e8cc1aSIngo Weinhold			if [ $sharedLibSupCxx = libsupc++.so ]; then
330c0e8cc1aSIngo Weinhold				sharedLibSupCxx=
3313f9f9f9aSIngo Weinhold			else
332c0e8cc1aSIngo Weinhold				sharedLibSupCxx=`$readlink $sharedLibSupCxx`
333ffe8b20cSIngo Weinhold			fi
3348b5934c9SIngo Weinhold			;;
3356cc8eecfSOliver Tappe		2.9*)
3365b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
3375b0f7b1bSOliver Tappe			# if an older one is installed
338c0e8cc1aSIngo Weinhold			if [ $gccRawVersion != $haikuRequiredLegacyGCCVersion ]; then
3395b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
3405b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
3415b0f7b1bSOliver Tappe				exit 1;
3425b0f7b1bSOliver Tappe			fi
343aaeadfcbSAlex Smith
344c0e8cc1aSIngo Weinhold			kernelLibgcc=$libgcc
345c0e8cc1aSIngo Weinhold			kernelLibSupCxx=
346c0e8cc1aSIngo Weinhold			targetArch=x86_gcc2
3475b0f7b1bSOliver Tappe			;;
3488b5934c9SIngo Weinhold	esac
34965ad1ba3SAlex Smith
350c0e8cc1aSIngo Weinhold	local bootLibgcc
351c0e8cc1aSIngo Weinhold	local bootLibSupCxx
35266a7f29fSJérôme Duval	local bootCxxHeaders
353c0e8cc1aSIngo Weinhold	case $gccMachine in
3544591ebc9SAlex Smith		x86_64-*)
35566a7f29fSJérôme Duval			# Boot loader is 32-bit, need the 32-bit libs and c++ config
356c0e8cc1aSIngo Weinhold			bootLibgcc=`$gcc -m32 -print-libgcc-file-name`
357c0e8cc1aSIngo Weinhold			bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a`
35866a7f29fSJérôme Duval
35966a7f29fSJérôme Duval			local headersBase=$gccdir/../../../..
36066a7f29fSJérôme Duval			local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion
36166a7f29fSJérôme Duval			if [ ! -d $headers ]; then
36266a7f29fSJérôme Duval				headers=$headersBase/include/c++/$gccRawVersion
36366a7f29fSJérôme Duval			fi
36466a7f29fSJérôme Duval			bootCxxHeaders="$headers/$gccMachine/32"
3654591ebc9SAlex Smith			;;
3664591ebc9SAlex Smith		*)
367c0e8cc1aSIngo Weinhold			bootLibgcc=$libgcc
368c0e8cc1aSIngo Weinhold			bootLibSupCxx=$staticLibSupCxx
369338b8dc3SIngo Weinhold			;;
370338b8dc3SIngo Weinhold	esac
371c0e8cc1aSIngo Weinhold
372c0e8cc1aSIngo Weinhold	# determine whether graphite loop optimization should/can be used
373c0e8cc1aSIngo Weinhold	local useGraphite=`get_variable HAIKU_USE_GCC_GRAPHITE_$targetCpu`
374c0e8cc1aSIngo Weinhold	if [ -z "$useGraphite" ]; then
375c0e8cc1aSIngo Weinhold		useGraphite=$useGccGraphiteDefault
376c0e8cc1aSIngo Weinhold	fi
377c0e8cc1aSIngo Weinhold
378c0e8cc1aSIngo Weinhold	if [ "$useGraphite" != 0 ]; then
379c0e8cc1aSIngo Weinhold		UNUSED=`echo "int main() {}" | $gcc -xc -c -floop-block - 2>&1`
380c0e8cc1aSIngo Weinhold		if [ $? != 0 ]; then
381c0e8cc1aSIngo Weinhold			echo "GCC Graphite loop optimizations cannot be used on $targetArch"
382c0e8cc1aSIngo Weinhold			useGraphite=0
383c0e8cc1aSIngo Weinhold		fi
384c0e8cc1aSIngo Weinhold	fi
385c0e8cc1aSIngo Weinhold
386c0e8cc1aSIngo Weinhold	set_variable HAIKU_CPU_$targetArch $targetCpu
387c0e8cc1aSIngo Weinhold
388c0e8cc1aSIngo Weinhold	get_build_tool_path CC_$targetArch "$gcc"
389c2b76f7fSJonathan Schleifer	if [ $useClang = 1 ]; then
390c2b76f7fSJonathan Schleifer		# The get_build_tool_path above is needed to get the path to the rest
391c2b76f7fSJonathan Schleifer		# of the build tools
392c2b76f7fSJonathan Schleifer		local path=`dirname $(get_variable HAIKU_CC_$targetArch)`
393c2b76f7fSJonathan Schleifer		set_variable HAIKU_CC_$targetArch \
394c2b76f7fSJonathan Schleifer			"PATH=\\\"$path:\\\$PATH\\\" clang -target $gccMachine"
395c2b76f7fSJonathan Schleifer		set_variable HAIKU_CC_IS_CLANG_$targetArch 1
396c2b76f7fSJonathan Schleifer	else
397c2b76f7fSJonathan Schleifer		set_variable HAIKU_CC_IS_CLANG_$targetArch 0
398c2b76f7fSJonathan Schleifer	fi
399c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion
400c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine
401c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir
402c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_LIBGCC_$targetArch $libgcc
403c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_GLUE_CODE_$targetArch "crtbegin.o crtend.o"
404c0e8cc1aSIngo Weinhold	set_variable HAIKU_GCC_HEADERS_DIR_$targetArch \
405c0e8cc1aSIngo Weinhold		"${gccdir}/include ${gccdir}/include-fixed"
406c0e8cc1aSIngo Weinhold	set_variable HAIKU_STATIC_LIBSTDCXX_$targetArch "$staticLibStdCxx"
407c0e8cc1aSIngo Weinhold	set_variable HAIKU_SHARED_LIBSTDCXX_$targetArch "$sharedLibStdCxx"
408c0e8cc1aSIngo Weinhold	set_variable HAIKU_STATIC_LIBSUPCXX_$targetArch "$staticLibSupCxx"
409c0e8cc1aSIngo Weinhold	set_variable HAIKU_SHARED_LIBSUPCXX_$targetArch "$sharedLibSupCxx"
410c0e8cc1aSIngo Weinhold	set_variable HAIKU_KERNEL_LIBSUPCXX_$targetArch "$kernelLibSupCxx"
411c0e8cc1aSIngo Weinhold	set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx"
412c0e8cc1aSIngo Weinhold	set_variable HAIKU_KERNEL_LIBGCC_$targetArch $kernelLibgcc
413c0e8cc1aSIngo Weinhold	set_variable HAIKU_CXX_HEADERS_DIR_$targetArch "$cxxHeaders"
414c0e8cc1aSIngo Weinhold	set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc
41566a7f29fSJérôme Duval	set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders"
416c0e8cc1aSIngo Weinhold	set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite
417c0e8cc1aSIngo Weinhold
418c0e8cc1aSIngo Weinhold	standard_gcc_settings_targetArch=$targetArch
419c0e8cc1aSIngo Weinhold}
420c0e8cc1aSIngo Weinhold
421c0e8cc1aSIngo Weinhold# set_variable
422c0e8cc1aSIngo Weinhold#
423c0e8cc1aSIngo Weinhold# Set the value of a variable.
424c0e8cc1aSIngo Weinhold#
425c0e8cc1aSIngo Weinholdset_variable()
426c0e8cc1aSIngo Weinhold{
427c0e8cc1aSIngo Weinhold	eval "$1=\"$2\""
428c0e8cc1aSIngo Weinhold}
429c0e8cc1aSIngo Weinhold
430c0e8cc1aSIngo Weinhold# get_variable
431c0e8cc1aSIngo Weinhold#
432c0e8cc1aSIngo Weinhold# Echo the value of a variable.
433c0e8cc1aSIngo Weinhold#
434c0e8cc1aSIngo Weinholdget_variable()
435c0e8cc1aSIngo Weinhold{
436c0e8cc1aSIngo Weinhold	eval "echo \${$1}"
43709c5682dSIngo Weinhold}
43809c5682dSIngo Weinhold
439338b8dc3SIngo Weinhold# set_default_value
440338b8dc3SIngo Weinhold#
441338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
442338b8dc3SIngo Weinhold#
443338b8dc3SIngo Weinholdset_default_value()
444338b8dc3SIngo Weinhold{
445338b8dc3SIngo Weinhold	eval "$1=\${$1-$2}"
446338b8dc3SIngo Weinhold}
447338b8dc3SIngo Weinhold
448338b8dc3SIngo Weinhold# get_build_tool_path
449338b8dc3SIngo Weinhold#
450338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
451338b8dc3SIngo Weinhold#
452338b8dc3SIngo Weinholdget_build_tool_path()
453338b8dc3SIngo Weinhold{
454338b8dc3SIngo Weinhold	local var="HAIKU_$1"
455c0e8cc1aSIngo Weinhold	local path=$2
456338b8dc3SIngo Weinhold
457338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
458338b8dc3SIngo Weinhold		# get absolute path
459a559f87aSFrançois Revol		local oldPwd="`pwd`"
460a559f87aSFrançois Revol		cd "`dirname "$path"`"
461a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
462338b8dc3SIngo Weinhold		cd $oldPwd
463338b8dc3SIngo Weinhold	else
4647fe2e06cSMatt Madia		which "$path" > /dev/null 2>&1 || {
465338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
466338b8dc3SIngo Weinhold			exit 1
467338b8dc3SIngo Weinhold		}
468338b8dc3SIngo Weinhold	fi
469338b8dc3SIngo Weinhold
470338b8dc3SIngo Weinhold	eval "$var=$path"
471338b8dc3SIngo Weinhold}
472338b8dc3SIngo Weinhold
473483b28e4SIngo Weinholdis_in_list()
474483b28e4SIngo Weinhold{
475483b28e4SIngo Weinhold	local element
476483b28e4SIngo Weinhold	for element in $2; do
477483b28e4SIngo Weinhold		if [ "$1" = "$element" ]; then
478483b28e4SIngo Weinhold			return 0
479483b28e4SIngo Weinhold		fi
480483b28e4SIngo Weinhold	done
481483b28e4SIngo Weinhold	return 1
482483b28e4SIngo Weinhold}
483483b28e4SIngo Weinhold
484338b8dc3SIngo Weinhold# get cwd and the source directory
485338b8dc3SIngo WeinholdcurrentDir=`pwd`
4866e7c6fe5SIngo Weinholdcd `dirname "$0"`
487338b8dc3SIngo WeinholdsourceDir=`pwd`
4886e7c6fe5SIngo Weinholdcd "$currentDir"
489338b8dc3SIngo Weinhold
49055d267a4SFrançois Revol# backup the passed arguments
49155d267a4SFrançois RevolconfigureArgs="$@"
49255d267a4SFrançois Revol
4937c4641d0SOliver Tappe# internal default parameter values
494022fa244SIngo Weinhold#
49552a38012Sejakowatzplatform=`uname`
4965abd9a46SIngo WeinholdplatformMachine=`uname  -m`
497c0e8cc1aSIngo WeinholdtargetArchs=
498338b8dc3SIngo WeinholdbuildCrossTools=
49929ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
50060d8d8fcSIngo WeinholdbuildCrossToolsJobs=
501c2b76f7fSJonathan SchleiferuseClang=0
502c0e8cc1aSIngo WeinholduseGccGraphiteDefault=0
503c0e8cc1aSIngo WeinholdunknownArchIndex=1
504483b28e4SIngo WeinholdhaikuTargetArchs=
5057c4641d0SOliver Tappe
5067c4641d0SOliver Tappe# exported (BuildSetup) default parameter values
5077c4641d0SOliver Tappe#
5087c4641d0SOliver TappeHOST_GCC_RAW_VERSION=`gcc -dumpversion`
5097c4641d0SOliver TappeHOST_GCC_MACHINE=`gcc -dumpmachine`
5107c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS=0
5117c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0
51276fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES=0
5137c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0
5147c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER=0
5157c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default
5167c4641d0SOliver TappeTARGET_PLATFORM=haiku
5177c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0
5187986925fSIngo WeinholdHAIKU_HOST_USE_32BIT=0
5197986925fSIngo WeinholdHAIKU_HOST_USE_XATTR=0
520bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF=0
5212ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY=0
522f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED="sed -r"
5237c4641d0SOliver TappeHOST_GCC_LD=`gcc -print-prog-name=ld`
5247c4641d0SOliver TappeHOST_GCC_OBJCOPY=`gcc -print-prog-name=objcopy`
525c505b276SFrançois RevolSFDISK_BINARY=sfdisk
526c505b276SFrançois RevolHOST_SFDISK=$SFDISK_BINARY
5272a5d0aafSIngo WeinholdHOST_SHA256=
528e173a1ecSIngo WeinholdHOST_HAIKU_PORTER=
529e173a1ecSIngo WeinholdHAIKU_PORTS=
530e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS=
531e70c4c64SPulkoMandyHAIKU_BOOT_BOARD=
532aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS=0
5332a5d0aafSIngo Weinhold
534c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS=
535c0e8cc1aSIngo Weinhold
536a04a520bSJonathan Schleiferset_default_value HAIKU_NASM		nasm
537c0e8cc1aSIngo Weinhold
5383942ca0dSIngo Weinholdif sha256sum < /dev/null > /dev/null 2>&1; then
5392a5d0aafSIngo Weinhold	HOST_SHA256=sha256sum
5403942ca0dSIngo Weinholdelif sha256 < /dev/null > /dev/null 2>&1; then
5412a5d0aafSIngo Weinhold	HOST_SHA256="sha256 -q"
542b5a871b1SNiels Sascha Reedijkelif shasum < /dev/null > /dev/null 2>&1; then
543b5a871b1SNiels Sascha Reedijk	HOST_SHA256="shasum -a 256"
5442a5d0aafSIngo Weinholdelse
5452a5d0aafSIngo Weinhold	echo "Error: Neither sha256sum nor sha256 seem to be available!" >&2
5462a5d0aafSIngo Weinhold	exit 1
5472a5d0aafSIngo Weinholdfi
548338b8dc3SIngo Weinhold
549cc91b333SIngo WeinholdhaikuRequiredLegacyGCCVersion="2.95.3-haiku-2013_08_15"
550a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
551af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
552483b28e4SIngo WeinholdsupportedTargetArchs="
553483b28e4SIngo Weinhold	arm
554483b28e4SIngo Weinhold	m68k
555483b28e4SIngo Weinhold	ppc
556483b28e4SIngo Weinhold	x86
557483b28e4SIngo Weinhold	x86_64
558483b28e4SIngo Weinhold	x86_gcc2
559483b28e4SIngo Weinhold	"
560e70c4c64SPulkoMandysupportedTargetBoards="
561e70c4c64SPulkoMandy	beagle
562c0b833b1SAlexander von Gluck IV	raspberry_pi
563e70c4c64SPulkoMandy	verdex
564e70c4c64SPulkoMandy	"
565af4bf973SOliver Tappe
5667c4641d0SOliver Tappe# determine output directory
5677c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then
5687c4641d0SOliver Tappe	outputDir=$currentDir/generated
5697c4641d0SOliver Tappeelse
5707c4641d0SOliver Tappe	outputDir=$currentDir
5717c4641d0SOliver Tappefi
5727c4641d0SOliver TappebuildOutputDir="$outputDir/build"
5737c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes"
5747c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig"
5757c4641d0SOliver Tappe
5767c4641d0SOliver Tappe# check for update request
5777c4641d0SOliver Tappeif [ "$1" = "--update" ]; then
5787c4641d0SOliver Tappe	if ! [ -e "$buildConfigFile" ]; then
5797c4641d0SOliver Tappe		echo $0 --update: \'$buildConfigFile\' not found - updating not possible.
5807c4641d0SOliver Tappe		exit 1
5817c4641d0SOliver Tappe	fi
5827c4641d0SOliver Tappe	if ! type perl >/dev/null 2>&1; then
5837c4641d0SOliver Tappe		echo $0 --update: \'perl\' not found - updating not possible.
5847c4641d0SOliver Tappe		exit 1
5857c4641d0SOliver Tappe	fi
5867c4641d0SOliver Tappe	# convert BuildConfig from jam format to shell format and evaluate it
5877c4641d0SOliver Tappe	shellConfigFile="${buildConfigFile}.shell"
5887c4641d0SOliver Tappe	perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
5897c4641d0SOliver Tappe		<"$buildConfigFile" >"$shellConfigFile"
5907c4641d0SOliver Tappe	. "$shellConfigFile"
5917c4641d0SOliver Tappe	rm "$shellConfigFile"
5927c4641d0SOliver Tappe	shift
5937c4641d0SOliver Tappefi
5947c4641d0SOliver Tappe
595022fa244SIngo Weinhold# parse parameters
596022fa244SIngo Weinhold#
59720ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
598022fa244SIngo Weinhold	case "$1" in
599e173a1ecSIngo Weinhold		--bootstrap)
600e173a1ecSIngo Weinhold			assertparams "$1" 3 $#
601e173a1ecSIngo Weinhold			HOST_HAIKU_PORTER="`absolute_path $2`"
602e173a1ecSIngo Weinhold			HAIKU_PORTS_CROSS="`absolute_path $3`"
603e173a1ecSIngo Weinhold			HAIKU_PORTS="`absolute_path $4`"
604502882dbSJessica Hamilton			check_file_exists "$HOST_HAIKU_PORTER" || (
605502882dbSJessica Hamilton				echo "Invalid path to haikuporter: $HOST_HAIKU_PORTER" >&2
60639d444a3SArvind S Raj				exit 1
60739d444a3SArvind S Raj			)
60839d444a3SArvind S Raj			check_dir_exists "$HAIKU_PORTS" || (
60939d444a3SArvind S Raj				echo "Non-existent directory $HAIKU_PORTS" >&2
61039d444a3SArvind S Raj				exit 1
61139d444a3SArvind S Raj			)
61239d444a3SArvind S Raj			check_dir_exists "$HAIKU_PORTS_CROSS" || (
61339d444a3SArvind S Raj				echo "Non-existent directory $HAIKU_PORTS_CROSS" >&2
61439d444a3SArvind S Raj				exit 1
61539d444a3SArvind S Raj			)
616e173a1ecSIngo Weinhold			shift 4
617e173a1ecSIngo Weinhold			;;
618c0e8cc1aSIngo Weinhold		--build-cross-tools)
619c0e8cc1aSIngo Weinhold			if [ -z "$buildCrossTools" ]; then
6209b0dd528SIngo Weinhold				assertparams "$1" 2 $#
621c0e8cc1aSIngo Weinhold				targetArch=$2
6229b0dd528SIngo Weinhold				buildCrossTools=$3
6239b0dd528SIngo Weinhold				shift 3
624c0e8cc1aSIngo Weinhold			else
625c0e8cc1aSIngo Weinhold				assertparam "$1" $#
626c0e8cc1aSIngo Weinhold				targetArch=$2
627c0e8cc1aSIngo Weinhold				shift 2
628c0e8cc1aSIngo Weinhold			fi
629c0e8cc1aSIngo Weinhold			case "$targetArch" in
630c0e8cc1aSIngo Weinhold				x86_gcc2)	targetMachine=i586-pc-haiku;;
631c0e8cc1aSIngo Weinhold				x86)		targetMachine=i586-pc-haiku;;
632c0e8cc1aSIngo Weinhold				x86_64)		targetMachine=x86_64-unknown-haiku;;
633c0e8cc1aSIngo Weinhold				ppc)		targetMachine=powerpc-apple-haiku;;
634c0e8cc1aSIngo Weinhold				m68k)		targetMachine=m68k-unknown-haiku;;
635c0e8cc1aSIngo Weinhold				arm)		targetMachine=arm-unknown-haiku;;
636c0e8cc1aSIngo Weinhold				*)
637c0e8cc1aSIngo Weinhold					echo "Unsupported target architecture: $2" >&2
638c0e8cc1aSIngo Weinhold					exit 1
639c0e8cc1aSIngo Weinhold					;;
640c0e8cc1aSIngo Weinhold			esac
641c0e8cc1aSIngo Weinhold			set_variable buildCrossToolsMachine_$targetArch $targetMachine
642c0e8cc1aSIngo Weinhold			targetArchs="$targetArchs $targetArch"
643c0e8cc1aSIngo Weinhold			HAIKU_PACKAGING_ARCHS=
6449b0dd528SIngo Weinhold			;;
6459b0dd528SIngo Weinhold		--cross-tools-prefix)
6469b0dd528SIngo Weinhold			assertparam "$1" $#
647c0e8cc1aSIngo Weinhold			targetArch=unknown${unknownArchIndex}
648c0e8cc1aSIngo Weinhold			set_variable crossToolsPrefix_$targetArch "$2"
649c0e8cc1aSIngo Weinhold			targetArchs="$targetArchs $targetArch"
650c0e8cc1aSIngo Weinhold			HAIKU_PACKAGING_ARCHS=
651d68208faSMatt Madia			unknownArchIndex=$(($unknownArchIndex + 1))
6529b0dd528SIngo Weinhold			shift 2
6539b0dd528SIngo Weinhold			;;
654a66c32ddSIngo Weinhold		--distro-compatibility)
6559b0dd528SIngo Weinhold			assertparam "$1" $#
6567c4641d0SOliver Tappe			HAIKU_DISTRO_COMPATIBILITY=$2
6577c4641d0SOliver Tappe			case "$HAIKU_DISTRO_COMPATIBILITY" in
658a66c32ddSIngo Weinhold				official)	;;
659a66c32ddSIngo Weinhold				compatible)	;;
660a66c32ddSIngo Weinhold				default)	;;
661a66c32ddSIngo Weinhold				*)			echo "Invalid distro compatibility" \
6627c4641d0SOliver Tappe								"level: $HAIKU_DISTRO_COMPATIBILITY"
663a66c32ddSIngo Weinhold							exit 1;;
664a66c32ddSIngo Weinhold			esac
6659b0dd528SIngo Weinhold			shift 2
6669b0dd528SIngo Weinhold			;;
6677c4641d0SOliver Tappe		--enable-multiuser)	HAIKU_ENABLE_MULTIUSER=1; shift 1;;
66860d8d8fcSIngo Weinhold		--help | -h)	usage; exit 0;;
6692ebcd86dSIngo Weinhold		--host-only)	HAIKU_HOST_BUILD_ONLY=1; shift 1;;
6707c4641d0SOliver Tappe		--include-gpl-addons)	HAIKU_INCLUDE_GPL_ADDONS=1; shift 1;;
6717c4641d0SOliver Tappe		--include-patented-code)	HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;;
67276fa0be3SIngo Weinhold		--include-sources)	HAIKU_INCLUDE_SOURCES=1; shift 1;;
6737c4641d0SOliver Tappe		--include-3rdparty)	HAIKU_INCLUDE_3RDPARTY=1; shift 1;;
67460d8d8fcSIngo Weinhold        -j*)				buildCrossToolsJobs="$1"; shift 1;;
675aa2e5ecaSOliver Tappe		--no-downloads)	HAIKU_NO_DOWNLOADS=1; shift 1;;
6767c4641d0SOliver Tappe		--target=*)     TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;;
677483b28e4SIngo Weinhold		--target-arch)
678483b28e4SIngo Weinhold			assertparam "$1" $#
679483b28e4SIngo Weinhold			targetArch=$2
680483b28e4SIngo Weinhold			shift 2
681483b28e4SIngo Weinhold			if [ ! "$platform" = Haiku ]; then
682483b28e4SIngo Weinhold				echo "--target-arch can only be specified on Haiku." >&2
683483b28e4SIngo Weinhold				exit 1
684483b28e4SIngo Weinhold			fi
685483b28e4SIngo Weinhold			is_in_list "$targetArch" "$supportedTargetArchs" || (
686483b28e4SIngo Weinhold				echo "Unsupported target architecture: \"$targetArch\"" >&2
687483b28e4SIngo Weinhold				exit 1
688483b28e4SIngo Weinhold			)
689483b28e4SIngo Weinhold			haikuTargetArchs="$haikuTargetArchs $targetArch"
690483b28e4SIngo Weinhold			;;
691e70c4c64SPulkoMandy		--target-board)
692e70c4c64SPulkoMandy			assertparam "$1" $#
693e70c4c64SPulkoMandy			HAIKU_BOOT_BOARD=$2
694e70c4c64SPulkoMandy			is_in_list "$HAIKU_BOOT_BOARD" "$supportedTargetBoards" || (
695e70c4c64SPulkoMandy				echo "Unsupported target board: \"$HAIKU_BOOT_BOARD\"" >&2
696e70c4c64SPulkoMandy				exit 1
697e70c4c64SPulkoMandy			)
698e70c4c64SPulkoMandy			shift 2
699e70c4c64SPulkoMandy			;;
700c2b76f7fSJonathan Schleifer		--use-clang) useClang=1; shift 1;;
7017c4641d0SOliver Tappe		--use-gcc-pipe)	HAIKU_USE_GCC_PIPE=1; shift 1;;
702c0e8cc1aSIngo Weinhold		--use-gcc-graphite)	useGccGraphiteDefault=1; shift 1;;
7037986925fSIngo Weinhold		--use-32bit)	HAIKU_HOST_USE_32BIT=1; shift 1;;
7047986925fSIngo Weinhold		--use-xattr)	HAIKU_HOST_USE_XATTR=1; shift 1;;
705bc96e8f3SIngo Weinhold		--use-xattr-ref)	HAIKU_HOST_USE_XATTR_REF=1; shift 1;;
706022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
707022fa244SIngo Weinhold	esac
708022fa244SIngo Weinholddone
709022fa244SIngo Weinhold
7100df3cc9cSIngo Weinhold# detect the build platform
711338b8dc3SIngo Weinholdcase "${platform}" in
7127c4641d0SOliver Tappe	Darwin)	HOST_PLATFORM=darwin ;;
7137c4641d0SOliver Tappe	FreeBSD)	HOST_PLATFORM=freebsd
714c505b276SFrançois Revol				SFDISK_BINARY=sfdisk-linux
7157986925fSIngo Weinhold				if [ "$HAIKU_HOST_USE_32BIT" = 1 ] ; then
7165abd9a46SIngo Weinhold					echo Unsupported platform: FreeBSD ${platformMachine}
717308c212cSIngo Weinhold					exit 1
718308c212cSIngo Weinhold				fi	;;
7197c4641d0SOliver Tappe	Haiku)	HOST_PLATFORM=haiku_host ;;
7207c4641d0SOliver Tappe	Linux)	HOST_PLATFORM=linux ;;
7217c4641d0SOliver Tappe	OpenBSD) HOST_PLATFORM=openbsd ;;
7227c4641d0SOliver Tappe	SunOS)	HOST_PLATFORM=sunos ;;
7237c4641d0SOliver Tappe	CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
724338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
7254cbe4925SAxel Dörfler			exit 1 ;;
7264cbe4925SAxel Dörfleresac
72752a38012Sejakowatz
728c505b276SFrançois Revol# check common locations for sfdisk
729c505b276SFrançois Revolfor sfdiskDir in /sbin /usr/sbin /usr/local/sbin ; do
730c505b276SFrançois Revol	if [ -e ${sfdiskDir}/${SFDISK_BINARY} ]; then
731c505b276SFrançois Revol		HOST_SFDISK=${sfdiskDir}/${SFDISK_BINARY}
732c505b276SFrançois Revol	fi
733c505b276SFrançois Revoldone
734c505b276SFrançois Revol
7350962132cSAlex Smith# check for case-sensitive filesystem
7360962132cSAlex Smithmkdir haikuCaseTest 2>/dev/null
7370962132cSAlex Smithmkdir haikucasetest 2>/dev/null
7380962132cSAlex SmithcaseInsensitive=$?
73997f5a0bdSAlex Smithrmdir haikuCaseTest haikucasetest 2>/dev/null
7400962132cSAlex Smithif [ $caseInsensitive != 0 ]; then
7413ecc5287SMichael Lotz	echo "You need a case-sensitive file-system to build Haiku."
7420962132cSAlex Smith	if [ $HOST_PLATFORM = "darwin" ]; then
7430962132cSAlex Smith		echo "You can create a case-sensitive disk image using Disk Utility and use"
7440962132cSAlex Smith		echo "it to store the Haiku sources on."
7453ecc5287SMichael Lotz	fi
7460962132cSAlex Smith	exit 1
7473ecc5287SMichael Lotzfi
7483ecc5287SMichael Lotz
749f04f7042SNiels Sascha Reedijk# determine how to invoke sed with extended regexp support for non-GNU sed
750f04f7042SNiels Sascha Reedijkif [ $HOST_PLATFORM = "darwin" ]; then
751f04f7042SNiels Sascha Reedijk	HOST_EXTENDED_REGEX_SED="sed -E"
752f04f7042SNiels Sascha Reedijkfi
753f04f7042SNiels Sascha Reedijk
754338b8dc3SIngo Weinhold# create output directory
7556e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1
756338b8dc3SIngo Weinhold
7572ebcd86dSIngo Weinholdif [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
7582ebcd86dSIngo Weinhold	invalidCommand=$sourceDir/build/scripts/host_build_only
7592ebcd86dSIngo Weinhold	HAIKU_AR=$invalidCommand
7602ebcd86dSIngo Weinhold	HAIKU_CC=$invalidCommand
7612ebcd86dSIngo Weinhold	HAIKU_LD=$invalidCommand
7622ebcd86dSIngo Weinhold	HAIKU_OBJCOPY=$invalidCommand
7632ebcd86dSIngo Weinhold	HAIKU_RANLIB=$invalidCommand
7642ebcd86dSIngo Weinhold	HAIKU_ELFEDIT=$invalidCommand
765d6f80927SJonathan Schleifer	HAIKU_NASM=$invalidCommand
7662ebcd86dSIngo Weinhold	HAIKU_STRIP=$invalidCommand
7672ebcd86dSIngo Weinholdelse
768c0e8cc1aSIngo Weinhold	if [ -n "$HAIKU_PACKAGING_ARCHS" ]; then
769c0e8cc1aSIngo Weinhold		targetArchs="$HAIKU_PACKAGING_ARCHS"
770c0e8cc1aSIngo Weinhold	fi
771c0e8cc1aSIngo Weinhold	HAIKU_PACKAGING_ARCHS=
772c0e8cc1aSIngo Weinhold
773483b28e4SIngo Weinhold	# On Haiku determine target architectures and tools automatically.
774c0e8cc1aSIngo Weinhold	if [ -z "$targetArchs" ]; then
775483b28e4SIngo Weinhold		if [ $HOST_PLATFORM != haiku_host ]; then
776483b28e4SIngo Weinhold			echo "Please specify the build tools to use or build (via" \
777eaef83a9SJeroen Oortwijn				"--cross-tools-prefix or --build-cross-tools) or specify a" \
778483b28e4SIngo Weinhold				"host-only build (--host-only)." >&2
779483b28e4SIngo Weinhold			exit 1
780483b28e4SIngo Weinhold		fi
781483b28e4SIngo Weinhold
782483b28e4SIngo Weinhold		# determine primary architecture
783dda53eaeSIngo Weinhold		targetArch=`package list -i /system/packages/haiku-*.hpkg \
784483b28e4SIngo Weinhold			| sed '/^\s*architecture:/!d; s,^\s*architecture:\s*,,'`
785483b28e4SIngo Weinhold		is_in_list "$targetArch" "$supportedTargetArchs" || (
786483b28e4SIngo Weinhold			echo "Unsupported target architecture: \"$targetArch\"" >&2
787483b28e4SIngo Weinhold			exit 1
788483b28e4SIngo Weinhold		)
789c0e8cc1aSIngo Weinhold		targetArchs=$targetArch
790483b28e4SIngo Weinhold
791c0e8cc1aSIngo Weinhold		set_default_value HAIKU_AR_$targetArch			ar
792c0e8cc1aSIngo Weinhold		set_default_value HAIKU_CC_$targetArch			gcc
793c0e8cc1aSIngo Weinhold		set_default_value HAIKU_LD_$targetArch			ld
794c0e8cc1aSIngo Weinhold		set_default_value HAIKU_OBJCOPY_$targetArch		objcopy
795c0e8cc1aSIngo Weinhold		set_default_value HAIKU_RANLIB_$targetArch		ranlib
796c0e8cc1aSIngo Weinhold		set_default_value HAIKU_ELFEDIT_$targetArch		elfedit
797c0e8cc1aSIngo Weinhold		set_default_value HAIKU_STRIP_$targetArch		strip
798483b28e4SIngo Weinhold
799483b28e4SIngo Weinhold		# determine secondary architectures
800483b28e4SIngo Weinhold		for targetArch in $supportedTargetArchs; do
80180262a91SMatt Madia			if [ -e /system/packages/haiku_$targetArch-*.hpkg ]; then
802483b28e4SIngo Weinhold				targetArchs="$targetArchs $targetArch"
803483b28e4SIngo Weinhold				set_default_value HAIKU_AR_$targetArch		ar-$targetArch
804483b28e4SIngo Weinhold				set_default_value HAIKU_CC_$targetArch		gcc-$targetArch
805483b28e4SIngo Weinhold				set_default_value HAIKU_LD_$targetArch		ld-$targetArch
806483b28e4SIngo Weinhold				set_default_value HAIKU_OBJCOPY_$targetArch	objcopy-$targetArch
807483b28e4SIngo Weinhold				set_default_value HAIKU_RANLIB_$targetArch	ranlib-$targetArch
808483b28e4SIngo Weinhold				set_default_value HAIKU_ELFEDIT_$targetArch	elfedit-$targetArch
809483b28e4SIngo Weinhold				set_default_value HAIKU_STRIP_$targetArch	strip-$targetArch
810483b28e4SIngo Weinhold			fi
811483b28e4SIngo Weinhold		done
812483b28e4SIngo Weinhold
813483b28e4SIngo Weinhold		# The target architectures might have been specified explicitly.
814483b28e4SIngo Weinhold		if [ -n "$haikuTargetArchs" ]; then
815483b28e4SIngo Weinhold			for targetArch in $haikuTargetArchs; do
816483b28e4SIngo Weinhold				is_in_list "$targetArch" "$targetArchs" || (
817483b28e4SIngo Weinhold					echo "Unsupported target architecture: \"$targetArch\"." \
818483b28e4SIngo Weinhold						"Only native architectures of the host platform can" \
819483b28e4SIngo Weinhold						"be specified." >&2
820483b28e4SIngo Weinhold					exit 1
821483b28e4SIngo Weinhold				)
822483b28e4SIngo Weinhold			done
823483b28e4SIngo Weinhold			targetArchs="$haikuTargetArchs"
824483b28e4SIngo Weinhold		fi
825c0e8cc1aSIngo Weinhold	fi
826c0e8cc1aSIngo Weinhold
82768ccc989SIngo Weinhold	isPrimaryArch=1
828c0e8cc1aSIngo Weinhold	for targetArch in $targetArchs; do
829c0e8cc1aSIngo Weinhold		# Note: targetArch is "unknown<n>" at this point, if a cross-tools
830c0e8cc1aSIngo Weinhold		# prefix was specified. The standard_gcc_settings call below will get
831c0e8cc1aSIngo Weinhold		# the actual architecture.
832c0e8cc1aSIngo Weinhold
833c0e8cc1aSIngo Weinhold		crossToolsPrefix=`get_variable crossToolsPrefix_$targetArch`
834c0e8cc1aSIngo Weinhold
835338b8dc3SIngo Weinhold		# build cross tools from sources
836c0e8cc1aSIngo Weinhold		if [ -n "$buildCrossTools" -a -z "$crossToolsPrefix" ]; then
837c0e8cc1aSIngo Weinhold			crossToolsDir="$outputDir/cross-tools-$targetArch"
838c0e8cc1aSIngo Weinhold			targetMachine=`get_variable buildCrossToolsMachine_$targetArch`
839c0e8cc1aSIngo Weinhold			script="$buildCrossToolsScript"
8408304ec7cSIngo Weinhold			scriptArgs=
841c0e8cc1aSIngo Weinhold			if [ $targetArch != x86_gcc2 ]; then
8428304ec7cSIngo Weinhold				script="${script}_gcc4"
8438304ec7cSIngo Weinhold				scriptArgs="$targetMachine"
8441e93288eSJérôme Duval				set_default_value HAIKU_USE_GCC_GRAPHITE_$targetArch	\
8451e93288eSJérôme Duval					$useGccGraphiteDefault
846c0e8cc1aSIngo Weinhold			fi
84768ccc989SIngo Weinhold			secondaryArch=
84868ccc989SIngo Weinhold			if [ -z "$isPrimaryArch" ]; then
84968ccc989SIngo Weinhold				secondaryArch=$targetArch
85068ccc989SIngo Weinhold			fi
85186de8c37SIngo Weinhold
85286de8c37SIngo Weinhold			case $HOST_PLATFORM in
85386de8c37SIngo Weinhold				freebsd|openbsd)	MAKE=gmake;;
85486de8c37SIngo Weinhold				*)					MAKE=make;;
85586de8c37SIngo Weinhold			esac
85686de8c37SIngo Weinhold
85786de8c37SIngo Weinhold			MAKE=$MAKE \
85868ccc989SIngo Weinhold			SECONDARY_ARCH=$secondaryArch \
859c0e8cc1aSIngo Weinhold			HAIKU_USE_GCC_GRAPHITE=`get_variable \
860c0e8cc1aSIngo Weinhold				HAIKU_USE_GCC_GRAPHITE_$targetArch` \
861b3ece905SJérôme Duval			HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
8628304ec7cSIngo Weinhold			"$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
8638304ec7cSIngo Weinhold				"$crossToolsDir" $buildCrossToolsJobs || exit 1
864c0e8cc1aSIngo Weinhold			crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
865338b8dc3SIngo Weinhold		fi
866338b8dc3SIngo Weinhold
867c0e8cc1aSIngo Weinhold		# prepare gcc settings and get the actual target architecture
868c0e8cc1aSIngo Weinhold		gcc="${crossToolsPrefix}gcc"
869c0e8cc1aSIngo Weinhold		if [ -z "${crossToolsPrefix}" ]; then
870c0e8cc1aSIngo Weinhold			gcc=`get_variable HAIKU_CC_$targetArch`
871338b8dc3SIngo Weinhold		fi
872c0e8cc1aSIngo Weinhold		standard_gcc_settings "$gcc"
873c0e8cc1aSIngo Weinhold		targetArch=$standard_gcc_settings_targetArch
874338b8dc3SIngo Weinhold
875c0e8cc1aSIngo Weinhold		# set default values for flags
876c0e8cc1aSIngo Weinhold		set_default_value HAIKU_CPPFLAGS_$targetArch	""
877c0e8cc1aSIngo Weinhold		set_default_value HAIKU_CCFLAGS_$targetArch		""
878c0e8cc1aSIngo Weinhold		set_default_value HAIKU_CXXFLAGS_$targetArch	""
879c0e8cc1aSIngo Weinhold		set_default_value HAIKU_LDFLAGS_$targetArch		""
880c0e8cc1aSIngo Weinhold		set_default_value HAIKU_ARFLAGS_$targetArch		cru
881c0e8cc1aSIngo Weinhold		set_default_value HAIKU_UNARFLAGS_$targetArch	x
882338b8dc3SIngo Weinhold
883c0e8cc1aSIngo Weinhold		# Override the cross tools variables, if the tools were built or a
884c0e8cc1aSIngo Weinhold		# prefix was specified.
885b7777272SAlex Smith		if [ -n "$crossToolsPrefix" ]; then
886c0e8cc1aSIngo Weinhold			get_build_tool_path AR_$targetArch ${crossToolsPrefix}ar
887c0e8cc1aSIngo Weinhold			get_build_tool_path LD_$targetArch ${crossToolsPrefix}ld
888c0e8cc1aSIngo Weinhold			get_build_tool_path OBJCOPY_$targetArch ${crossToolsPrefix}objcopy
889c0e8cc1aSIngo Weinhold			get_build_tool_path RANLIB_$targetArch ${crossToolsPrefix}ranlib
890c0e8cc1aSIngo Weinhold			get_build_tool_path STRIP_$targetArch ${crossToolsPrefix}strip
891c0e8cc1aSIngo Weinhold
892c0e8cc1aSIngo Weinhold			case `get_variable HAIKU_GCC_RAW_VERSION_$targetArch` in
893bd16f0ddSAlex Smith				4.*)
894c0e8cc1aSIngo Weinhold					get_build_tool_path ELFEDIT_$targetArch \
895c0e8cc1aSIngo Weinhold						${crossToolsPrefix}elfedit
896bd16f0ddSAlex Smith				;;
897bd16f0ddSAlex Smith			esac
89852a38012Sejakowatz		fi
89952a38012Sejakowatz
900c0e8cc1aSIngo Weinhold		# Get the libgcc objects. We couldn't do that in standard_gcc_settings,
901c0e8cc1aSIngo Weinhold		# since we need "ar", which may be set later.
902c0e8cc1aSIngo Weinhold		ar=`get_variable HAIKU_AR_$targetArch`
903c0e8cc1aSIngo Weinhold		libgcc=`get_variable HAIKU_GCC_LIBGCC_$targetArch`
904c0e8cc1aSIngo Weinhold		set_variable HAIKU_GCC_LIBGCC_OBJECTS_$targetArch \
905c0e8cc1aSIngo Weinhold			"`$ar t $libgcc | grep -v eabi.o`"
906c0e8cc1aSIngo Weinhold			# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC
907c0e8cc1aSIngo Weinhold			# and neither needed nor wanted.
908c0e8cc1aSIngo Weinhold
909ef57df3dSIngo Weinhold		# check whether the Haiku compiler really targets Haiku
910c0e8cc1aSIngo Weinhold		targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch`
911c0e8cc1aSIngo Weinhold		case "$targetMachine" in
912eedc3d0bSIngo Weinhold			*-*-haiku)	;;
913c0e8cc1aSIngo Weinhold			*)
914c0e8cc1aSIngo Weinhold				echo The compiler specified as Haiku target compiler is not a \
915c0e8cc1aSIngo Weinhold				valid Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
916eedc3d0bSIngo Weinhold				echo compiler: $HAIKU_CC
917c0e8cc1aSIngo Weinhold				echo compiler is configured for target: $targetMachine
918eedc3d0bSIngo Weinhold				exit 1 ;;
919eedc3d0bSIngo Weinhold		esac
920c0e8cc1aSIngo Weinhold
921c0e8cc1aSIngo Weinhold		HAIKU_PACKAGING_ARCHS="$HAIKU_PACKAGING_ARCHS $targetArch"
92268ccc989SIngo Weinhold		isPrimaryArch=
923c0e8cc1aSIngo Weinhold	done
9242ebcd86dSIngo Weinholdfi
925eedc3d0bSIngo Weinhold
92652a38012Sejakowatz# Generate BuildConfig
9277c4641d0SOliver Tappecat << EOF > "$buildConfigFile"
92852a38012Sejakowatz# BuildConfig
929ab2540c4SIngo Weinhold# Note: This file has been automatically generated by configure with the
930ab2540c4SIngo Weinhold# following arguments:
93155d267a4SFrançois Revol# ${configureArgs}
93252a38012Sejakowatz
9337c4641d0SOliver TappeTARGET_PLATFORM 			?= "${TARGET_PLATFORM}" ;
9347c4641d0SOliver TappeHOST_PLATFORM				?= "${HOST_PLATFORM}" ;
935338b8dc3SIngo Weinhold
9367c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS			?= "${HAIKU_INCLUDE_GPL_ADDONS}" ;
9377c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE			?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
93876fa0be3SIngo WeinholdHAIKU_INCLUDE_SOURCES				?= "${HAIKU_INCLUDE_SOURCES}" ;
9397c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY				?= "${HAIKU_INCLUDE_3RDPARTY}" ;
9407c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER				?= "${HAIKU_ENABLE_MULTIUSER}" ;
9417c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY			?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
9427c4641d0SOliver TappeHAIKU_USE_GCC_PIPE					?= "${HAIKU_USE_GCC_PIPE}" ;
9437986925fSIngo WeinholdHAIKU_HOST_USE_32BIT				?= "${HAIKU_HOST_USE_32BIT}" ;
9447986925fSIngo WeinholdHAIKU_HOST_USE_XATTR				?= "${HAIKU_HOST_USE_XATTR}" ;
945bc96e8f3SIngo WeinholdHAIKU_HOST_USE_XATTR_REF			?= "${HAIKU_HOST_USE_XATTR_REF}" ;
9462ebcd86dSIngo WeinholdHAIKU_HOST_BUILD_ONLY				?= "${HAIKU_HOST_BUILD_ONLY}" ;
947eccc7665SIngo Weinhold
948c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCHS		?= ${HAIKU_PACKAGING_ARCHS} ;
94965ad1ba3SAlex Smith
950aa2e5ecaSOliver TappeHAIKU_NO_DOWNLOADS			?= "${HAIKU_NO_DOWNLOADS}" ;
951aa2e5ecaSOliver Tappe
9527c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR	?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
953338b8dc3SIngo Weinhold
954d6f80927SJonathan SchleiferHAIKU_NASM					?= ${HAIKU_NASM} ;
955e70c4c64SPulkoMandyHAIKU_BOOT_BOARD			?= ${HAIKU_BOOT_BOARD} ;
956338b8dc3SIngo Weinhold
957f04f7042SNiels Sascha ReedijkHOST_EXTENDED_REGEX_SED		?= ${HOST_EXTENDED_REGEX_SED} ;
9587c4641d0SOliver TappeHOST_GCC_RAW_VERSION		?= ${HOST_GCC_RAW_VERSION} ;
9597c4641d0SOliver TappeHOST_GCC_MACHINE			?= ${HOST_GCC_MACHINE} ;
9607c4641d0SOliver TappeHOST_LD						?= ${HOST_GCC_LD} ;
9617c4641d0SOliver TappeHOST_OBJCOPY				?= ${HOST_GCC_OBJCOPY} ;
962c505b276SFrançois RevolHOST_SFDISK					?= ${HOST_SFDISK} ;
9632a5d0aafSIngo WeinholdHOST_SHA256					?= ${HOST_SHA256} ;
9648b5934c9SIngo Weinhold
965e173a1ecSIngo WeinholdHOST_HAIKU_PORTER			?= ${HOST_HAIKU_PORTER} ;
966e173a1ecSIngo WeinholdHAIKU_PORTS					?= ${HAIKU_PORTS} ;
967e173a1ecSIngo WeinholdHAIKU_PORTS_CROSS			?= ${HAIKU_PORTS_CROSS} ;
968e173a1ecSIngo Weinhold
969c4786ea6SlilloEOF
970c4786ea6Slillo
971c0e8cc1aSIngo Weinholdfor targetArch in $HAIKU_PACKAGING_ARCHS; do
972c0e8cc1aSIngo Weinhold	variables="
973c0e8cc1aSIngo Weinhold		HAIKU_GCC_RAW_VERSION		HAIKU_GCC_RAW_VERSION
974c0e8cc1aSIngo Weinhold		HAIKU_GCC_MACHINE			HAIKU_GCC_MACHINE
975c0e8cc1aSIngo Weinhold		HAIKU_GCC_LIB_DIR			HAIKU_GCC_LIB_DIR
976c0e8cc1aSIngo Weinhold		HAIKU_GCC_LIBGCC			HAIKU_GCC_LIBGCC
977c0e8cc1aSIngo Weinhold		HAIKU_CPU					HAIKU_CPU
978c0e8cc1aSIngo Weinhold		HAIKU_STATIC_LIBSTDC++		HAIKU_STATIC_LIBSTDCXX
979c0e8cc1aSIngo Weinhold		HAIKU_SHARED_LIBSTDC++		HAIKU_SHARED_LIBSTDCXX
980c0e8cc1aSIngo Weinhold		HAIKU_STATIC_LIBSUPC++		HAIKU_STATIC_LIBSUPCXX
981c0e8cc1aSIngo Weinhold		HAIKU_SHARED_LIBSUPC++		HAIKU_SHARED_LIBSUPCXX
982c0e8cc1aSIngo Weinhold		HAIKU_KERNEL_LIBGCC			HAIKU_KERNEL_LIBGCC
983c0e8cc1aSIngo Weinhold		HAIKU_KERNEL_LIBSUPC++		HAIKU_KERNEL_LIBSUPCXX
984c0e8cc1aSIngo Weinhold		HAIKU_BOOT_LIBGCC			HAIKU_BOOT_LIBGCC
985c0e8cc1aSIngo Weinhold		HAIKU_BOOT_LIBSUPC++		HAIKU_BOOT_LIBSUPCXX
986c0e8cc1aSIngo Weinhold		HAIKU_AR					HAIKU_AR
987c0e8cc1aSIngo Weinhold		HAIKU_CC					HAIKU_CC
988c2b76f7fSJonathan Schleifer		HAIKU_CC_IS_CLANG			HAIKU_CC_IS_CLANG
989c0e8cc1aSIngo Weinhold		HAIKU_LD					HAIKU_LD
990c0e8cc1aSIngo Weinhold		HAIKU_OBJCOPY				HAIKU_OBJCOPY
991c0e8cc1aSIngo Weinhold		HAIKU_RANLIB				HAIKU_RANLIB
992c0e8cc1aSIngo Weinhold		HAIKU_ELFEDIT				HAIKU_ELFEDIT
993c0e8cc1aSIngo Weinhold		HAIKU_STRIP					HAIKU_STRIP
994c0e8cc1aSIngo Weinhold		HAIKU_CPPFLAGS				HAIKU_CPPFLAGS
995c0e8cc1aSIngo Weinhold		HAIKU_CCFLAGS				HAIKU_CCFLAGS
996c0e8cc1aSIngo Weinhold		HAIKU_C++FLAGS				HAIKU_CXXFLAGS
997c0e8cc1aSIngo Weinhold		HAIKU_LDFLAGS				HAIKU_LDFLAGS
998c0e8cc1aSIngo Weinhold		HAIKU_ARFLAGS				HAIKU_ARFLAGS
999c0e8cc1aSIngo Weinhold		HAIKU_UNARFLAGS				HAIKU_UNARFLAGS
1000c0e8cc1aSIngo Weinhold		HAIKU_USE_GCC_GRAPHITE		HAIKU_USE_GCC_GRAPHITE
1001c0e8cc1aSIngo Weinhold		"
1002c0e8cc1aSIngo Weinhold	set -- $variables
1003c0e8cc1aSIngo Weinhold	while [ $# -ge 2 ]; do
1004c0e8cc1aSIngo Weinhold		value=`get_variable ${2}_$targetArch`
1005c0e8cc1aSIngo Weinhold		echo "${1}_${targetArch} ?= $value ;" >> "$buildConfigFile"
1006c0e8cc1aSIngo Weinhold		shift 2
1007c0e8cc1aSIngo Weinhold	done
1008b1e5b60cSAxel Dörfler
1009c0e8cc1aSIngo Weinhold	# For variables that may have long values, distribute them over multiple
1010c0e8cc1aSIngo Weinhold	# lines so that jam doesn't hit the maximum line length.
1011c0e8cc1aSIngo Weinhold	variables="
1012c0e8cc1aSIngo Weinhold		HAIKU_GCC_HEADERS_DIR		HAIKU_GCC_HEADERS_DIR
1013c0e8cc1aSIngo Weinhold		HAIKU_C++_HEADERS_DIR		HAIKU_CXX_HEADERS_DIR
101466a7f29fSJérôme Duval		HAIKU_BOOT_C++_HEADERS_DIR	HAIKU_BOOT_CXX_HEADERS_DIR
1015c0e8cc1aSIngo Weinhold		HAIKU_GCC_LIBGCC_OBJECTS	HAIKU_GCC_LIBGCC_OBJECTS
1016c0e8cc1aSIngo Weinhold		"
1017c0e8cc1aSIngo Weinhold	set -- $variables
1018c0e8cc1aSIngo Weinhold	while [ $# -ge 2 ]; do
1019c0e8cc1aSIngo Weinhold		echo "${1}_${targetArch} ?= " >> "$buildConfigFile"
1020c0e8cc1aSIngo Weinhold		get_variable ${2}_$targetArch | xargs -n 1 echo "   " \
1021c0e8cc1aSIngo Weinhold			>> "$buildConfigFile"
1022c0e8cc1aSIngo Weinhold		echo "    ;" >> "$buildConfigFile"
1023c0e8cc1aSIngo Weinhold		shift 2
1024c0e8cc1aSIngo Weinhold	done
1025c0e8cc1aSIngo Weinholddone
1026b1e5b60cSAxel Dörfler
1027b1e5b60cSAxel Dörfler
10289b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
1029338b8dc3SIngo Weinhold
1030338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
1031338b8dc3SIngo Weinhold# automatically generated Jamfile
1032338b8dc3SIngo Weinhold
1033338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
1034338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
1035338b8dc3SIngo Weinhold
1036338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
1037338b8dc3SIngo Weinhold
1038338b8dc3SIngo WeinholdEOF
1039