xref: /haiku/configure (revision 55d267a46d48658b0a08ef79611f6c79fa265952)
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:
1560d8d8fcSIngo Weinhold  --alternative-gcc-output-dir <dir>
1660d8d8fcSIngo Weinhold                              Build a Haiku installation that supports running
1760d8d8fcSIngo Weinhold                              executables built with a gcc version incompatible
1860d8d8fcSIngo Weinhold                              with the primary gcc (e.g. gcc 2 executables under
1960d8d8fcSIngo Weinhold                              a gcc 4 Haiku or vice versa). <dir> specifies the
2060d8d8fcSIngo Weinhold                              output directory of the other gcc. The directory
2160d8d8fcSIngo Weinhold                              must already be fully configured.
2260d8d8fcSIngo Weinhold                              Note, that a sub-jam will be executed when
2360d8d8fcSIngo Weinhold                              building Haiku. When using a jam that is not
2460d8d8fcSIngo Weinhold                              simply invoked by "jam", the JAM build variable
2560d8d8fcSIngo Weinhold                              needs to be set accordingly.
2660d8d8fcSIngo Weinhold                              To disable building the alternative libraries
2760d8d8fcSIngo Weinhold                              the variable HAIKU_ADD_ALTERNATIVE_GCC_LIBS can be
2860d8d8fcSIngo Weinhold                              unset in the UserBuildConfig file.
29338b8dc3SIngo Weinhold  --build-cross-tools <build tools dir>
30338b8dc3SIngo Weinhold                              Assume cross compilation. <build tools dir>
31338b8dc3SIngo Weinhold                              defines the location of the build tools sources.
32338b8dc3SIngo Weinhold                              They will be compiled and placed in the output
33a5b60fa8SOliver Tappe                              directory under "cross-tools". The HAIKU_* tools
34a5b60fa8SOliver Tappe                              variables will be set accordingly.
3520ab75e6SIngo Weinhold  --build-cross-tools-gcc4 <arch> <build tools dir>
3629ef597dSIngo Weinhold                              Like "--build-cross-tools" just that gcc 4 will
37a5b60fa8SOliver Tappe                              be used for cross-compilation. Note, that the
38a5b60fa8SOliver Tappe                              resulting Haiku installation built with gcc 4
39a5b60fa8SOliver Tappe                              will not be binary compatible with BeOS R5.
4020ab75e6SIngo Weinhold                              <arch> specifies the target architecture, either
41161ad355SJérôme Duval                              "x86", "ppc", "m68k", "arm" or "mipsel".
42eccc7665SIngo Weinhold  --cross-tools-prefix <prefix>
43eccc7665SIngo Weinhold                              Assume cross compilation. <prefix> should be a
44eccc7665SIngo Weinhold                              path to the directory where the cross
45eccc7665SIngo Weinhold                              compilation tools are located, plus the platform
460da9c208SIngo Weinhold                              prefix, e.g. "/path/to/tools/i586-pc-haiku-".
47eccc7665SIngo Weinhold                              This overrides the HAIKU_* tool variables.
48a66c32ddSIngo Weinhold  --distro-compatibility <level>
49a66c32ddSIngo Weinhold                              The distribution's level of compatibility with
50a66c32ddSIngo Weinhold                              the official Haiku distribution. The generated
51a66c32ddSIngo Weinhold                              files will contain the respective trademarks
52a66c32ddSIngo Weinhold                              accordingly.
53a66c32ddSIngo Weinhold                              official -- the official Haiku distribution.
54a66c32ddSIngo Weinhold                              compatible -- a Haiku Compatible (tm) distro.
55a66c32ddSIngo Weinhold                              default -- any other distro (default value).
5660d8d8fcSIngo Weinhold  --enable-multiuser          Enable experimental multiuser support.
57eccc7665SIngo Weinhold  --help                      Prints out this help.
58eccc7665SIngo Weinhold  --include-gpl-addons        Include GPL licensed add-ons.
5967838392SAxel Dörfler  --include-patented-code     Enable code that is known to implemented patented
6067838392SAxel Dörfler                              ideas and techniques. If this option is not
6167838392SAxel Dörfler                              specified, the resulting distribution may still
6267838392SAxel Dörfler                              implement patented ideas and techniques. This
6367838392SAxel Dörfler                              option only disables code that is currently known
6467838392SAxel Dörfler                              to be problematic.
651974210fSFrançois Revol  --include-3rdparty          Include 3rdparty/ in the build system.
6660d8d8fcSIngo Weinhold  -j<n>                       Only relevant for --build-cross-tools and
6760d8d8fcSIngo Weinhold                              --build-cross-tools-gcc4. Is passed on to the
6860d8d8fcSIngo Weinhold                              make building the build tools.
69614026d7Sshatty  --target=TARGET             Select build target platform. [default=${target}]
70a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
71eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
725a34a443SFrançois Revol                              process, but uses more memory.
730385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
744f4e5272SIngo Weinhold  --use-xattr                 Use Linux xattr support for BeOS attribute
754f4e5272SIngo Weinhold                              emulation. Warning: Make sure your file system
764f4e5272SIngo Weinhold                              supports sufficient attribute sizes (4 KB per
774f4e5272SIngo Weinhold                              file for all attributes won't suffice).
78338b8dc3SIngo Weinhold
79338b8dc3SIngo Weinholdenvironment variables:
80338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
81338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
82338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
83338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
84338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
8577e84f21SIngo Weinhold  HAIKU_YASM                  The yasm assembler (x86 only).
86338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
87338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
88338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
89338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
90338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
9123eb9a9eSFrançois Revol                              Defaults to "cru".
92338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
93338b8dc3SIngo Weinhold                              Defaults to "x".
9464f6da31SIngo Weinhold
9564f6da31SIngo WeinholdNon-standard output directories:
9664f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
9764f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
9864f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
9964f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
10064f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
10164f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
10264f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
10364f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
10464f6da31SIngo Weinhold  non-default location and running jam.
10564f6da31SIngo Weinhold
10664f6da31SIngo Weinhold
107022fa244SIngo WeinholdEOF
108022fa244SIngo Weinhold}
109022fa244SIngo Weinhold
110022fa244SIngo Weinhold# assertparam
111022fa244SIngo Weinhold#
112022fa244SIngo Weinhold# Checks whether at least one parameter is left.
113022fa244SIngo Weinhold#
114022fa244SIngo Weinholdassertparam()
115022fa244SIngo Weinhold{
11620ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
117022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
118022fa244SIngo Weinhold		exit 1
119022fa244SIngo Weinhold	fi
120022fa244SIngo Weinhold}
121022fa244SIngo Weinhold
12220ab75e6SIngo Weinhold# assertparams
12320ab75e6SIngo Weinhold#
12420ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
12520ab75e6SIngo Weinhold#
12620ab75e6SIngo Weinholdassertparams()
12720ab75e6SIngo Weinhold{
12820ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
12920ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
13020ab75e6SIngo Weinhold		exit 1
13120ab75e6SIngo Weinhold	fi
13220ab75e6SIngo Weinhold}
13320ab75e6SIngo Weinhold
13409c5682dSIngo Weinhold# standard_gcc_settings
13509c5682dSIngo Weinhold#
13609c5682dSIngo Weinhold# Sets the variables for a GCC platform.
13709c5682dSIngo Weinhold#
13809c5682dSIngo Weinholdstandard_gcc_settings()
13909c5682dSIngo Weinhold{
14009c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
141338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
14209c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
1435b0f7b1bSOliver Tappe
144338b8dc3SIngo Weinhold	haikuGCCVersion=`$HAIKU_CC -dumpversion`
145338b8dc3SIngo Weinhold	haikuGCCMachine=`$HAIKU_CC -dumpmachine`
146338b8dc3SIngo Weinhold
147338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
148338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
149338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
15028b5bc75SMichael Lotz	HAIKU_GCC_HEADERS_DIR="${gccdir}/include
15128b5bc75SMichael Lotz		${gccdir}/include-fixed"
1525d978968SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`$HAIKU_AR t ${HAIKU_GCC_LIBGCC} | grep -v eabi.o`
1535d978968SIngo Weinhold		# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC and
1545d978968SIngo Weinhold		# neither needed nor wanted.
1558b5934c9SIngo Weinhold
1568b5934c9SIngo Weinhold	case $haikuGCCVersion in
1578b5934c9SIngo Weinhold		4.*)
1585b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
1595b0f7b1bSOliver Tappe			# compiler
1608b5934c9SIngo Weinhold			haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
1618b5934c9SIngo Weinhold			haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
162c89fc875SIngo Weinhold			haikuStaticLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.a`
163c89fc875SIngo Weinhold			haikuSharedLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.so`
16414210488SMichael Lotz
16514210488SMichael Lotz			local headers
16614210488SMichael Lotz			if [ -d $gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion ]; then
16714210488SMichael Lotz				headers=$gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion
16814210488SMichael Lotz			else
16914210488SMichael Lotz				headers=$gccdir/../../../../include/c++/$haikuGCCVersion
17014210488SMichael Lotz			fi
17114210488SMichael Lotz
1728b5934c9SIngo Weinhold			haikuCxxHeadersDir=$headers
17329ef597dSIngo Weinhold			for d in $haikuGCCMachine backward ext; do
17429ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
17529ef597dSIngo Weinhold				# too long for jam (512 bytes max).
17629ef597dSIngo Weinhold				haikuCxxHeadersDir="$haikuCxxHeadersDir
17729ef597dSIngo Weinhold					$headers/$d"
1788b5934c9SIngo Weinhold			done
179274b450aSMarcus Overhagen
180dad36002SMarcus Overhagen
181dad36002SMarcus Overhagen			# when not building the crosscompiler, to use cpp headers from
182274b450aSMarcus Overhagen			# tree first, but fallback to local C++ system headers (like <new>)
183dad36002SMarcus Overhagen			# if [ "$buildCrossTools" = "" ]; then
184dad36002SMarcus Overhagen			#	haikuCxxHeadersDir="headers/cpp $haikuCxxHeadersDir"
185dad36002SMarcus Overhagen			# fi
1868b5934c9SIngo Weinhold
1878b5934c9SIngo Weinhold			if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
1888b5934c9SIngo Weinhold				haikuStaticLibStdCxx=
1898b5934c9SIngo Weinhold			fi
19016d5c24eSOliver Tappe			# we build libstdc++.so ourselves, so we can leave it as is
19116d5c24eSOliver Tappe			# if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
19216d5c24eSOliver Tappe			#	haikuSharedLibStdCxx=
19316d5c24eSOliver Tappe			# fi
194c89fc875SIngo Weinhold			if [ $haikuStaticLibSupCxx = libsupc++.a ]; then
195c89fc875SIngo Weinhold				haikuStaticLibSupCxx=
196c89fc875SIngo Weinhold			fi
19716d5c24eSOliver Tappe			# we build libsupc++.so ourselves, so we can leave it as is
19816d5c24eSOliver Tappe			# if [ $haikuSharedLibSupCxx = libsupc++.so ]; then
19916d5c24eSOliver Tappe			# 	haikuSharedLibSupCxx=
20016d5c24eSOliver Tappe			# fi
2018b5934c9SIngo Weinhold		;;
2026cc8eecfSOliver Tappe		2.9*)
2035b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
2045b0f7b1bSOliver Tappe			# if an older one is installed
2055b0f7b1bSOliver Tappe			if [ $haikuGCCVersion != $haikuRequiredLegacyGCCVersion ]; then
2065b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
2075b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
2085b0f7b1bSOliver Tappe				exit 1;
2095b0f7b1bSOliver Tappe			fi
2105b0f7b1bSOliver Tappe		;;
2118b5934c9SIngo Weinhold	esac
21209c5682dSIngo Weinhold}
21309c5682dSIngo Weinhold
214338b8dc3SIngo Weinhold# set_default_value
215338b8dc3SIngo Weinhold#
216338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
217338b8dc3SIngo Weinhold#
218338b8dc3SIngo Weinholdset_default_value()
219338b8dc3SIngo Weinhold{
2200838a930SJérôme Duval	eval "$1=\${$1-$2}"
221338b8dc3SIngo Weinhold}
222338b8dc3SIngo Weinhold
223338b8dc3SIngo Weinhold# get_build_tool_path
224338b8dc3SIngo Weinhold#
225338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
226338b8dc3SIngo Weinhold#
227338b8dc3SIngo Weinholdget_build_tool_path()
228338b8dc3SIngo Weinhold{
229338b8dc3SIngo Weinhold	local var="HAIKU_$1"
230338b8dc3SIngo Weinhold	local tool=$2
231338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
232338b8dc3SIngo Weinhold
233338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
234338b8dc3SIngo Weinhold		# get absolute path
235a559f87aSFrançois Revol		local oldPwd="`pwd`"
236a559f87aSFrançois Revol		cd "`dirname "$path"`"
237a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
238338b8dc3SIngo Weinhold		cd $oldPwd
239338b8dc3SIngo Weinhold	else
240338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
241338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
242338b8dc3SIngo Weinhold			exit 1
243338b8dc3SIngo Weinhold		}
244338b8dc3SIngo Weinhold	fi
245338b8dc3SIngo Weinhold
246338b8dc3SIngo Weinhold	eval "$var=$path"
247338b8dc3SIngo Weinhold}
248338b8dc3SIngo Weinhold
249338b8dc3SIngo Weinhold# get cwd and the source directory
250338b8dc3SIngo WeinholdcurrentDir=`pwd`
2516e7c6fe5SIngo Weinholdcd `dirname "$0"`
252338b8dc3SIngo WeinholdsourceDir=`pwd`
2536e7c6fe5SIngo Weinholdcd "$currentDir"
254338b8dc3SIngo Weinhold
255*55d267a4SFrançois Revol# backup the passed arguments
256*55d267a4SFrançois RevolconfigureArgs="$@"
257*55d267a4SFrançois Revol
258022fa244SIngo Weinhold# default parameter values
259022fa244SIngo Weinhold#
26052a38012Sejakowatzplatform=`uname`
2615abd9a46SIngo WeinholdplatformMachine=`uname  -m`
262338b8dc3SIngo WeinholdhaikuGCCVersion=
2630da9c208SIngo WeinholdhaikuGCCMachine=i586-pc-haiku
2648b5934c9SIngo WeinholdhaikuStaticLibStdCxx=
2658b5934c9SIngo WeinholdhaikuSharedLibStdCxx=
266c89fc875SIngo WeinholdhaikuStaticLibSupCxx=
267c89fc875SIngo WeinholdhaikuSharedLibSupCxx=
2688b5934c9SIngo WeinholdhaikuCxxHeadersDir=
269db63fe67SAxel DörflerhostGCCVersion=`gcc -dumpversion`
270a85cf9d7SIngo WeinholdhostGCCMachine=`gcc -dumpmachine`
2715abd9a46SIngo WeinholdincludeGPLAddOns=0
27267838392SAxel DörflerincludePatentedCode=0
2735abd9a46SIngo Weinholdinclude3rdParty=0
2745abd9a46SIngo WeinholdenableMultiuser=0
275a66c32ddSIngo WeinholddistroCompatibility=default
27662339647SAxel Dörflertarget=haiku
27777e84f21SIngo WeinholdtargetArch=x86
2785abd9a46SIngo WeinholduseGCCPipe=0
2795abd9a46SIngo Weinholduse32bit=0
2805abd9a46SIngo WeinholduseXattr=0
281338b8dc3SIngo WeinholdcrossToolsPrefix=
282338b8dc3SIngo WeinholdbuildCrossTools=
28329ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
28420ab75e6SIngo WeinholdbuildCrossToolsMachine=
28560d8d8fcSIngo WeinholdbuildCrossToolsJobs=
2869b0dd528SIngo WeinholdalternativeGCCOutputDir=
287292e63bfSIngo WeinholdaddAlternativeGCCLibs=
288338b8dc3SIngo Weinhold
28916d5c24eSOliver TappehaikuRequiredLegacyGCCVersion="2.95.3-haiku-090629"
290a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
291af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
292af4bf973SOliver Tappe
293338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
294338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
295338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
296338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
297338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
29877e84f21SIngo Weinholdset_default_value HAIKU_YASM		yasm
299338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
300338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
301338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
302338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
30323eb9a9eSFrançois Revolset_default_value HAIKU_ARFLAGS		cru
304338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
30562339647SAxel Dörfler
306022fa244SIngo Weinhold# parse parameters
307022fa244SIngo Weinhold#
30820ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
309022fa244SIngo Weinhold	case "$1" in
31060d8d8fcSIngo Weinhold		--alternative-gcc-output-dir)
31160d8d8fcSIngo Weinhold			assertparam "$1" $#
31260d8d8fcSIngo Weinhold			cd $2 || exit 1
31360d8d8fcSIngo Weinhold			alternativeGCCOutputDir=`pwd`
31460d8d8fcSIngo Weinhold			addAlternativeGCCLibs=1
31560d8d8fcSIngo Weinhold			cd $currentDir
31660d8d8fcSIngo Weinhold			shift 2
31760d8d8fcSIngo Weinhold			;;
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			;;
35360d8d8fcSIngo Weinhold		--enable-multiuser)	enableMultiuser=1; shift 1;;
35460d8d8fcSIngo Weinhold		--help | -h)	usage; exit 0;;
35560d8d8fcSIngo Weinhold		--include-gpl-addons)	includeGPLAddOns=1; shift 1;;
35660d8d8fcSIngo Weinhold		--include-patented-code)	includePatentedCode=1; shift 1;;
35760d8d8fcSIngo Weinhold		--include-3rdparty)	include3rdParty=1; shift 1;;
35860d8d8fcSIngo 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" \
44160d8d8fcSIngo 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
471*55d267a4SFrançois Revol# Note: This file has been automatically generated by configure with the following arguments:
472*55d267a4SFrançois Revol# ${configureArgs}
47352a38012Sejakowatz
4746e7c6fe5SIngo WeinholdTARGET_PLATFORM 			?= "${target}" ;
4756e7c6fe5SIngo WeinholdHOST_PLATFORM				?= "${buildPlatform}" ;
476338b8dc3SIngo Weinhold
4770b58d844SIngo WeinholdHAIKU_INCLUDE_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} ;
516a85cf9d7SIngo WeinholdHOST_GCC_MACHINE			?= ${hostGCCMachine} ;
5178b5934c9SIngo Weinhold
518c4786ea6SlilloEOF
519c4786ea6Slillo
520b1e5b60cSAxel Dörfler# Libgcc.a objects
521b1e5b60cSAxel Dörfler
5226e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/libgccObjects"
523b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
524b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
525b1e5b60cSAxel Dörfler
526338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
527b1e5b60cSAxel DörflerEOF
528b1e5b60cSAxel Dörfler
5294c74bde8SJérôme Duval# Generate Timezones binaries bindings
5304c74bde8SJérôme Duval
531338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
532338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
533338b8dc3SIngo Weinhold
5346e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/Timezones"
535b1e5b60cSAxel Dörfler# Timezones used for the build
536b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
537b1e5b60cSAxel Dörfler
538338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
539338b8dc3SIngo Weinhold
540b1e5b60cSAxel DörflerEOF
541b1e5b60cSAxel Dörfler
542338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
5433578c56aSAxel Dörfler	f=$sourceDir/src/data/timezones/$source
5444c74bde8SJérôme Duval
5456e7c6fe5SIngo WeinholdTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' "$f" `
5464c74bde8SJérôme Duval
5476e7c6fe5SIngo Weinholdcat << EOF >> "$buildOutputDir/Timezones"
548338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
5494c74bde8SJérôme DuvalEOF
5504c74bde8SJérôme Duvaldone
551338b8dc3SIngo Weinhold
5529b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
553338b8dc3SIngo Weinhold
554338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
555338b8dc3SIngo Weinhold# automatically generated Jamfile
556338b8dc3SIngo Weinhold
557338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
558338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
559338b8dc3SIngo Weinhold
560338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
561338b8dc3SIngo Weinhold
562338b8dc3SIngo WeinholdEOF
563