xref: /haiku/configure (revision 5abd9a464d1cdf6e65aaa532ba15df6c2af12c1c)
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
2920ab75e6SIngo Weinhold                              "x86" or "ppc".
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.
37eccc7665SIngo Weinhold  --cross-tools-prefix <prefix>
38eccc7665SIngo Weinhold                              Assume cross compilation. <prefix> should be a
39eccc7665SIngo Weinhold                              path to the directory where the cross
40eccc7665SIngo Weinhold                              compilation tools are located, plus the platform
410da9c208SIngo Weinhold                              prefix, e.g. "/path/to/tools/i586-pc-haiku-".
42eccc7665SIngo Weinhold                              This overrides the HAIKU_* tool variables.
43a66c32ddSIngo Weinhold  --distro-compatibility <level>
44a66c32ddSIngo Weinhold                              The distribution's level of compatibility with
45a66c32ddSIngo Weinhold                              the official Haiku distribution. The generated
46a66c32ddSIngo Weinhold                              files will contain the respective trademarks
47a66c32ddSIngo Weinhold                              accordingly.
48a66c32ddSIngo Weinhold                              official -- the official Haiku distribution.
49a66c32ddSIngo Weinhold                              compatible -- a Haiku Compatible (tm) distro.
50a66c32ddSIngo Weinhold                              default -- any other distro (default value).
51eccc7665SIngo Weinhold  --help                      Prints out this help.
52eccc7665SIngo Weinhold  --include-gpl-addons        Include GPL licensed add-ons.
531974210fSFrançois Revol  --include-3rdparty          Include 3rdparty/ in the build system.
54f1b9c086SFrançois Revol  --enable-multiuser          Enable experimental multiuser support.
55614026d7Sshatty  --target=TARGET             Select build target platform. [default=${target}]
56a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
57eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
585a34a443SFrançois Revol                              process, but uses more memory.
590385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
604f4e5272SIngo Weinhold  --use-xattr                 Use Linux xattr support for BeOS attribute
614f4e5272SIngo Weinhold                              emulation. Warning: Make sure your file system
624f4e5272SIngo Weinhold                              supports sufficient attribute sizes (4 KB per
634f4e5272SIngo Weinhold                              file for all attributes won't suffice).
64338b8dc3SIngo Weinhold
65338b8dc3SIngo Weinholdenvironment variables:
66338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
67338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
68338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
69338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
70338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
71338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
72338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
73338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
74338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
75338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
76338b8dc3SIngo Weinhold                              Defaults to "ru".
77338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
78338b8dc3SIngo Weinhold                              Defaults to "x".
7964f6da31SIngo Weinhold
8064f6da31SIngo WeinholdNon-standard output directories:
8164f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
8264f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
8364f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
8464f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
8564f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
8664f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
8764f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
8864f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
8964f6da31SIngo Weinhold  non-default location and running jam.
9064f6da31SIngo Weinhold
9164f6da31SIngo Weinhold
92022fa244SIngo WeinholdEOF
93022fa244SIngo Weinhold}
94022fa244SIngo Weinhold
95022fa244SIngo Weinhold# assertparam
96022fa244SIngo Weinhold#
97022fa244SIngo Weinhold# Checks whether at least one parameter is left.
98022fa244SIngo Weinhold#
99022fa244SIngo Weinholdassertparam()
100022fa244SIngo Weinhold{
10120ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
102022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
103022fa244SIngo Weinhold		exit 1
104022fa244SIngo Weinhold	fi
105022fa244SIngo Weinhold}
106022fa244SIngo Weinhold
10720ab75e6SIngo Weinhold# assertparams
10820ab75e6SIngo Weinhold#
10920ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
11020ab75e6SIngo Weinhold#
11120ab75e6SIngo Weinholdassertparams()
11220ab75e6SIngo Weinhold{
11320ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
11420ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
11520ab75e6SIngo Weinhold		exit 1
11620ab75e6SIngo Weinhold	fi
11720ab75e6SIngo Weinhold}
11820ab75e6SIngo Weinhold
11909c5682dSIngo Weinhold# standard_gcc_settings
12009c5682dSIngo Weinhold#
12109c5682dSIngo Weinhold# Sets the variables for a GCC platform.
12209c5682dSIngo Weinhold#
12309c5682dSIngo Weinholdstandard_gcc_settings()
12409c5682dSIngo Weinhold{
12509c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
126338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
12709c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
1285b0f7b1bSOliver Tappe
129338b8dc3SIngo Weinhold	haikuGCCVersion=`$HAIKU_CC -dumpversion`
130338b8dc3SIngo Weinhold	haikuGCCMachine=`$HAIKU_CC -dumpmachine`
131338b8dc3SIngo Weinhold
132338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
133338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
134338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
13528b5bc75SMichael Lotz	HAIKU_GCC_HEADERS_DIR="${gccdir}/include
13628b5bc75SMichael Lotz		${gccdir}/include-fixed"
1375d978968SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`$HAIKU_AR t ${HAIKU_GCC_LIBGCC} | grep -v eabi.o`
1385d978968SIngo Weinhold		# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC and
1395d978968SIngo Weinhold		# neither needed nor wanted.
1408b5934c9SIngo Weinhold
1418b5934c9SIngo Weinhold	case $haikuGCCVersion in
1428b5934c9SIngo Weinhold		4.*)
1435b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
1445b0f7b1bSOliver Tappe			# compiler
1458b5934c9SIngo Weinhold			haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
1468b5934c9SIngo Weinhold			haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
147c89fc875SIngo Weinhold			haikuStaticLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.a`
148c89fc875SIngo Weinhold			haikuSharedLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.so`
14914210488SMichael Lotz
15014210488SMichael Lotz			local headers
15114210488SMichael Lotz			if [ -d $gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion ]; then
15214210488SMichael Lotz				headers=$gccdir/../../../../$haikuGCCMachine/include/c++/$haikuGCCVersion
15314210488SMichael Lotz			else
15414210488SMichael Lotz				headers=$gccdir/../../../../include/c++/$haikuGCCVersion
15514210488SMichael Lotz			fi
15614210488SMichael Lotz
1578b5934c9SIngo Weinhold			haikuCxxHeadersDir=$headers
15829ef597dSIngo Weinhold			for d in $haikuGCCMachine backward ext; do
15929ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
16029ef597dSIngo Weinhold				# too long for jam (512 bytes max).
16129ef597dSIngo Weinhold				haikuCxxHeadersDir="$haikuCxxHeadersDir
16229ef597dSIngo Weinhold					$headers/$d"
1638b5934c9SIngo Weinhold			done
164274b450aSMarcus Overhagen
165dad36002SMarcus Overhagen
166dad36002SMarcus Overhagen			# when not building the crosscompiler, to use cpp headers from
167274b450aSMarcus Overhagen			# tree first, but fallback to local C++ system headers (like <new>)
168dad36002SMarcus Overhagen			# if [ "$buildCrossTools" = "" ]; then
169dad36002SMarcus Overhagen			#	haikuCxxHeadersDir="headers/cpp $haikuCxxHeadersDir"
170dad36002SMarcus Overhagen			# fi
1718b5934c9SIngo Weinhold
1728b5934c9SIngo Weinhold			if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
1738b5934c9SIngo Weinhold				haikuStaticLibStdCxx=
1748b5934c9SIngo Weinhold			fi
1758b5934c9SIngo Weinhold			if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
1768b5934c9SIngo Weinhold				haikuSharedLibStdCxx=
1778b5934c9SIngo Weinhold			fi
178c89fc875SIngo Weinhold			if [ $haikuStaticLibSupCxx = libsupc++.a ]; then
179c89fc875SIngo Weinhold				haikuStaticLibSupCxx=
180c89fc875SIngo Weinhold			fi
181c89fc875SIngo Weinhold			if [ $haikuSharedLibSupCxx = libsupc++.so ]; then
182c89fc875SIngo Weinhold				haikuSharedLibSupCxx=
183c89fc875SIngo Weinhold			fi
1848b5934c9SIngo Weinhold		;;
1856cc8eecfSOliver Tappe		2.9*)
1865b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
1875b0f7b1bSOliver Tappe			# if an older one is installed
1885b0f7b1bSOliver Tappe			if [ $haikuGCCVersion != $haikuRequiredLegacyGCCVersion ]; then
1895b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
1905b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
1915b0f7b1bSOliver Tappe				exit 1;
1925b0f7b1bSOliver Tappe			fi
1935b0f7b1bSOliver Tappe		;;
1948b5934c9SIngo Weinhold	esac
19509c5682dSIngo Weinhold}
19609c5682dSIngo Weinhold
197338b8dc3SIngo Weinhold# set_default_value
198338b8dc3SIngo Weinhold#
199338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
200338b8dc3SIngo Weinhold#
201338b8dc3SIngo Weinholdset_default_value()
202338b8dc3SIngo Weinhold{
2030838a930SJérôme Duval	eval "$1=\${$1-$2}"
204338b8dc3SIngo Weinhold}
205338b8dc3SIngo Weinhold
206338b8dc3SIngo Weinhold# get_build_tool_path
207338b8dc3SIngo Weinhold#
208338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
209338b8dc3SIngo Weinhold#
210338b8dc3SIngo Weinholdget_build_tool_path()
211338b8dc3SIngo Weinhold{
212338b8dc3SIngo Weinhold	local var="HAIKU_$1"
213338b8dc3SIngo Weinhold	local tool=$2
214338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
215338b8dc3SIngo Weinhold
216338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
217338b8dc3SIngo Weinhold		# get absolute path
218a559f87aSFrançois Revol		local oldPwd="`pwd`"
219a559f87aSFrançois Revol		cd "`dirname "$path"`"
220a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
221338b8dc3SIngo Weinhold		cd $oldPwd
222338b8dc3SIngo Weinhold	else
223338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
224338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
225338b8dc3SIngo Weinhold			exit 1
226338b8dc3SIngo Weinhold		}
227338b8dc3SIngo Weinhold	fi
228338b8dc3SIngo Weinhold
229338b8dc3SIngo Weinhold	eval "$var=$path"
230338b8dc3SIngo Weinhold}
231338b8dc3SIngo Weinhold
232338b8dc3SIngo Weinhold# get cwd and the source directory
233338b8dc3SIngo WeinholdcurrentDir=`pwd`
2346e7c6fe5SIngo Weinholdcd `dirname "$0"`
235338b8dc3SIngo WeinholdsourceDir=`pwd`
2366e7c6fe5SIngo Weinholdcd "$currentDir"
237338b8dc3SIngo Weinhold
238022fa244SIngo Weinhold# default parameter values
239022fa244SIngo Weinhold#
24052a38012Sejakowatzplatform=`uname`
241*5abd9a46SIngo WeinholdplatformMachine=`uname  -m`
242338b8dc3SIngo WeinholdhaikuGCCVersion=
2430da9c208SIngo WeinholdhaikuGCCMachine=i586-pc-haiku
2448b5934c9SIngo WeinholdhaikuStaticLibStdCxx=
2458b5934c9SIngo WeinholdhaikuSharedLibStdCxx=
246c89fc875SIngo WeinholdhaikuStaticLibSupCxx=
247c89fc875SIngo WeinholdhaikuSharedLibSupCxx=
2488b5934c9SIngo WeinholdhaikuCxxHeadersDir=
249db63fe67SAxel DörflerhostGCCVersion=`gcc -dumpversion`
250*5abd9a46SIngo WeinholdbochsDebug=0
251*5abd9a46SIngo WeinholdincludeGPLAddOns=0
252*5abd9a46SIngo Weinholdinclude3rdParty=0
253*5abd9a46SIngo WeinholdenableMultiuser=0
254a66c32ddSIngo WeinholddistroCompatibility=default
25562339647SAxel Dörflertarget=haiku
256*5abd9a46SIngo WeinholduseGCCPipe=0
257*5abd9a46SIngo Weinholduse32bit=0
258*5abd9a46SIngo WeinholduseXattr=0
259338b8dc3SIngo WeinholdcrossToolsPrefix=
260338b8dc3SIngo WeinholdbuildCrossTools=
26129ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
26220ab75e6SIngo WeinholdbuildCrossToolsMachine=
2639b0dd528SIngo WeinholdalternativeGCCOutputDir=
264338b8dc3SIngo Weinhold
26583d554a7SIngo WeinholdhaikuRequiredLegacyGCCVersion="2.95.3-haiku-081024"
266a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
267af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
268af4bf973SOliver Tappe
269338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
270338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
271338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
272338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
273338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
274338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
275338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
276338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
277338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
278338b8dc3SIngo Weinholdset_default_value HAIKU_ARFLAGS		ru
279338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
28062339647SAxel Dörfler
281022fa244SIngo Weinhold# parse parameters
282022fa244SIngo Weinhold#
28320ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
284022fa244SIngo Weinhold	case "$1" in
285*5abd9a46SIngo Weinhold		--bochs-debug)	bochsDebug=1; shift 1;;
286a5b60fa8SOliver Tappe		--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
2879b0dd528SIngo Weinhold		--build-cross-tools-gcc4)
2889b0dd528SIngo Weinhold			assertparams "$1" 2 $#
2899b0dd528SIngo Weinhold			buildCrossTools=$3
2909b0dd528SIngo Weinhold			buildCrossToolsScript="${buildCrossToolsScript}_gcc4"
29120ab75e6SIngo Weinhold			case "$2" in
29220ab75e6SIngo Weinhold				x86)	haikuGCCMachine=i586-pc-haiku;;
29320ab75e6SIngo Weinhold				ppc)	haikuGCCMachine=powerpc-apple-haiku;;
2948074e217SFrançois Revol				m68k)	haikuGCCMachine=m68k-unknown-haiku;;
2954a9f6b4aSMichael Lotz				arm)	haikuGCCMachine=arm-unknown-haiku;;
29620ab75e6SIngo Weinhold				*)		echo "Unsupported target architecture: $2"
29720ab75e6SIngo Weinhold						exit 1;;
29820ab75e6SIngo Weinhold			esac
299a5b60fa8SOliver Tappe			buildCrossToolsMachine=$haikuGCCMachine
3009b0dd528SIngo Weinhold			shift 3
3019b0dd528SIngo Weinhold			;;
3029b0dd528SIngo Weinhold		--alternative-gcc-output-dir)
3039b0dd528SIngo Weinhold			assertparam "$1" $#
3049b0dd528SIngo Weinhold			cd $2 || exit 1
3059b0dd528SIngo Weinhold			alternativeGCCOutputDir=`pwd`
3069b0dd528SIngo Weinhold			cd $currentDir
3079b0dd528SIngo Weinhold			shift 2
3089b0dd528SIngo Weinhold			;;
3099b0dd528SIngo Weinhold		--cross-tools-prefix)
3109b0dd528SIngo Weinhold			assertparam "$1" $#
3119b0dd528SIngo Weinhold			crossToolsPrefix=$2
3129b0dd528SIngo Weinhold			shift 2
3139b0dd528SIngo Weinhold			;;
314022fa244SIngo Weinhold		--help | -h)	usage; exit 0;;
315*5abd9a46SIngo Weinhold		--include-gpl-addons)	includeGPLAddOns=1; shift 1;;
316*5abd9a46SIngo Weinhold		--include-3rdparty)	include3rdParty=1; shift 1;;
317*5abd9a46SIngo Weinhold		--enable-multiuser)	enableMultiuser=1; shift 1;;
318a66c32ddSIngo Weinhold		--distro-compatibility)
3199b0dd528SIngo Weinhold			assertparam "$1" $#
3209b0dd528SIngo Weinhold			distroCompatibility=$2
321a66c32ddSIngo Weinhold			case "$distroCompatibility" in
322a66c32ddSIngo Weinhold				official)	;;
323a66c32ddSIngo Weinhold				compatible)	;;
324a66c32ddSIngo Weinhold				default)	;;
325a66c32ddSIngo Weinhold				*)			echo "Invalid distro compatibility" \
326a66c32ddSIngo Weinhold								"level: $distroCompatibility"
327a66c32ddSIngo Weinhold							exit 1;;
328a66c32ddSIngo Weinhold			esac
3299b0dd528SIngo Weinhold			shift 2
3309b0dd528SIngo Weinhold			;;
331eccc7665SIngo Weinhold		--target=*)     target=`echo $1 | cut -d'=' -f2-`; shift 1;;
332*5abd9a46SIngo Weinhold		--use-gcc-pipe)	useGCCPipe=1; shift 1;;
333*5abd9a46SIngo Weinhold		--use-32bit)	use32bit=1; shift 1;;
334*5abd9a46SIngo Weinhold		--use-xattr)	useXattr=1; shift 1;;
335022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
336022fa244SIngo Weinhold	esac
337022fa244SIngo Weinholddone
338022fa244SIngo Weinhold
339308c212cSIngo Weinhold# check for a 64bit platform
340*5abd9a46SIngo Weinholdcase "${platformMachine}" in
341*5abd9a46SIngo Weinhold	x86_64)	use32bit=1 ;;
342*5abd9a46SIngo Weinhold	*)	echo Assuming 32-bit machine: "$platformMachine"
343*5abd9a46SIngo Weinhold		use32bit=0 ;;
344308c212cSIngo Weinholdesac
345308c212cSIngo Weinhold
3460df3cc9cSIngo Weinhold# detect the build platform
347338b8dc3SIngo Weinholdcase "${platform}" in
3480df3cc9cSIngo Weinhold	BeOS)	revision=`uname -r`
3490df3cc9cSIngo Weinhold			case "$revision" in
35014998c8bSIngo Weinhold				6.*)	buildPlatform=dano ;;
3510df3cc9cSIngo Weinhold				5.1)	buildPlatform=dano ;;
3520df3cc9cSIngo Weinhold				5.0.4)	buildPlatform=bone ;;
3530df3cc9cSIngo Weinhold				5.0*)	buildPlatform=r5 ;;
3540df3cc9cSIngo Weinhold				*)		echo Unknown BeOS version: $revision
3550df3cc9cSIngo Weinhold						exit 1 ;;
3560df3cc9cSIngo Weinhold			esac
3570df3cc9cSIngo Weinhold			;;
3586dcd0ccfSIngo Weinhold	Darwin)	buildPlatform=darwin ;;
359308c212cSIngo Weinhold	FreeBSD)	buildPlatform=freebsd
360*5abd9a46SIngo Weinhold				if [ "$use32bit" = 1 ] ; then
361*5abd9a46SIngo Weinhold					echo Unsupported platform: FreeBSD ${platformMachine}
362308c212cSIngo Weinhold					exit 1
363308c212cSIngo Weinhold				fi	;;
364da0f9ae0SIngo Weinhold	Haiku)	buildPlatform=haiku_host ;;
365da0f9ae0SIngo Weinhold	Linux)	buildPlatform=linux ;;
366ff1beff8SFrançois Revol	OpenBSD) buildPlatform=openbsd ;;
367a559f87aSFrançois Revol	SunOS)	buildPlatform=sunos ;;
368e688a433SMaurice Kalinowski	CYGWIN_NT-*) buildPlatform=cygwin ;;
369338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
3704cbe4925SAxel Dörfler			exit 1 ;;
3714cbe4925SAxel Dörfleresac
37252a38012Sejakowatz
373338b8dc3SIngo Weinhold# create output directory
374338b8dc3SIngo Weinholdif [ "$currentDir" = "$sourceDir" ]; then
375338b8dc3SIngo Weinhold	outputDir=$currentDir/generated
376338b8dc3SIngo Weinholdelse
377338b8dc3SIngo Weinhold	outputDir=$currentDir
378338b8dc3SIngo Weinholdfi
3796e7c6fe5SIngo WeinholdbuildOutputDir="$outputDir/build"
3806e7c6fe5SIngo WeinholdbuildAttributesDir="$outputDir/attributes"
3816e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1
382338b8dc3SIngo Weinhold
383338b8dc3SIngo Weinhold# build cross tools from sources
384338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then
38520ab75e6SIngo Weinhold	"$buildCrossToolsScript" $buildCrossToolsMachine "$sourceDir" \
3866e7c6fe5SIngo Weinhold		"$buildCrossTools" "$outputDir" || exit 1
387a5b60fa8SOliver Tappe	crossToolsPrefix="$outputDir/cross-tools/bin/${haikuGCCMachine}-"
388338b8dc3SIngo Weinholdfi
389338b8dc3SIngo Weinhold
390338b8dc3SIngo Weinhold# cross tools
391338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then
392338b8dc3SIngo Weinhold	get_build_tool_path AR ar
393338b8dc3SIngo Weinhold	get_build_tool_path CC gcc
394338b8dc3SIngo Weinhold	get_build_tool_path LD ld
395338b8dc3SIngo Weinhold	get_build_tool_path OBJCOPY objcopy
396338b8dc3SIngo Weinhold	get_build_tool_path RANLIB ranlib
397338b8dc3SIngo Weinholdfi
398338b8dc3SIngo Weinhold
399338b8dc3SIngo Weinhold# prepare gcc settings
400338b8dc3SIngo Weinholdstandard_gcc_settings
401338b8dc3SIngo Weinhold
402eedc3d0bSIngo Weinhold# check whether the Haiku compiler really targets Haiku or BeOS
403eedc3d0bSIngo Weinholdcase "$haikuGCCMachine" in
404eedc3d0bSIngo Weinhold	*-*-haiku)	;;
405eedc3d0bSIngo Weinhold	*-*-beos)	;;
406eedc3d0bSIngo Weinhold	*) echo The compiler specified as Haiku target compiler is not a valid \
407eedc3d0bSIngo Weinhold			Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
408eedc3d0bSIngo Weinhold	   echo compiler: $HAIKU_CC
409eedc3d0bSIngo Weinhold	   echo compiler is configured for target: $haikuGCCMachine
410eedc3d0bSIngo Weinhold	   exit 1 ;;
411eedc3d0bSIngo Weinholdesac
412eedc3d0bSIngo Weinhold
41352a38012Sejakowatz# Generate BuildConfig
4146e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/BuildConfig"
41552a38012Sejakowatz# BuildConfig
41652a38012Sejakowatz# Note: This file has been automatically generated by configure.
41752a38012Sejakowatz
4186e7c6fe5SIngo WeinholdTARGET_PLATFORM 			?= "${target}" ;
4196e7c6fe5SIngo WeinholdHOST_PLATFORM				?= "${buildPlatform}" ;
420338b8dc3SIngo Weinhold
421*5abd9a46SIngo WeinholdBOCHS_DEBUG_HACK					?= "${bochsDebug}" ;
422*5abd9a46SIngo WeinholdINCLUDE_GPL_ADDONS					?= "${includeGPLAddOns}" ;
423*5abd9a46SIngo WeinholdHAIKU_INCLUDE_3RDPARTY				?= "${include3rdParty}" ;
424*5abd9a46SIngo WeinholdHAIKU_ENABLE_MULTIUSER				?= "${enableMultiuser}" ;
425a66c32ddSIngo WeinholdHAIKU_DISTRO_COMPATIBILITY			?= "${distroCompatibility}" ;
426*5abd9a46SIngo WeinholdHAIKU_USE_GCC_PIPE					?= "${useGCCPipe}" ;
427*5abd9a46SIngo WeinholdHAIKU_HOST_USE_32BIT				?= "${use32bit}" ;
428*5abd9a46SIngo WeinholdHAIKU_HOST_USE_XATTR				?= "${useXattr}" ;
4299b0dd528SIngo WeinholdHAIKU_ALTERNATIVE_GCC_OUTPUT_DIR	?= ${alternativeGCCOutputDir} ;
430eccc7665SIngo Weinhold
431338b8dc3SIngo WeinholdHAIKU_GCC_RAW_VERSION		?= ${haikuGCCVersion} ;
432338b8dc3SIngo WeinholdHAIKU_GCC_MACHINE			?= ${haikuGCCMachine} ;
433338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR			?= ${HAIKU_GCC_LIB_DIR} ;
434338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR		?= ${HAIKU_GCC_HEADERS_DIR} ;
435338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC			?= ${HAIKU_GCC_LIBGCC} ;
436338b8dc3SIngo Weinhold
4378b5934c9SIngo WeinholdHAIKU_STATIC_LIBSTDC++		?= ${haikuStaticLibStdCxx} ;
4388b5934c9SIngo WeinholdHAIKU_SHARED_LIBSTDC++		?= ${haikuSharedLibStdCxx} ;
439c89fc875SIngo WeinholdHAIKU_STATIC_LIBSUPC++		?= ${haikuStaticLibSupCxx} ;
440c89fc875SIngo WeinholdHAIKU_SHARED_LIBSUPC++		?= ${haikuSharedLibSupCxx} ;
4418b5934c9SIngo WeinholdHAIKU_C++_HEADERS_DIR		?= ${haikuCxxHeadersDir} ;
4428b5934c9SIngo Weinhold
443338b8dc3SIngo WeinholdHAIKU_BUILD_ATTRIBUTES_DIR	?= ${buildAttributesDir} ;
444338b8dc3SIngo Weinhold
445338b8dc3SIngo WeinholdHAIKU_AR					?= ${HAIKU_AR} ;
446338b8dc3SIngo WeinholdHAIKU_CC					?= ${HAIKU_CC} ;
447338b8dc3SIngo WeinholdHAIKU_LD					?= ${HAIKU_LD} ;
448338b8dc3SIngo WeinholdHAIKU_OBJCOPY				?= ${HAIKU_OBJCOPY} ;
449338b8dc3SIngo WeinholdHAIKU_RANLIB				?= ${HAIKU_RANLIB} ;
450338b8dc3SIngo WeinholdHAIKU_CPPFLAGS				?= ${HAIKU_CPPFLAGS} ;
451338b8dc3SIngo WeinholdHAIKU_CCFLAGS				?= ${HAIKU_CCFLAGS} ;
452338b8dc3SIngo WeinholdHAIKU_CXXFLAGS				?= ${HAIKU_CXXFLAGS} ;
453338b8dc3SIngo WeinholdHAIKU_LDFLAGS				?= ${HAIKU_LDFLAGS} ;
454338b8dc3SIngo WeinholdHAIKU_ARFLAGS				?= ${HAIKU_ARFLAGS} ;
455338b8dc3SIngo WeinholdHAIKU_UNARFLAGS				?= ${HAIKU_UNARFLAGS} ;
456338b8dc3SIngo Weinhold
4578b5934c9SIngo WeinholdHOST_GCC_RAW_VERSION		?= ${hostGCCVersion} ;
4588b5934c9SIngo Weinhold
459c4786ea6SlilloEOF
460c4786ea6Slillo
461b1e5b60cSAxel Dörfler# Libgcc.a objects
462b1e5b60cSAxel Dörfler
4636e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/libgccObjects"
464b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
465b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
466b1e5b60cSAxel Dörfler
467338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
468b1e5b60cSAxel DörflerEOF
469b1e5b60cSAxel Dörfler
4704c74bde8SJérôme Duval# Generate Timezones binaries bindings
4714c74bde8SJérôme Duval
472338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
473338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
474338b8dc3SIngo Weinhold
4756e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/Timezones"
476b1e5b60cSAxel Dörfler# Timezones used for the build
477b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
478b1e5b60cSAxel Dörfler
479338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
480338b8dc3SIngo Weinhold
481b1e5b60cSAxel DörflerEOF
482b1e5b60cSAxel Dörfler
483338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
484338b8dc3SIngo Weinhold	f=$sourceDir/src/data/etc/timezones/$source
4854c74bde8SJérôme Duval
4866e7c6fe5SIngo WeinholdTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' "$f" `
4874c74bde8SJérôme Duval
4886e7c6fe5SIngo Weinholdcat << EOF >> "$buildOutputDir/Timezones"
489338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
4904c74bde8SJérôme DuvalEOF
4914c74bde8SJérôme Duvaldone
492338b8dc3SIngo Weinhold
4939b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
494338b8dc3SIngo Weinhold
495338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
496338b8dc3SIngo Weinhold# automatically generated Jamfile
497338b8dc3SIngo Weinhold
498338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
499338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
500338b8dc3SIngo Weinhold
501338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
502338b8dc3SIngo Weinhold
503338b8dc3SIngo WeinholdEOF
504