xref: /haiku/configure (revision 60d8d8fcc5005cdd8cff9861a803e5fa6a8fd725)
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*60d8d8fcSIngo Weinhold  --alternative-gcc-output-dir <dir>
16*60d8d8fcSIngo Weinhold                              Build a Haiku installation that supports running
17*60d8d8fcSIngo Weinhold                              executables built with a gcc version incompatible
18*60d8d8fcSIngo Weinhold                              with the primary gcc (e.g. gcc 2 executables under
19*60d8d8fcSIngo Weinhold                              a gcc 4 Haiku or vice versa). <dir> specifies the
20*60d8d8fcSIngo Weinhold                              output directory of the other gcc. The directory
21*60d8d8fcSIngo Weinhold                              must already be fully configured.
22*60d8d8fcSIngo Weinhold                              Note, that a sub-jam will be executed when
23*60d8d8fcSIngo Weinhold                              building Haiku. When using a jam that is not
24*60d8d8fcSIngo Weinhold                              simply invoked by "jam", the JAM build variable
25*60d8d8fcSIngo Weinhold                              needs to be set accordingly.
26*60d8d8fcSIngo Weinhold                              To disable building the alternative libraries
27*60d8d8fcSIngo Weinhold                              the variable HAIKU_ADD_ALTERNATIVE_GCC_LIBS can be
28*60d8d8fcSIngo Weinhold                              unset in the UserBuildConfig file.
296f9587ddSAxel Dörfler  --bochs-debug               Enables bochs serial debug emulation (activated
306f9587ddSAxel Dörfler                              via kernel settings file).
31338b8dc3SIngo Weinhold  --build-cross-tools <build tools dir>
32338b8dc3SIngo Weinhold                              Assume cross compilation. <build tools dir>
33338b8dc3SIngo Weinhold                              defines the location of the build tools sources.
34338b8dc3SIngo Weinhold                              They will be compiled and placed in the output
35a5b60fa8SOliver Tappe                              directory under "cross-tools". The HAIKU_* tools
36a5b60fa8SOliver Tappe                              variables will be set accordingly.
3720ab75e6SIngo Weinhold  --build-cross-tools-gcc4 <arch> <build tools dir>
3829ef597dSIngo Weinhold                              Like "--build-cross-tools" just that gcc 4 will
39a5b60fa8SOliver Tappe                              be used for cross-compilation. Note, that the
40a5b60fa8SOliver Tappe                              resulting Haiku installation built with gcc 4
41a5b60fa8SOliver Tappe                              will not be binary compatible with BeOS R5.
4220ab75e6SIngo Weinhold                              <arch> specifies the target architecture, either
43161ad355SJérôme Duval                              "x86", "ppc", "m68k", "arm" or "mipsel".
44eccc7665SIngo Weinhold  --cross-tools-prefix <prefix>
45eccc7665SIngo Weinhold                              Assume cross compilation. <prefix> should be a
46eccc7665SIngo Weinhold                              path to the directory where the cross
47eccc7665SIngo Weinhold                              compilation tools are located, plus the platform
480da9c208SIngo Weinhold                              prefix, e.g. "/path/to/tools/i586-pc-haiku-".
49eccc7665SIngo Weinhold                              This overrides the HAIKU_* tool variables.
50a66c32ddSIngo Weinhold  --distro-compatibility <level>
51a66c32ddSIngo Weinhold                              The distribution's level of compatibility with
52a66c32ddSIngo Weinhold                              the official Haiku distribution. The generated
53a66c32ddSIngo Weinhold                              files will contain the respective trademarks
54a66c32ddSIngo Weinhold                              accordingly.
55a66c32ddSIngo Weinhold                              official -- the official Haiku distribution.
56a66c32ddSIngo Weinhold                              compatible -- a Haiku Compatible (tm) distro.
57a66c32ddSIngo Weinhold                              default -- any other distro (default value).
58*60d8d8fcSIngo Weinhold  --enable-multiuser          Enable experimental multiuser support.
59eccc7665SIngo Weinhold  --help                      Prints out this help.
60eccc7665SIngo Weinhold  --include-gpl-addons        Include GPL licensed add-ons.
6167838392SAxel Dörfler  --include-patented-code     Enable code that is known to implemented patented
6267838392SAxel Dörfler                              ideas and techniques. If this option is not
6367838392SAxel Dörfler                              specified, the resulting distribution may still
6467838392SAxel Dörfler                              implement patented ideas and techniques. This
6567838392SAxel Dörfler                              option only disables code that is currently known
6667838392SAxel Dörfler                              to be problematic.
671974210fSFrançois Revol  --include-3rdparty          Include 3rdparty/ in the build system.
68*60d8d8fcSIngo Weinhold  -j<n>                       Only relevant for --build-cross-tools and
69*60d8d8fcSIngo Weinhold                              --build-cross-tools-gcc4. Is passed on to the
70*60d8d8fcSIngo Weinhold                              make building the build tools.
71614026d7Sshatty  --target=TARGET             Select build target platform. [default=${target}]
72a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
73eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
745a34a443SFrançois Revol                              process, but uses more memory.
750385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
764f4e5272SIngo Weinhold  --use-xattr                 Use Linux xattr support for BeOS attribute
774f4e5272SIngo Weinhold                              emulation. Warning: Make sure your file system
784f4e5272SIngo Weinhold                              supports sufficient attribute sizes (4 KB per
794f4e5272SIngo Weinhold                              file for all attributes won't suffice).
80338b8dc3SIngo Weinhold
81338b8dc3SIngo Weinholdenvironment variables:
82338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
83338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
84338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
85338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
86338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
8777e84f21SIngo Weinhold  HAIKU_YASM                  The yasm assembler (x86 only).
88338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
89338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
90338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
91338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
92338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
9323eb9a9eSFrançois Revol                              Defaults to "cru".
94338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
95338b8dc3SIngo Weinhold                              Defaults to "x".
9664f6da31SIngo Weinhold
9764f6da31SIngo WeinholdNon-standard output directories:
9864f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
9964f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
10064f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
10164f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
10264f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
10364f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
10464f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
10564f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
10664f6da31SIngo Weinhold  non-default location and running jam.
10764f6da31SIngo Weinhold
10864f6da31SIngo Weinhold
109022fa244SIngo WeinholdEOF
110022fa244SIngo Weinhold}
111022fa244SIngo Weinhold
112022fa244SIngo Weinhold# assertparam
113022fa244SIngo Weinhold#
114022fa244SIngo Weinhold# Checks whether at least one parameter is left.
115022fa244SIngo Weinhold#
116022fa244SIngo Weinholdassertparam()
117022fa244SIngo Weinhold{
11820ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
119022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
120022fa244SIngo Weinhold		exit 1
121022fa244SIngo Weinhold	fi
122022fa244SIngo Weinhold}
123022fa244SIngo Weinhold
12420ab75e6SIngo Weinhold# assertparams
12520ab75e6SIngo Weinhold#
12620ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
12720ab75e6SIngo Weinhold#
12820ab75e6SIngo Weinholdassertparams()
12920ab75e6SIngo Weinhold{
13020ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
13120ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
13220ab75e6SIngo Weinhold		exit 1
13320ab75e6SIngo Weinhold	fi
13420ab75e6SIngo Weinhold}
13520ab75e6SIngo Weinhold
13609c5682dSIngo Weinhold# standard_gcc_settings
13709c5682dSIngo Weinhold#
13809c5682dSIngo Weinhold# Sets the variables for a GCC platform.
13909c5682dSIngo Weinhold#
14009c5682dSIngo Weinholdstandard_gcc_settings()
14109c5682dSIngo Weinhold{
14209c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
143338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
14409c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
1455b0f7b1bSOliver Tappe
146338b8dc3SIngo Weinhold	haikuGCCVersion=`$HAIKU_CC -dumpversion`
147338b8dc3SIngo Weinhold	haikuGCCMachine=`$HAIKU_CC -dumpmachine`
148338b8dc3SIngo Weinhold
149338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
150338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
151338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
15228b5bc75SMichael Lotz	HAIKU_GCC_HEADERS_DIR="${gccdir}/include
15328b5bc75SMichael Lotz		${gccdir}/include-fixed"
1545d978968SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`$HAIKU_AR t ${HAIKU_GCC_LIBGCC} | grep -v eabi.o`
1555d978968SIngo Weinhold		# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC and
1565d978968SIngo Weinhold		# neither needed nor wanted.
1578b5934c9SIngo Weinhold
1588b5934c9SIngo Weinhold	case $haikuGCCVersion in
1598b5934c9SIngo Weinhold		4.*)
1605b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
1615b0f7b1bSOliver Tappe			# compiler
1628b5934c9SIngo Weinhold			haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
1638b5934c9SIngo Weinhold			haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
164c89fc875SIngo Weinhold			haikuStaticLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.a`
165c89fc875SIngo Weinhold			haikuSharedLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.so`
16614210488SMichael Lotz
16714210488SMichael Lotz			local headers
16814210488SMichael Lotz			if [ -d $gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion ]; then
16914210488SMichael Lotz				headers=$gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion
17014210488SMichael Lotz			else
17114210488SMichael Lotz				headers=$gccdir/../../../../include/c++/$haikuGCCVersion
17214210488SMichael Lotz			fi
17314210488SMichael Lotz
1748b5934c9SIngo Weinhold			haikuCxxHeadersDir=$headers
17529ef597dSIngo Weinhold			for d in $haikuGCCMachine backward ext; do
17629ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
17729ef597dSIngo Weinhold				# too long for jam (512 bytes max).
17829ef597dSIngo Weinhold				haikuCxxHeadersDir="$haikuCxxHeadersDir
17929ef597dSIngo Weinhold					$headers/$d"
1808b5934c9SIngo Weinhold			done
181274b450aSMarcus Overhagen
182dad36002SMarcus Overhagen
183dad36002SMarcus Overhagen			# when not building the crosscompiler, to use cpp headers from
184274b450aSMarcus Overhagen			# tree first, but fallback to local C++ system headers (like <new>)
185dad36002SMarcus Overhagen			# if [ "$buildCrossTools" = "" ]; then
186dad36002SMarcus Overhagen			#	haikuCxxHeadersDir="headers/cpp $haikuCxxHeadersDir"
187dad36002SMarcus Overhagen			# fi
1888b5934c9SIngo Weinhold
1898b5934c9SIngo Weinhold			if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
1908b5934c9SIngo Weinhold				haikuStaticLibStdCxx=
1918b5934c9SIngo Weinhold			fi
19216d5c24eSOliver Tappe			# we build libstdc++.so ourselves, so we can leave it as is
19316d5c24eSOliver Tappe			# if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
19416d5c24eSOliver Tappe			#	haikuSharedLibStdCxx=
19516d5c24eSOliver Tappe			# fi
196c89fc875SIngo Weinhold			if [ $haikuStaticLibSupCxx = libsupc++.a ]; then
197c89fc875SIngo Weinhold				haikuStaticLibSupCxx=
198c89fc875SIngo Weinhold			fi
19916d5c24eSOliver Tappe			# we build libsupc++.so ourselves, so we can leave it as is
20016d5c24eSOliver Tappe			# if [ $haikuSharedLibSupCxx = libsupc++.so ]; then
20116d5c24eSOliver Tappe			# 	haikuSharedLibSupCxx=
20216d5c24eSOliver Tappe			# fi
2038b5934c9SIngo Weinhold		;;
2046cc8eecfSOliver Tappe		2.9*)
2055b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
2065b0f7b1bSOliver Tappe			# if an older one is installed
2075b0f7b1bSOliver Tappe			if [ $haikuGCCVersion != $haikuRequiredLegacyGCCVersion ]; then
2085b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
2095b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
2105b0f7b1bSOliver Tappe				exit 1;
2115b0f7b1bSOliver Tappe			fi
2125b0f7b1bSOliver Tappe		;;
2138b5934c9SIngo Weinhold	esac
21409c5682dSIngo Weinhold}
21509c5682dSIngo Weinhold
216338b8dc3SIngo Weinhold# set_default_value
217338b8dc3SIngo Weinhold#
218338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
219338b8dc3SIngo Weinhold#
220338b8dc3SIngo Weinholdset_default_value()
221338b8dc3SIngo Weinhold{
2220838a930SJérôme Duval	eval "$1=\${$1-$2}"
223338b8dc3SIngo Weinhold}
224338b8dc3SIngo Weinhold
225338b8dc3SIngo Weinhold# get_build_tool_path
226338b8dc3SIngo Weinhold#
227338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
228338b8dc3SIngo Weinhold#
229338b8dc3SIngo Weinholdget_build_tool_path()
230338b8dc3SIngo Weinhold{
231338b8dc3SIngo Weinhold	local var="HAIKU_$1"
232338b8dc3SIngo Weinhold	local tool=$2
233338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
234338b8dc3SIngo Weinhold
235338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
236338b8dc3SIngo Weinhold		# get absolute path
237a559f87aSFrançois Revol		local oldPwd="`pwd`"
238a559f87aSFrançois Revol		cd "`dirname "$path"`"
239a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
240338b8dc3SIngo Weinhold		cd $oldPwd
241338b8dc3SIngo Weinhold	else
242338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
243338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
244338b8dc3SIngo Weinhold			exit 1
245338b8dc3SIngo Weinhold		}
246338b8dc3SIngo Weinhold	fi
247338b8dc3SIngo Weinhold
248338b8dc3SIngo Weinhold	eval "$var=$path"
249338b8dc3SIngo Weinhold}
250338b8dc3SIngo Weinhold
251338b8dc3SIngo Weinhold# get cwd and the source directory
252338b8dc3SIngo WeinholdcurrentDir=`pwd`
2536e7c6fe5SIngo Weinholdcd `dirname "$0"`
254338b8dc3SIngo WeinholdsourceDir=`pwd`
2556e7c6fe5SIngo Weinholdcd "$currentDir"
256338b8dc3SIngo Weinhold
257022fa244SIngo Weinhold# default parameter values
258022fa244SIngo Weinhold#
25952a38012Sejakowatzplatform=`uname`
2605abd9a46SIngo WeinholdplatformMachine=`uname  -m`
261338b8dc3SIngo WeinholdhaikuGCCVersion=
2620da9c208SIngo WeinholdhaikuGCCMachine=i586-pc-haiku
2638b5934c9SIngo WeinholdhaikuStaticLibStdCxx=
2648b5934c9SIngo WeinholdhaikuSharedLibStdCxx=
265c89fc875SIngo WeinholdhaikuStaticLibSupCxx=
266c89fc875SIngo WeinholdhaikuSharedLibSupCxx=
2678b5934c9SIngo WeinholdhaikuCxxHeadersDir=
268db63fe67SAxel DörflerhostGCCVersion=`gcc -dumpversion`
2695abd9a46SIngo WeinholdbochsDebug=0
2705abd9a46SIngo WeinholdincludeGPLAddOns=0
27167838392SAxel DörflerincludePatentedCode=0
2725abd9a46SIngo Weinholdinclude3rdParty=0
2735abd9a46SIngo WeinholdenableMultiuser=0
274a66c32ddSIngo WeinholddistroCompatibility=default
27562339647SAxel Dörflertarget=haiku
27677e84f21SIngo WeinholdtargetArch=x86
2775abd9a46SIngo WeinholduseGCCPipe=0
2785abd9a46SIngo Weinholduse32bit=0
2795abd9a46SIngo WeinholduseXattr=0
280338b8dc3SIngo WeinholdcrossToolsPrefix=
281338b8dc3SIngo WeinholdbuildCrossTools=
28229ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
28320ab75e6SIngo WeinholdbuildCrossToolsMachine=
284*60d8d8fcSIngo WeinholdbuildCrossToolsJobs=
2859b0dd528SIngo WeinholdalternativeGCCOutputDir=
286292e63bfSIngo WeinholdaddAlternativeGCCLibs=
287338b8dc3SIngo Weinhold
28816d5c24eSOliver TappehaikuRequiredLegacyGCCVersion="2.95.3-haiku-090629"
289a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
290af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
291af4bf973SOliver Tappe
292338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
293338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
294338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
295338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
296338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
29777e84f21SIngo Weinholdset_default_value HAIKU_YASM		yasm
298338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
299338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
300338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
301338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
30223eb9a9eSFrançois Revolset_default_value HAIKU_ARFLAGS		cru
303338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
30462339647SAxel Dörfler
305022fa244SIngo Weinhold# parse parameters
306022fa244SIngo Weinhold#
30720ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
308022fa244SIngo Weinhold	case "$1" in
309*60d8d8fcSIngo Weinhold		--alternative-gcc-output-dir)
310*60d8d8fcSIngo Weinhold			assertparam "$1" $#
311*60d8d8fcSIngo Weinhold			cd $2 || exit 1
312*60d8d8fcSIngo Weinhold			alternativeGCCOutputDir=`pwd`
313*60d8d8fcSIngo Weinhold			addAlternativeGCCLibs=1
314*60d8d8fcSIngo Weinhold			cd $currentDir
315*60d8d8fcSIngo Weinhold			shift 2
316*60d8d8fcSIngo Weinhold			;;
3175abd9a46SIngo Weinhold		--bochs-debug)	bochsDebug=1; shift 1;;
318a5b60fa8SOliver Tappe		--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
3199b0dd528SIngo Weinhold		--build-cross-tools-gcc4)
3209b0dd528SIngo Weinhold			assertparams "$1" 2 $#
3219b0dd528SIngo Weinhold			buildCrossTools=$3
3229b0dd528SIngo Weinhold			buildCrossToolsScript="${buildCrossToolsScript}_gcc4"
32320ab75e6SIngo Weinhold			case "$2" in
32420ab75e6SIngo Weinhold				x86)	haikuGCCMachine=i586-pc-haiku;;
32577e84f21SIngo Weinhold				ppc)	haikuGCCMachine=powerpc-apple-haiku; targetArch=ppc;;
32677e84f21SIngo Weinhold				m68k)	haikuGCCMachine=m68k-unknown-haiku; targetArch=m86k;;
32777e84f21SIngo Weinhold				arm)	haikuGCCMachine=arm-unknown-haiku; targetArch=arm;;
32877e84f21SIngo Weinhold				mipsel)	haikuGCCMachine=mipsel-unknown-haiku; targetArch=mips;;
32920ab75e6SIngo Weinhold				*)		echo "Unsupported target architecture: $2"
33020ab75e6SIngo Weinhold						exit 1;;
33120ab75e6SIngo Weinhold			esac
332a5b60fa8SOliver Tappe			buildCrossToolsMachine=$haikuGCCMachine
3339b0dd528SIngo Weinhold			shift 3
3349b0dd528SIngo Weinhold			;;
3359b0dd528SIngo Weinhold		--cross-tools-prefix)
3369b0dd528SIngo Weinhold			assertparam "$1" $#
3379b0dd528SIngo Weinhold			crossToolsPrefix=$2
3389b0dd528SIngo Weinhold			shift 2
3399b0dd528SIngo Weinhold			;;
340a66c32ddSIngo Weinhold		--distro-compatibility)
3419b0dd528SIngo Weinhold			assertparam "$1" $#
3429b0dd528SIngo Weinhold			distroCompatibility=$2
343a66c32ddSIngo Weinhold			case "$distroCompatibility" in
344a66c32ddSIngo Weinhold				official)	;;
345a66c32ddSIngo Weinhold				compatible)	;;
346a66c32ddSIngo Weinhold				default)	;;
347a66c32ddSIngo Weinhold				*)			echo "Invalid distro compatibility" \
348a66c32ddSIngo Weinhold								"level: $distroCompatibility"
349a66c32ddSIngo Weinhold							exit 1;;
350a66c32ddSIngo Weinhold			esac
3519b0dd528SIngo Weinhold			shift 2
3529b0dd528SIngo Weinhold			;;
353*60d8d8fcSIngo Weinhold		--enable-multiuser)	enableMultiuser=1; shift 1;;
354*60d8d8fcSIngo Weinhold		--help | -h)	usage; exit 0;;
355*60d8d8fcSIngo Weinhold		--include-gpl-addons)	includeGPLAddOns=1; shift 1;;
356*60d8d8fcSIngo Weinhold		--include-patented-code)	includePatentedCode=1; shift 1;;
357*60d8d8fcSIngo Weinhold		--include-3rdparty)	include3rdParty=1; shift 1;;
358*60d8d8fcSIngo Weinhold        -j*)				buildCrossToolsJobs="$1"; shift 1;;
359eccc7665SIngo Weinhold		--target=*)     target=`echo $1 | cut -d'=' -f2-`; shift 1;;
3605abd9a46SIngo Weinhold		--use-gcc-pipe)	useGCCPipe=1; shift 1;;
3615abd9a46SIngo Weinhold		--use-32bit)	use32bit=1; shift 1;;
3625abd9a46SIngo Weinhold		--use-xattr)	useXattr=1; shift 1;;
363022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
364022fa244SIngo Weinhold	esac
365022fa244SIngo Weinholddone
366022fa244SIngo Weinhold
3670df3cc9cSIngo Weinhold# detect the build platform
368338b8dc3SIngo Weinholdcase "${platform}" in
3690df3cc9cSIngo Weinhold	BeOS)	revision=`uname -r`
3700df3cc9cSIngo Weinhold			case "$revision" in
37114998c8bSIngo Weinhold				6.*)	buildPlatform=dano ;;
3720df3cc9cSIngo Weinhold				5.1)	buildPlatform=dano ;;
3730df3cc9cSIngo Weinhold				5.0.4)	buildPlatform=bone ;;
3740df3cc9cSIngo Weinhold				5.0*)	buildPlatform=r5 ;;
3750df3cc9cSIngo Weinhold				*)		echo Unknown BeOS version: $revision
3760df3cc9cSIngo Weinhold						exit 1 ;;
3770df3cc9cSIngo Weinhold			esac
3780df3cc9cSIngo Weinhold			;;
3796dcd0ccfSIngo Weinhold	Darwin)	buildPlatform=darwin ;;
380308c212cSIngo Weinhold	FreeBSD)	buildPlatform=freebsd
3815abd9a46SIngo Weinhold				if [ "$use32bit" = 1 ] ; then
3825abd9a46SIngo Weinhold					echo Unsupported platform: FreeBSD ${platformMachine}
383308c212cSIngo Weinhold					exit 1
384308c212cSIngo Weinhold				fi	;;
385da0f9ae0SIngo Weinhold	Haiku)	buildPlatform=haiku_host ;;
386da0f9ae0SIngo Weinhold	Linux)	buildPlatform=linux ;;
387ff1beff8SFrançois Revol	OpenBSD) buildPlatform=openbsd ;;
388a559f87aSFrançois Revol	SunOS)	buildPlatform=sunos ;;
389e688a433SMaurice Kalinowski	CYGWIN_NT-*) buildPlatform=cygwin ;;
390338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
3914cbe4925SAxel Dörfler			exit 1 ;;
3924cbe4925SAxel Dörfleresac
39352a38012Sejakowatz
39477e84f21SIngo Weinhold# check yasm version
39577e84f21SIngo Weinholdif [ $targetArch = "x86" ]; then
39677e84f21SIngo Weinhold	$HAIKU_YASM --version > /dev/null || {
39792696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
39877e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
39977e84f21SIngo Weinhold		exit 1
40077e84f21SIngo Weinhold	}
40177e84f21SIngo Weinhold
40277e84f21SIngo Weinhold	set -- $($HAIKU_YASM --version | head -n 1)
40377e84f21SIngo Weinhold	versionOK=0
40477e84f21SIngo Weinhold	case $2 in
40592696166SIngo Weinhold		0.[0-6].*)		;;
40677e84f21SIngo Weinhold		*)				versionOK=1 ;;
40777e84f21SIngo Weinhold	esac
40877e84f21SIngo Weinhold
40977e84f21SIngo Weinhold	if [ $versionOK = 0 ]; then
41092696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
41177e84f21SIngo Weinhold		echo "The installed version is $2."
41277e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
41377e84f21SIngo Weinhold		exit 1
41477e84f21SIngo Weinhold	fi
41577e84f21SIngo Weinholdfi
41677e84f21SIngo Weinhold
4173ecc5287SMichael Lotz# check for case-sensitive filesystem if on darwin
4183ecc5287SMichael Lotzif [ $buildPlatform = "darwin" ]; then
4190651c859SMichael Pfeiffer	diskutil info $(pwd) | grep -i "case-sensitive" > /dev/null
4203ecc5287SMichael Lotz	if [ $? != 0 ]; then
4213ecc5287SMichael Lotz		echo "You need a case-sensitive file-system to build Haiku."
4223ecc5287SMichael Lotz		echo "Please see the following guide on how to set one up:"
4233ecc5287SMichael Lotz		echo "http://haiku-os.org/documents/dev/how_to_build_haiku_on_mac_os_x"
4243ecc5287SMichael Lotz		exit 1
4253ecc5287SMichael Lotz	fi
4263ecc5287SMichael Lotzfi
4273ecc5287SMichael Lotz
428338b8dc3SIngo Weinhold# create output directory
429338b8dc3SIngo Weinholdif [ "$currentDir" = "$sourceDir" ]; then
430338b8dc3SIngo Weinhold	outputDir=$currentDir/generated
431338b8dc3SIngo Weinholdelse
432338b8dc3SIngo Weinhold	outputDir=$currentDir
433338b8dc3SIngo Weinholdfi
4346e7c6fe5SIngo WeinholdbuildOutputDir="$outputDir/build"
4356e7c6fe5SIngo WeinholdbuildAttributesDir="$outputDir/attributes"
4366e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1
437338b8dc3SIngo Weinhold
438338b8dc3SIngo Weinhold# build cross tools from sources
439338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then
44020ab75e6SIngo Weinhold	"$buildCrossToolsScript" $buildCrossToolsMachine "$sourceDir" \
441*60d8d8fcSIngo Weinhold		"$buildCrossTools" "$outputDir" $buildCrossToolsJobs || exit 1
442a5b60fa8SOliver Tappe	crossToolsPrefix="$outputDir/cross-tools/bin/${haikuGCCMachine}-"
443338b8dc3SIngo Weinholdfi
444338b8dc3SIngo Weinhold
445338b8dc3SIngo Weinhold# cross tools
446338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then
447338b8dc3SIngo Weinhold	get_build_tool_path AR ar
448338b8dc3SIngo Weinhold	get_build_tool_path CC gcc
449338b8dc3SIngo Weinhold	get_build_tool_path LD ld
450338b8dc3SIngo Weinhold	get_build_tool_path OBJCOPY objcopy
451338b8dc3SIngo Weinhold	get_build_tool_path RANLIB ranlib
452338b8dc3SIngo Weinholdfi
453338b8dc3SIngo Weinhold
454338b8dc3SIngo Weinhold# prepare gcc settings
455338b8dc3SIngo Weinholdstandard_gcc_settings
456338b8dc3SIngo Weinhold
457eedc3d0bSIngo Weinhold# check whether the Haiku compiler really targets Haiku or BeOS
458eedc3d0bSIngo Weinholdcase "$haikuGCCMachine" in
459eedc3d0bSIngo Weinhold	*-*-haiku)	;;
460eedc3d0bSIngo Weinhold	*-*-beos)	;;
461eedc3d0bSIngo Weinhold	*) echo The compiler specified as Haiku target compiler is not a valid \
462eedc3d0bSIngo Weinhold			Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
463eedc3d0bSIngo Weinhold	   echo compiler: $HAIKU_CC
464eedc3d0bSIngo Weinhold	   echo compiler is configured for target: $haikuGCCMachine
465eedc3d0bSIngo Weinhold	   exit 1 ;;
466eedc3d0bSIngo Weinholdesac
467eedc3d0bSIngo Weinhold
46852a38012Sejakowatz# Generate BuildConfig
4696e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/BuildConfig"
47052a38012Sejakowatz# BuildConfig
47152a38012Sejakowatz# Note: This file has been automatically generated by configure.
47252a38012Sejakowatz
4736e7c6fe5SIngo WeinholdTARGET_PLATFORM 			?= "${target}" ;
4746e7c6fe5SIngo WeinholdHOST_PLATFORM				?= "${buildPlatform}" ;
475338b8dc3SIngo Weinhold
4765abd9a46SIngo WeinholdBOCHS_DEBUG_HACK					?= "${bochsDebug}" ;
4775abd9a46SIngo WeinholdINCLUDE_GPL_ADDONS					?= "${includeGPLAddOns}" ;
47867838392SAxel DörflerHAIKU_INCLUDE_PATENTED_CODE			?= "${includePatentedCode}" ;
4795abd9a46SIngo WeinholdHAIKU_INCLUDE_3RDPARTY				?= "${include3rdParty}" ;
4805abd9a46SIngo WeinholdHAIKU_ENABLE_MULTIUSER				?= "${enableMultiuser}" ;
481a66c32ddSIngo WeinholdHAIKU_DISTRO_COMPATIBILITY			?= "${distroCompatibility}" ;
4825abd9a46SIngo WeinholdHAIKU_USE_GCC_PIPE					?= "${useGCCPipe}" ;
4835abd9a46SIngo WeinholdHAIKU_HOST_USE_32BIT				?= "${use32bit}" ;
4845abd9a46SIngo WeinholdHAIKU_HOST_USE_XATTR				?= "${useXattr}" ;
4859b0dd528SIngo WeinholdHAIKU_ALTERNATIVE_GCC_OUTPUT_DIR	?= ${alternativeGCCOutputDir} ;
486292e63bfSIngo WeinholdHAIKU_ADD_ALTERNATIVE_GCC_LIBS		?= ${addAlternativeGCCLibs} ;
487eccc7665SIngo Weinhold
488338b8dc3SIngo WeinholdHAIKU_GCC_RAW_VERSION		?= ${haikuGCCVersion} ;
489338b8dc3SIngo WeinholdHAIKU_GCC_MACHINE			?= ${haikuGCCMachine} ;
490338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR			?= ${HAIKU_GCC_LIB_DIR} ;
491338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR		?= ${HAIKU_GCC_HEADERS_DIR} ;
492338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC			?= ${HAIKU_GCC_LIBGCC} ;
493338b8dc3SIngo Weinhold
4948b5934c9SIngo WeinholdHAIKU_STATIC_LIBSTDC++		?= ${haikuStaticLibStdCxx} ;
4958b5934c9SIngo WeinholdHAIKU_SHARED_LIBSTDC++		?= ${haikuSharedLibStdCxx} ;
496c89fc875SIngo WeinholdHAIKU_STATIC_LIBSUPC++		?= ${haikuStaticLibSupCxx} ;
497c89fc875SIngo WeinholdHAIKU_SHARED_LIBSUPC++		?= ${haikuSharedLibSupCxx} ;
4988b5934c9SIngo WeinholdHAIKU_C++_HEADERS_DIR		?= ${haikuCxxHeadersDir} ;
4998b5934c9SIngo Weinhold
500338b8dc3SIngo WeinholdHAIKU_BUILD_ATTRIBUTES_DIR	?= ${buildAttributesDir} ;
501338b8dc3SIngo Weinhold
502338b8dc3SIngo WeinholdHAIKU_AR					?= ${HAIKU_AR} ;
503338b8dc3SIngo WeinholdHAIKU_CC					?= ${HAIKU_CC} ;
504338b8dc3SIngo WeinholdHAIKU_LD					?= ${HAIKU_LD} ;
505338b8dc3SIngo WeinholdHAIKU_OBJCOPY				?= ${HAIKU_OBJCOPY} ;
506338b8dc3SIngo WeinholdHAIKU_RANLIB				?= ${HAIKU_RANLIB} ;
50777e84f21SIngo WeinholdHAIKU_YASM					?= ${HAIKU_YASM} ;
508338b8dc3SIngo WeinholdHAIKU_CPPFLAGS				?= ${HAIKU_CPPFLAGS} ;
509338b8dc3SIngo WeinholdHAIKU_CCFLAGS				?= ${HAIKU_CCFLAGS} ;
510338b8dc3SIngo WeinholdHAIKU_CXXFLAGS				?= ${HAIKU_CXXFLAGS} ;
511338b8dc3SIngo WeinholdHAIKU_LDFLAGS				?= ${HAIKU_LDFLAGS} ;
512338b8dc3SIngo WeinholdHAIKU_ARFLAGS				?= ${HAIKU_ARFLAGS} ;
513338b8dc3SIngo WeinholdHAIKU_UNARFLAGS				?= ${HAIKU_UNARFLAGS} ;
514338b8dc3SIngo Weinhold
5158b5934c9SIngo WeinholdHOST_GCC_RAW_VERSION		?= ${hostGCCVersion} ;
5168b5934c9SIngo Weinhold
517c4786ea6SlilloEOF
518c4786ea6Slillo
519b1e5b60cSAxel Dörfler# Libgcc.a objects
520b1e5b60cSAxel Dörfler
5216e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/libgccObjects"
522b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
523b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
524b1e5b60cSAxel Dörfler
525338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
526b1e5b60cSAxel DörflerEOF
527b1e5b60cSAxel Dörfler
5284c74bde8SJérôme Duval# Generate Timezones binaries bindings
5294c74bde8SJérôme Duval
530338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
531338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
532338b8dc3SIngo Weinhold
5336e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/Timezones"
534b1e5b60cSAxel Dörfler# Timezones used for the build
535b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
536b1e5b60cSAxel Dörfler
537338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
538338b8dc3SIngo Weinhold
539b1e5b60cSAxel DörflerEOF
540b1e5b60cSAxel Dörfler
541338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
5423578c56aSAxel Dörfler	f=$sourceDir/src/data/timezones/$source
5434c74bde8SJérôme Duval
5446e7c6fe5SIngo WeinholdTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' "$f" `
5454c74bde8SJérôme Duval
5466e7c6fe5SIngo Weinholdcat << EOF >> "$buildOutputDir/Timezones"
547338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
5484c74bde8SJérôme DuvalEOF
5494c74bde8SJérôme Duvaldone
550338b8dc3SIngo Weinhold
5519b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
552338b8dc3SIngo Weinhold
553338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
554338b8dc3SIngo Weinhold# automatically generated Jamfile
555338b8dc3SIngo Weinhold
556338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
557338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
558338b8dc3SIngo Weinhold
559338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
560338b8dc3SIngo Weinhold
561338b8dc3SIngo WeinholdEOF
562