xref: /haiku/configure (revision 3ecc52877442a2ff4019eba8613fbfc9a49d6718)
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:
156f9587ddSAxel Dörfler  --bochs-debug               Enables bochs serial debug emulation (activated
166f9587ddSAxel Dörfler                              via kernel settings file).
17338b8dc3SIngo Weinhold  --build-cross-tools <build tools dir>
18338b8dc3SIngo Weinhold                              Assume cross compilation. <build tools dir>
19338b8dc3SIngo Weinhold                              defines the location of the build tools sources.
20338b8dc3SIngo Weinhold                              They will be compiled and placed in the output
21a5b60fa8SOliver Tappe                              directory under "cross-tools". The HAIKU_* tools
22a5b60fa8SOliver Tappe                              variables will be set accordingly.
2320ab75e6SIngo Weinhold  --build-cross-tools-gcc4 <arch> <build tools dir>
2429ef597dSIngo Weinhold                              Like "--build-cross-tools" just that gcc 4 will
25a5b60fa8SOliver Tappe                              be used for cross-compilation. Note, that the
26a5b60fa8SOliver Tappe                              resulting Haiku installation built with gcc 4
27a5b60fa8SOliver Tappe                              will not be binary compatible with BeOS R5.
2820ab75e6SIngo Weinhold                              <arch> specifies the target architecture, either
29161ad355SJérôme Duval                              "x86", "ppc", "m68k", "arm" or "mipsel".
309b0dd528SIngo Weinhold  --alternative-gcc-output-dir <dir>
319b0dd528SIngo Weinhold                              Build a Haiku installation that supports running
329b0dd528SIngo Weinhold                              executables built with a gcc version incompatible
339b0dd528SIngo Weinhold                              with the primary gcc (e.g. gcc 2 executables under
349b0dd528SIngo Weinhold                              a gcc 4 Haiku or vice versa). <dir> specifies the
359b0dd528SIngo Weinhold                              output directory of the other gcc. The directory
369b0dd528SIngo Weinhold                              must already be fully configured.
37292e63bfSIngo Weinhold                              Note, that a sub-jam will be executed when
38292e63bfSIngo Weinhold                              building Haiku. When using a jam that is not
39292e63bfSIngo Weinhold                              simply invoked by "jam", the JAM build variable
40292e63bfSIngo Weinhold                              needs to be set accordingly.
41292e63bfSIngo Weinhold                              To disable building the alternative libraries
42292e63bfSIngo Weinhold                              the variable HAIKU_ADD_ALTERNATIVE_GCC_LIBS can be
43292e63bfSIngo Weinhold                              unset in the UserBuildConfig file.
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).
58eccc7665SIngo Weinhold  --help                      Prints out this help.
59eccc7665SIngo Weinhold  --include-gpl-addons        Include GPL licensed add-ons.
601974210fSFrançois Revol  --include-3rdparty          Include 3rdparty/ in the build system.
61f1b9c086SFrançois Revol  --enable-multiuser          Enable experimental multiuser support.
62614026d7Sshatty  --target=TARGET             Select build target platform. [default=${target}]
63a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
64eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
655a34a443SFrançois Revol                              process, but uses more memory.
660385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
674f4e5272SIngo Weinhold  --use-xattr                 Use Linux xattr support for BeOS attribute
684f4e5272SIngo Weinhold                              emulation. Warning: Make sure your file system
694f4e5272SIngo Weinhold                              supports sufficient attribute sizes (4 KB per
704f4e5272SIngo Weinhold                              file for all attributes won't suffice).
71338b8dc3SIngo Weinhold
72338b8dc3SIngo Weinholdenvironment variables:
73338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
74338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
75338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
76338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
77338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
7877e84f21SIngo Weinhold  HAIKU_YASM                  The yasm assembler (x86 only).
79338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
80338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
81338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
82338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
83338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
84338b8dc3SIngo Weinhold                              Defaults to "ru".
85338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
86338b8dc3SIngo Weinhold                              Defaults to "x".
8764f6da31SIngo Weinhold
8864f6da31SIngo WeinholdNon-standard output directories:
8964f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
9064f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
9164f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
9264f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
9364f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
9464f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
9564f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
9664f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
9764f6da31SIngo Weinhold  non-default location and running jam.
9864f6da31SIngo Weinhold
9964f6da31SIngo Weinhold
100022fa244SIngo WeinholdEOF
101022fa244SIngo Weinhold}
102022fa244SIngo Weinhold
103022fa244SIngo Weinhold# assertparam
104022fa244SIngo Weinhold#
105022fa244SIngo Weinhold# Checks whether at least one parameter is left.
106022fa244SIngo Weinhold#
107022fa244SIngo Weinholdassertparam()
108022fa244SIngo Weinhold{
10920ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
110022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
111022fa244SIngo Weinhold		exit 1
112022fa244SIngo Weinhold	fi
113022fa244SIngo Weinhold}
114022fa244SIngo Weinhold
11520ab75e6SIngo Weinhold# assertparams
11620ab75e6SIngo Weinhold#
11720ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
11820ab75e6SIngo Weinhold#
11920ab75e6SIngo Weinholdassertparams()
12020ab75e6SIngo Weinhold{
12120ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
12220ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
12320ab75e6SIngo Weinhold		exit 1
12420ab75e6SIngo Weinhold	fi
12520ab75e6SIngo Weinhold}
12620ab75e6SIngo Weinhold
12709c5682dSIngo Weinhold# standard_gcc_settings
12809c5682dSIngo Weinhold#
12909c5682dSIngo Weinhold# Sets the variables for a GCC platform.
13009c5682dSIngo Weinhold#
13109c5682dSIngo Weinholdstandard_gcc_settings()
13209c5682dSIngo Weinhold{
13309c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
134338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
13509c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
1365b0f7b1bSOliver Tappe
137338b8dc3SIngo Weinhold	haikuGCCVersion=`$HAIKU_CC -dumpversion`
138338b8dc3SIngo Weinhold	haikuGCCMachine=`$HAIKU_CC -dumpmachine`
139338b8dc3SIngo Weinhold
140338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
141338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
142338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
14328b5bc75SMichael Lotz	HAIKU_GCC_HEADERS_DIR="${gccdir}/include
14428b5bc75SMichael Lotz		${gccdir}/include-fixed"
1455d978968SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`$HAIKU_AR t ${HAIKU_GCC_LIBGCC} | grep -v eabi.o`
1465d978968SIngo Weinhold		# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC and
1475d978968SIngo Weinhold		# neither needed nor wanted.
1488b5934c9SIngo Weinhold
1498b5934c9SIngo Weinhold	case $haikuGCCVersion in
1508b5934c9SIngo Weinhold		4.*)
1515b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
1525b0f7b1bSOliver Tappe			# compiler
1538b5934c9SIngo Weinhold			haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
1548b5934c9SIngo Weinhold			haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
155c89fc875SIngo Weinhold			haikuStaticLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.a`
156c89fc875SIngo Weinhold			haikuSharedLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.so`
15714210488SMichael Lotz
15814210488SMichael Lotz			local headers
15914210488SMichael Lotz			if [ -d $gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion ]; then
16014210488SMichael Lotz				headers=$gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion
16114210488SMichael Lotz			else
16214210488SMichael Lotz				headers=$gccdir/../../../../include/c++/$haikuGCCVersion
16314210488SMichael Lotz			fi
16414210488SMichael Lotz
1658b5934c9SIngo Weinhold			haikuCxxHeadersDir=$headers
16629ef597dSIngo Weinhold			for d in $haikuGCCMachine backward ext; do
16729ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
16829ef597dSIngo Weinhold				# too long for jam (512 bytes max).
16929ef597dSIngo Weinhold				haikuCxxHeadersDir="$haikuCxxHeadersDir
17029ef597dSIngo Weinhold					$headers/$d"
1718b5934c9SIngo Weinhold			done
172274b450aSMarcus Overhagen
173dad36002SMarcus Overhagen
174dad36002SMarcus Overhagen			# when not building the crosscompiler, to use cpp headers from
175274b450aSMarcus Overhagen			# tree first, but fallback to local C++ system headers (like <new>)
176dad36002SMarcus Overhagen			# if [ "$buildCrossTools" = "" ]; then
177dad36002SMarcus Overhagen			#	haikuCxxHeadersDir="headers/cpp $haikuCxxHeadersDir"
178dad36002SMarcus Overhagen			# fi
1798b5934c9SIngo Weinhold
1808b5934c9SIngo Weinhold			if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
1818b5934c9SIngo Weinhold				haikuStaticLibStdCxx=
1828b5934c9SIngo Weinhold			fi
1838b5934c9SIngo Weinhold			if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
1848b5934c9SIngo Weinhold				haikuSharedLibStdCxx=
1858b5934c9SIngo Weinhold			fi
186c89fc875SIngo Weinhold			if [ $haikuStaticLibSupCxx = libsupc++.a ]; then
187c89fc875SIngo Weinhold				haikuStaticLibSupCxx=
188c89fc875SIngo Weinhold			fi
189c89fc875SIngo Weinhold			if [ $haikuSharedLibSupCxx = libsupc++.so ]; then
190c89fc875SIngo Weinhold				haikuSharedLibSupCxx=
191c89fc875SIngo Weinhold			fi
1928b5934c9SIngo Weinhold		;;
1936cc8eecfSOliver Tappe		2.9*)
1945b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
1955b0f7b1bSOliver Tappe			# if an older one is installed
1965b0f7b1bSOliver Tappe			if [ $haikuGCCVersion != $haikuRequiredLegacyGCCVersion ]; then
1975b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
1985b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
1995b0f7b1bSOliver Tappe				exit 1;
2005b0f7b1bSOliver Tappe			fi
2015b0f7b1bSOliver Tappe		;;
2028b5934c9SIngo Weinhold	esac
20309c5682dSIngo Weinhold}
20409c5682dSIngo Weinhold
205338b8dc3SIngo Weinhold# set_default_value
206338b8dc3SIngo Weinhold#
207338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
208338b8dc3SIngo Weinhold#
209338b8dc3SIngo Weinholdset_default_value()
210338b8dc3SIngo Weinhold{
2110838a930SJérôme Duval	eval "$1=\${$1-$2}"
212338b8dc3SIngo Weinhold}
213338b8dc3SIngo Weinhold
214338b8dc3SIngo Weinhold# get_build_tool_path
215338b8dc3SIngo Weinhold#
216338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
217338b8dc3SIngo Weinhold#
218338b8dc3SIngo Weinholdget_build_tool_path()
219338b8dc3SIngo Weinhold{
220338b8dc3SIngo Weinhold	local var="HAIKU_$1"
221338b8dc3SIngo Weinhold	local tool=$2
222338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
223338b8dc3SIngo Weinhold
224338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
225338b8dc3SIngo Weinhold		# get absolute path
226a559f87aSFrançois Revol		local oldPwd="`pwd`"
227a559f87aSFrançois Revol		cd "`dirname "$path"`"
228a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
229338b8dc3SIngo Weinhold		cd $oldPwd
230338b8dc3SIngo Weinhold	else
231338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
232338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
233338b8dc3SIngo Weinhold			exit 1
234338b8dc3SIngo Weinhold		}
235338b8dc3SIngo Weinhold	fi
236338b8dc3SIngo Weinhold
237338b8dc3SIngo Weinhold	eval "$var=$path"
238338b8dc3SIngo Weinhold}
239338b8dc3SIngo Weinhold
240338b8dc3SIngo Weinhold# get cwd and the source directory
241338b8dc3SIngo WeinholdcurrentDir=`pwd`
2426e7c6fe5SIngo Weinholdcd `dirname "$0"`
243338b8dc3SIngo WeinholdsourceDir=`pwd`
2446e7c6fe5SIngo Weinholdcd "$currentDir"
245338b8dc3SIngo Weinhold
246022fa244SIngo Weinhold# default parameter values
247022fa244SIngo Weinhold#
24852a38012Sejakowatzplatform=`uname`
2495abd9a46SIngo WeinholdplatformMachine=`uname  -m`
250338b8dc3SIngo WeinholdhaikuGCCVersion=
2510da9c208SIngo WeinholdhaikuGCCMachine=i586-pc-haiku
2528b5934c9SIngo WeinholdhaikuStaticLibStdCxx=
2538b5934c9SIngo WeinholdhaikuSharedLibStdCxx=
254c89fc875SIngo WeinholdhaikuStaticLibSupCxx=
255c89fc875SIngo WeinholdhaikuSharedLibSupCxx=
2568b5934c9SIngo WeinholdhaikuCxxHeadersDir=
257db63fe67SAxel DörflerhostGCCVersion=`gcc -dumpversion`
2585abd9a46SIngo WeinholdbochsDebug=0
2595abd9a46SIngo WeinholdincludeGPLAddOns=0
2605abd9a46SIngo Weinholdinclude3rdParty=0
2615abd9a46SIngo WeinholdenableMultiuser=0
262a66c32ddSIngo WeinholddistroCompatibility=default
26362339647SAxel Dörflertarget=haiku
26477e84f21SIngo WeinholdtargetArch=x86
2655abd9a46SIngo WeinholduseGCCPipe=0
2665abd9a46SIngo Weinholduse32bit=0
2675abd9a46SIngo WeinholduseXattr=0
268338b8dc3SIngo WeinholdcrossToolsPrefix=
269338b8dc3SIngo WeinholdbuildCrossTools=
27029ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
27120ab75e6SIngo WeinholdbuildCrossToolsMachine=
2729b0dd528SIngo WeinholdalternativeGCCOutputDir=
273292e63bfSIngo WeinholdaddAlternativeGCCLibs=
274338b8dc3SIngo Weinhold
27583d554a7SIngo WeinholdhaikuRequiredLegacyGCCVersion="2.95.3-haiku-081024"
276a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
277af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
278af4bf973SOliver Tappe
279338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
280338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
281338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
282338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
283338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
28477e84f21SIngo Weinholdset_default_value HAIKU_YASM		yasm
285338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
286338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
287338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
288338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
289338b8dc3SIngo Weinholdset_default_value HAIKU_ARFLAGS		ru
290338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
29162339647SAxel Dörfler
292022fa244SIngo Weinhold# parse parameters
293022fa244SIngo Weinhold#
29420ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
295022fa244SIngo Weinhold	case "$1" in
2965abd9a46SIngo Weinhold		--bochs-debug)	bochsDebug=1; shift 1;;
297a5b60fa8SOliver Tappe		--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
2989b0dd528SIngo Weinhold		--build-cross-tools-gcc4)
2999b0dd528SIngo Weinhold			assertparams "$1" 2 $#
3009b0dd528SIngo Weinhold			buildCrossTools=$3
3019b0dd528SIngo Weinhold			buildCrossToolsScript="${buildCrossToolsScript}_gcc4"
30220ab75e6SIngo Weinhold			case "$2" in
30320ab75e6SIngo Weinhold				x86)	haikuGCCMachine=i586-pc-haiku;;
30477e84f21SIngo Weinhold				ppc)	haikuGCCMachine=powerpc-apple-haiku; targetArch=ppc;;
30577e84f21SIngo Weinhold				m68k)	haikuGCCMachine=m68k-unknown-haiku; targetArch=m86k;;
30677e84f21SIngo Weinhold				arm)	haikuGCCMachine=arm-unknown-haiku; targetArch=arm;;
30777e84f21SIngo Weinhold				mipsel)	haikuGCCMachine=mipsel-unknown-haiku; targetArch=mips;;
30820ab75e6SIngo Weinhold				*)		echo "Unsupported target architecture: $2"
30920ab75e6SIngo Weinhold						exit 1;;
31020ab75e6SIngo Weinhold			esac
311a5b60fa8SOliver Tappe			buildCrossToolsMachine=$haikuGCCMachine
3129b0dd528SIngo Weinhold			shift 3
3139b0dd528SIngo Weinhold			;;
3149b0dd528SIngo Weinhold		--alternative-gcc-output-dir)
3159b0dd528SIngo Weinhold			assertparam "$1" $#
3169b0dd528SIngo Weinhold			cd $2 || exit 1
3179b0dd528SIngo Weinhold			alternativeGCCOutputDir=`pwd`
318292e63bfSIngo Weinhold			addAlternativeGCCLibs=1
3199b0dd528SIngo Weinhold			cd $currentDir
3209b0dd528SIngo Weinhold			shift 2
3219b0dd528SIngo Weinhold			;;
3229b0dd528SIngo Weinhold		--cross-tools-prefix)
3239b0dd528SIngo Weinhold			assertparam "$1" $#
3249b0dd528SIngo Weinhold			crossToolsPrefix=$2
3259b0dd528SIngo Weinhold			shift 2
3269b0dd528SIngo Weinhold			;;
327022fa244SIngo Weinhold		--help | -h)	usage; exit 0;;
3285abd9a46SIngo Weinhold		--include-gpl-addons)	includeGPLAddOns=1; shift 1;;
3295abd9a46SIngo Weinhold		--include-3rdparty)	include3rdParty=1; shift 1;;
3305abd9a46SIngo Weinhold		--enable-multiuser)	enableMultiuser=1; shift 1;;
331a66c32ddSIngo Weinhold		--distro-compatibility)
3329b0dd528SIngo Weinhold			assertparam "$1" $#
3339b0dd528SIngo Weinhold			distroCompatibility=$2
334a66c32ddSIngo Weinhold			case "$distroCompatibility" in
335a66c32ddSIngo Weinhold				official)	;;
336a66c32ddSIngo Weinhold				compatible)	;;
337a66c32ddSIngo Weinhold				default)	;;
338a66c32ddSIngo Weinhold				*)			echo "Invalid distro compatibility" \
339a66c32ddSIngo Weinhold								"level: $distroCompatibility"
340a66c32ddSIngo Weinhold							exit 1;;
341a66c32ddSIngo Weinhold			esac
3429b0dd528SIngo Weinhold			shift 2
3439b0dd528SIngo Weinhold			;;
344eccc7665SIngo Weinhold		--target=*)     target=`echo $1 | cut -d'=' -f2-`; shift 1;;
3455abd9a46SIngo Weinhold		--use-gcc-pipe)	useGCCPipe=1; shift 1;;
3465abd9a46SIngo Weinhold		--use-32bit)	use32bit=1; shift 1;;
3475abd9a46SIngo Weinhold		--use-xattr)	useXattr=1; shift 1;;
348022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
349022fa244SIngo Weinhold	esac
350022fa244SIngo Weinholddone
351022fa244SIngo Weinhold
3520df3cc9cSIngo Weinhold# detect the build platform
353338b8dc3SIngo Weinholdcase "${platform}" in
3540df3cc9cSIngo Weinhold	BeOS)	revision=`uname -r`
3550df3cc9cSIngo Weinhold			case "$revision" in
35614998c8bSIngo Weinhold				6.*)	buildPlatform=dano ;;
3570df3cc9cSIngo Weinhold				5.1)	buildPlatform=dano ;;
3580df3cc9cSIngo Weinhold				5.0.4)	buildPlatform=bone ;;
3590df3cc9cSIngo Weinhold				5.0*)	buildPlatform=r5 ;;
3600df3cc9cSIngo Weinhold				*)		echo Unknown BeOS version: $revision
3610df3cc9cSIngo Weinhold						exit 1 ;;
3620df3cc9cSIngo Weinhold			esac
3630df3cc9cSIngo Weinhold			;;
3646dcd0ccfSIngo Weinhold	Darwin)	buildPlatform=darwin ;;
365308c212cSIngo Weinhold	FreeBSD)	buildPlatform=freebsd
3665abd9a46SIngo Weinhold				if [ "$use32bit" = 1 ] ; then
3675abd9a46SIngo Weinhold					echo Unsupported platform: FreeBSD ${platformMachine}
368308c212cSIngo Weinhold					exit 1
369308c212cSIngo Weinhold				fi	;;
370da0f9ae0SIngo Weinhold	Haiku)	buildPlatform=haiku_host ;;
371da0f9ae0SIngo Weinhold	Linux)	buildPlatform=linux ;;
372ff1beff8SFrançois Revol	OpenBSD) buildPlatform=openbsd ;;
373a559f87aSFrançois Revol	SunOS)	buildPlatform=sunos ;;
374e688a433SMaurice Kalinowski	CYGWIN_NT-*) buildPlatform=cygwin ;;
375338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
3764cbe4925SAxel Dörfler			exit 1 ;;
3774cbe4925SAxel Dörfleresac
37852a38012Sejakowatz
37977e84f21SIngo Weinhold# check yasm version
38077e84f21SIngo Weinholdif [ $targetArch = "x86" ]; then
38177e84f21SIngo Weinhold	$HAIKU_YASM --version > /dev/null || {
38292696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
38377e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
38477e84f21SIngo Weinhold		exit 1
38577e84f21SIngo Weinhold	}
38677e84f21SIngo Weinhold
38777e84f21SIngo Weinhold	set -- $($HAIKU_YASM --version | head -n 1)
38877e84f21SIngo Weinhold	versionOK=0
38977e84f21SIngo Weinhold	case $2 in
39092696166SIngo Weinhold		0.[0-6].*)		;;
39177e84f21SIngo Weinhold		*)				versionOK=1 ;;
39277e84f21SIngo Weinhold	esac
39377e84f21SIngo Weinhold
39477e84f21SIngo Weinhold	if [ $versionOK = 0 ]; then
39592696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
39677e84f21SIngo Weinhold		echo "The installed version is $2."
39777e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
39877e84f21SIngo Weinhold		exit 1
39977e84f21SIngo Weinhold	fi
40077e84f21SIngo Weinholdfi
40177e84f21SIngo Weinhold
402*3ecc5287SMichael Lotz# check for case-sensitive filesystem if on darwin
403*3ecc5287SMichael Lotzif [ $buildPlatform = "darwin" ]; then
404*3ecc5287SMichael Lotz	diskutil info . | grep -i "case-sensitive" > /dev/null
405*3ecc5287SMichael Lotz	if [ $? != 0 ]; then
406*3ecc5287SMichael Lotz		echo "You need a case-sensitive file-system to build Haiku."
407*3ecc5287SMichael Lotz		echo "Please see the following guide on how to set one up:"
408*3ecc5287SMichael Lotz		echo "http://haiku-os.org/documents/dev/how_to_build_haiku_on_mac_os_x"
409*3ecc5287SMichael Lotz		exit 1
410*3ecc5287SMichael Lotz	fi
411*3ecc5287SMichael Lotzfi
412*3ecc5287SMichael Lotz
413338b8dc3SIngo Weinhold# create output directory
414338b8dc3SIngo Weinholdif [ "$currentDir" = "$sourceDir" ]; then
415338b8dc3SIngo Weinhold	outputDir=$currentDir/generated
416338b8dc3SIngo Weinholdelse
417338b8dc3SIngo Weinhold	outputDir=$currentDir
418338b8dc3SIngo Weinholdfi
4196e7c6fe5SIngo WeinholdbuildOutputDir="$outputDir/build"
4206e7c6fe5SIngo WeinholdbuildAttributesDir="$outputDir/attributes"
4216e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1
422338b8dc3SIngo Weinhold
423338b8dc3SIngo Weinhold# build cross tools from sources
424338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then
42520ab75e6SIngo Weinhold	"$buildCrossToolsScript" $buildCrossToolsMachine "$sourceDir" \
4266e7c6fe5SIngo Weinhold		"$buildCrossTools" "$outputDir" || exit 1
427a5b60fa8SOliver Tappe	crossToolsPrefix="$outputDir/cross-tools/bin/${haikuGCCMachine}-"
428338b8dc3SIngo Weinholdfi
429338b8dc3SIngo Weinhold
430338b8dc3SIngo Weinhold# cross tools
431338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then
432338b8dc3SIngo Weinhold	get_build_tool_path AR ar
433338b8dc3SIngo Weinhold	get_build_tool_path CC gcc
434338b8dc3SIngo Weinhold	get_build_tool_path LD ld
435338b8dc3SIngo Weinhold	get_build_tool_path OBJCOPY objcopy
436338b8dc3SIngo Weinhold	get_build_tool_path RANLIB ranlib
437338b8dc3SIngo Weinholdfi
438338b8dc3SIngo Weinhold
439338b8dc3SIngo Weinhold# prepare gcc settings
440338b8dc3SIngo Weinholdstandard_gcc_settings
441338b8dc3SIngo Weinhold
442eedc3d0bSIngo Weinhold# check whether the Haiku compiler really targets Haiku or BeOS
443eedc3d0bSIngo Weinholdcase "$haikuGCCMachine" in
444eedc3d0bSIngo Weinhold	*-*-haiku)	;;
445eedc3d0bSIngo Weinhold	*-*-beos)	;;
446eedc3d0bSIngo Weinhold	*) echo The compiler specified as Haiku target compiler is not a valid \
447eedc3d0bSIngo Weinhold			Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
448eedc3d0bSIngo Weinhold	   echo compiler: $HAIKU_CC
449eedc3d0bSIngo Weinhold	   echo compiler is configured for target: $haikuGCCMachine
450eedc3d0bSIngo Weinhold	   exit 1 ;;
451eedc3d0bSIngo Weinholdesac
452eedc3d0bSIngo Weinhold
45352a38012Sejakowatz# Generate BuildConfig
4546e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/BuildConfig"
45552a38012Sejakowatz# BuildConfig
45652a38012Sejakowatz# Note: This file has been automatically generated by configure.
45752a38012Sejakowatz
4586e7c6fe5SIngo WeinholdTARGET_PLATFORM 			?= "${target}" ;
4596e7c6fe5SIngo WeinholdHOST_PLATFORM				?= "${buildPlatform}" ;
460338b8dc3SIngo Weinhold
4615abd9a46SIngo WeinholdBOCHS_DEBUG_HACK					?= "${bochsDebug}" ;
4625abd9a46SIngo WeinholdINCLUDE_GPL_ADDONS					?= "${includeGPLAddOns}" ;
4635abd9a46SIngo WeinholdHAIKU_INCLUDE_3RDPARTY				?= "${include3rdParty}" ;
4645abd9a46SIngo WeinholdHAIKU_ENABLE_MULTIUSER				?= "${enableMultiuser}" ;
465a66c32ddSIngo WeinholdHAIKU_DISTRO_COMPATIBILITY			?= "${distroCompatibility}" ;
4665abd9a46SIngo WeinholdHAIKU_USE_GCC_PIPE					?= "${useGCCPipe}" ;
4675abd9a46SIngo WeinholdHAIKU_HOST_USE_32BIT				?= "${use32bit}" ;
4685abd9a46SIngo WeinholdHAIKU_HOST_USE_XATTR				?= "${useXattr}" ;
4699b0dd528SIngo WeinholdHAIKU_ALTERNATIVE_GCC_OUTPUT_DIR	?= ${alternativeGCCOutputDir} ;
470292e63bfSIngo WeinholdHAIKU_ADD_ALTERNATIVE_GCC_LIBS		?= ${addAlternativeGCCLibs} ;
471eccc7665SIngo Weinhold
472338b8dc3SIngo WeinholdHAIKU_GCC_RAW_VERSION		?= ${haikuGCCVersion} ;
473338b8dc3SIngo WeinholdHAIKU_GCC_MACHINE			?= ${haikuGCCMachine} ;
474338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR			?= ${HAIKU_GCC_LIB_DIR} ;
475338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR		?= ${HAIKU_GCC_HEADERS_DIR} ;
476338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC			?= ${HAIKU_GCC_LIBGCC} ;
477338b8dc3SIngo Weinhold
4788b5934c9SIngo WeinholdHAIKU_STATIC_LIBSTDC++		?= ${haikuStaticLibStdCxx} ;
4798b5934c9SIngo WeinholdHAIKU_SHARED_LIBSTDC++		?= ${haikuSharedLibStdCxx} ;
480c89fc875SIngo WeinholdHAIKU_STATIC_LIBSUPC++		?= ${haikuStaticLibSupCxx} ;
481c89fc875SIngo WeinholdHAIKU_SHARED_LIBSUPC++		?= ${haikuSharedLibSupCxx} ;
4828b5934c9SIngo WeinholdHAIKU_C++_HEADERS_DIR		?= ${haikuCxxHeadersDir} ;
4838b5934c9SIngo Weinhold
484338b8dc3SIngo WeinholdHAIKU_BUILD_ATTRIBUTES_DIR	?= ${buildAttributesDir} ;
485338b8dc3SIngo Weinhold
486338b8dc3SIngo WeinholdHAIKU_AR					?= ${HAIKU_AR} ;
487338b8dc3SIngo WeinholdHAIKU_CC					?= ${HAIKU_CC} ;
488338b8dc3SIngo WeinholdHAIKU_LD					?= ${HAIKU_LD} ;
489338b8dc3SIngo WeinholdHAIKU_OBJCOPY				?= ${HAIKU_OBJCOPY} ;
490338b8dc3SIngo WeinholdHAIKU_RANLIB				?= ${HAIKU_RANLIB} ;
49177e84f21SIngo WeinholdHAIKU_YASM					?= ${HAIKU_YASM} ;
492338b8dc3SIngo WeinholdHAIKU_CPPFLAGS				?= ${HAIKU_CPPFLAGS} ;
493338b8dc3SIngo WeinholdHAIKU_CCFLAGS				?= ${HAIKU_CCFLAGS} ;
494338b8dc3SIngo WeinholdHAIKU_CXXFLAGS				?= ${HAIKU_CXXFLAGS} ;
495338b8dc3SIngo WeinholdHAIKU_LDFLAGS				?= ${HAIKU_LDFLAGS} ;
496338b8dc3SIngo WeinholdHAIKU_ARFLAGS				?= ${HAIKU_ARFLAGS} ;
497338b8dc3SIngo WeinholdHAIKU_UNARFLAGS				?= ${HAIKU_UNARFLAGS} ;
498338b8dc3SIngo Weinhold
4998b5934c9SIngo WeinholdHOST_GCC_RAW_VERSION		?= ${hostGCCVersion} ;
5008b5934c9SIngo Weinhold
501c4786ea6SlilloEOF
502c4786ea6Slillo
503b1e5b60cSAxel Dörfler# Libgcc.a objects
504b1e5b60cSAxel Dörfler
5056e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/libgccObjects"
506b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
507b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
508b1e5b60cSAxel Dörfler
509338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
510b1e5b60cSAxel DörflerEOF
511b1e5b60cSAxel Dörfler
5124c74bde8SJérôme Duval# Generate Timezones binaries bindings
5134c74bde8SJérôme Duval
514338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
515338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
516338b8dc3SIngo Weinhold
5176e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/Timezones"
518b1e5b60cSAxel Dörfler# Timezones used for the build
519b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
520b1e5b60cSAxel Dörfler
521338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
522338b8dc3SIngo Weinhold
523b1e5b60cSAxel DörflerEOF
524b1e5b60cSAxel Dörfler
525338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
526338b8dc3SIngo Weinhold	f=$sourceDir/src/data/etc/timezones/$source
5274c74bde8SJérôme Duval
5286e7c6fe5SIngo WeinholdTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' "$f" `
5294c74bde8SJérôme Duval
5306e7c6fe5SIngo Weinholdcat << EOF >> "$buildOutputDir/Timezones"
531338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
5324c74bde8SJérôme DuvalEOF
5334c74bde8SJérôme Duvaldone
534338b8dc3SIngo Weinhold
5359b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
536338b8dc3SIngo Weinhold
537338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
538338b8dc3SIngo Weinhold# automatically generated Jamfile
539338b8dc3SIngo Weinhold
540338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
541338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
542338b8dc3SIngo Weinhold
543338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
544338b8dc3SIngo Weinhold
545338b8dc3SIngo WeinholdEOF
546