xref: /haiku/configure (revision 7c4641d0afeb3fda1871223f4fe01fd9ffc4cb69)
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.
69*7c4641d0SOliver Tappe  --target=TARGET             Select build target platform. 
70*7c4641d0SOliver Tappe                              [default=${TARGET_PLATFORM}]
71a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
72*7c4641d0SOliver Tappe  --update                    re-runs last configure invocation [must be given 
73*7c4641d0SOliver Tappe                              as first option!]
74eccc7665SIngo Weinhold  --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
755a34a443SFrançois Revol                              process, but uses more memory.
760385b065SIngo Weinhold  --use-32bit                 Use -m32 flag on 64bit host gcc compiler.
774f4e5272SIngo Weinhold  --use-xattr                 Use Linux xattr support for BeOS attribute
784f4e5272SIngo Weinhold                              emulation. Warning: Make sure your file system
794f4e5272SIngo Weinhold                              supports sufficient attribute sizes (4 KB per
804f4e5272SIngo Weinhold                              file for all attributes won't suffice).
81338b8dc3SIngo Weinhold
82338b8dc3SIngo Weinholdenvironment variables:
83338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
84338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
85338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
86338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
87338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
8877e84f21SIngo Weinhold  HAIKU_YASM                  The yasm assembler (x86 only).
89338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
90338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
91338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
92338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
93338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
9423eb9a9eSFrançois Revol                              Defaults to "cru".
95338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
96338b8dc3SIngo Weinhold                              Defaults to "x".
9764f6da31SIngo Weinhold
9864f6da31SIngo WeinholdNon-standard output directories:
9964f6da31SIngo Weinhold  By default all objects, build configuration, and other related files are
10064f6da31SIngo Weinhold  stored in /path/to/haiku_source/generated.  To store objects in a non-default
10164f6da31SIngo Weinhold  location, run "../../relative/path/to/haiku_source/configure <options>" from
10264f6da31SIngo Weinhold  within your non-default location.  "jam [ options ] targets" can then be run
10364f6da31SIngo Weinhold  directly inside your non-default location.  Another option is to invoke "jam
10464f6da31SIngo Weinhold  [ options ] targets" from within haiku_source.  This can be accomplished by
10564f6da31SIngo Weinhold  either "export HAIKU_OUTPUT_DIR=your non-default location" before invoking
10664f6da31SIngo Weinhold  jam or by creating a symlink of haiku_source/generated pointing to your
10764f6da31SIngo Weinhold  non-default location and running jam.
10864f6da31SIngo Weinhold
10964f6da31SIngo Weinhold
110022fa244SIngo WeinholdEOF
111022fa244SIngo Weinhold}
112022fa244SIngo Weinhold
113022fa244SIngo Weinhold# assertparam
114022fa244SIngo Weinhold#
115022fa244SIngo Weinhold# Checks whether at least one parameter is left.
116022fa244SIngo Weinhold#
117022fa244SIngo Weinholdassertparam()
118022fa244SIngo Weinhold{
11920ab75e6SIngo Weinhold	if [ $2 -lt 2 ]; then
120022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
121022fa244SIngo Weinhold		exit 1
122022fa244SIngo Weinhold	fi
123022fa244SIngo Weinhold}
124022fa244SIngo Weinhold
12520ab75e6SIngo Weinhold# assertparams
12620ab75e6SIngo Weinhold#
12720ab75e6SIngo Weinhold# Checks whether at least a certain number of parameters is left.
12820ab75e6SIngo Weinhold#
12920ab75e6SIngo Weinholdassertparams()
13020ab75e6SIngo Weinhold{
13120ab75e6SIngo Weinhold	if [ $3 -le $2 ]; then
13220ab75e6SIngo Weinhold		echo $0: \`$1\': Not enough parameters.
13320ab75e6SIngo Weinhold		exit 1
13420ab75e6SIngo Weinhold	fi
13520ab75e6SIngo Weinhold}
13620ab75e6SIngo Weinhold
13709c5682dSIngo Weinhold# standard_gcc_settings
13809c5682dSIngo Weinhold#
13909c5682dSIngo Weinhold# Sets the variables for a GCC platform.
14009c5682dSIngo Weinhold#
14109c5682dSIngo Weinholdstandard_gcc_settings()
14209c5682dSIngo Weinhold{
14309c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
144338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
14509c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
1465b0f7b1bSOliver Tappe
147*7c4641d0SOliver Tappe	HAIKU_GCC_RAW_VERSION=`$HAIKU_CC -dumpversion`
148*7c4641d0SOliver Tappe	HAIKU_GCC_MACHINE=`$HAIKU_CC -dumpmachine`
149338b8dc3SIngo Weinhold
150338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
151338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
152338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
15328b5bc75SMichael Lotz	HAIKU_GCC_HEADERS_DIR="${gccdir}/include
15428b5bc75SMichael Lotz		${gccdir}/include-fixed"
1555d978968SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`$HAIKU_AR t ${HAIKU_GCC_LIBGCC} | grep -v eabi.o`
1565d978968SIngo Weinhold		# Note: We filter out eabi.o. It's present in gcc's libgcc for PPC and
1575d978968SIngo Weinhold		# neither needed nor wanted.
1588b5934c9SIngo Weinhold
159*7c4641d0SOliver Tappe	case $HAIKU_GCC_RAW_VERSION in
1608b5934c9SIngo Weinhold		4.*)
1615b0f7b1bSOliver Tappe			# for gcc 4 we use the libstdc++ and libsupc++ that come with the
1625b0f7b1bSOliver Tappe			# compiler
163*7c4641d0SOliver Tappe			HAIKU_STATIC_LIBSTDCXX=`$HAIKU_CC -print-file-name=libstdc++.a`
164*7c4641d0SOliver Tappe			HAIKU_SHARED_LIBSTDCXX=`$HAIKU_CC -print-file-name=libstdc++.so`
165*7c4641d0SOliver Tappe			HAIKU_STATIC_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++.a`
166*7c4641d0SOliver Tappe			HAIKU_SHARED_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++.so`
16714210488SMichael Lotz
16814210488SMichael Lotz			local headers
169*7c4641d0SOliver Tappe			if [ -d $gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION ]; then
170*7c4641d0SOliver Tappe				headers=$gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION
17114210488SMichael Lotz			else
172*7c4641d0SOliver Tappe				headers=$gccdir/../../../../include/c++/$HAIKU_GCC_RAW_VERSION
17314210488SMichael Lotz			fi
17414210488SMichael Lotz
175*7c4641d0SOliver Tappe			HAIKU_CXX_HEADERS_DIR=$headers
176*7c4641d0SOliver Tappe			for d in $HAIKU_GCC_MACHINE backward ext; do
17729ef597dSIngo Weinhold				# Note: We need the line break, otherwise the line might become
17829ef597dSIngo Weinhold				# too long for jam (512 bytes max).
179*7c4641d0SOliver Tappe				HAIKU_CXX_HEADERS_DIR="$HAIKU_CXX_HEADERS_DIR
18029ef597dSIngo Weinhold					$headers/$d"
1818b5934c9SIngo Weinhold			done
182274b450aSMarcus Overhagen
183dad36002SMarcus Overhagen
184dad36002SMarcus Overhagen			# when not building the crosscompiler, to use cpp headers from
185274b450aSMarcus Overhagen			# tree first, but fallback to local C++ system headers (like <new>)
186dad36002SMarcus Overhagen			# if [ "$buildCrossTools" = "" ]; then
187*7c4641d0SOliver Tappe			#	HAIKU_CXX_HEADERS_DIR="headers/cpp $HAIKU_CXX_HEADERS_DIR"
188dad36002SMarcus Overhagen			# fi
1898b5934c9SIngo Weinhold
190*7c4641d0SOliver Tappe			if [ $HAIKU_STATIC_LIBSTDCXX = libstdc++.a ]; then
191*7c4641d0SOliver Tappe				HAIKU_STATIC_LIBSTDCXX=
1928b5934c9SIngo Weinhold			fi
19316d5c24eSOliver Tappe			# we build libstdc++.so ourselves, so we can leave it as is
194*7c4641d0SOliver Tappe			# if [ $HAIKU_SHARED_LIBSTDCXX = libstdc++.so ]; then
195*7c4641d0SOliver Tappe			#	HAIKU_SHARED_LIBSTDCXX=
19616d5c24eSOliver Tappe			# fi
197*7c4641d0SOliver Tappe			if [ $HAIKU_STATIC_LIBSUPCXX = libsupc++.a ]; then
198*7c4641d0SOliver Tappe				HAIKU_STATIC_LIBSUPCXX=
199c89fc875SIngo Weinhold			fi
20016d5c24eSOliver Tappe			# we build libsupc++.so ourselves, so we can leave it as is
201*7c4641d0SOliver Tappe			# if [ $HAIKU_SHARED_LIBSUPCXX = libsupc++.so ]; then
202*7c4641d0SOliver Tappe			# 	HAIKU_SHARED_LIBSUPCXX=
20316d5c24eSOliver Tappe			# fi
2048b5934c9SIngo Weinhold		;;
2056cc8eecfSOliver Tappe		2.9*)
2065b0f7b1bSOliver Tappe			# check for correct (most up-to-date) legacy compiler and complain
2075b0f7b1bSOliver Tappe			# if an older one is installed
208*7c4641d0SOliver Tappe			if [ $HAIKU_GCC_RAW_VERSION != $haikuRequiredLegacyGCCVersion ]; then
2095b0f7b1bSOliver Tappe				echo "GCC version $haikuRequiredLegacyGCCVersion is required!";
2105b0f7b1bSOliver Tappe				echo "Please download it from www.haiku-os.org...";
2115b0f7b1bSOliver Tappe				exit 1;
2125b0f7b1bSOliver Tappe			fi
2135b0f7b1bSOliver Tappe		;;
2148b5934c9SIngo Weinhold	esac
21509c5682dSIngo Weinhold}
21609c5682dSIngo Weinhold
217338b8dc3SIngo Weinhold# set_default_value
218338b8dc3SIngo Weinhold#
219338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
220338b8dc3SIngo Weinhold#
221338b8dc3SIngo Weinholdset_default_value()
222338b8dc3SIngo Weinhold{
2230838a930SJérôme Duval	eval "$1=\${$1-$2}"
224338b8dc3SIngo Weinhold}
225338b8dc3SIngo Weinhold
226338b8dc3SIngo Weinhold# get_build_tool_path
227338b8dc3SIngo Weinhold#
228338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
229338b8dc3SIngo Weinhold#
230338b8dc3SIngo Weinholdget_build_tool_path()
231338b8dc3SIngo Weinhold{
232338b8dc3SIngo Weinhold	local var="HAIKU_$1"
233338b8dc3SIngo Weinhold	local tool=$2
234338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
235338b8dc3SIngo Weinhold
236338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
237338b8dc3SIngo Weinhold		# get absolute path
238a559f87aSFrançois Revol		local oldPwd="`pwd`"
239a559f87aSFrançois Revol		cd "`dirname "$path"`"
240a559f87aSFrançois Revol		path="`pwd`/`basename "$path"`"
241338b8dc3SIngo Weinhold		cd $oldPwd
242338b8dc3SIngo Weinhold	else
243338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
244338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
245338b8dc3SIngo Weinhold			exit 1
246338b8dc3SIngo Weinhold		}
247338b8dc3SIngo Weinhold	fi
248338b8dc3SIngo Weinhold
249338b8dc3SIngo Weinhold	eval "$var=$path"
250338b8dc3SIngo Weinhold}
251338b8dc3SIngo Weinhold
252338b8dc3SIngo Weinhold# get cwd and the source directory
253338b8dc3SIngo WeinholdcurrentDir=`pwd`
2546e7c6fe5SIngo Weinholdcd `dirname "$0"`
255338b8dc3SIngo WeinholdsourceDir=`pwd`
2566e7c6fe5SIngo Weinholdcd "$currentDir"
257338b8dc3SIngo Weinhold
25855d267a4SFrançois Revol# backup the passed arguments
25955d267a4SFrançois RevolconfigureArgs="$@"
26055d267a4SFrançois Revol
261*7c4641d0SOliver Tappe# internal default parameter values
262022fa244SIngo Weinhold#
26352a38012Sejakowatzplatform=`uname`
2645abd9a46SIngo WeinholdplatformMachine=`uname  -m`
26577e84f21SIngo WeinholdtargetArch=x86
266338b8dc3SIngo WeinholdcrossToolsPrefix=
267338b8dc3SIngo WeinholdbuildCrossTools=
26829ef597dSIngo WeinholdbuildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools"
26920ab75e6SIngo WeinholdbuildCrossToolsMachine=
27060d8d8fcSIngo WeinholdbuildCrossToolsJobs=
271*7c4641d0SOliver Tappe
272*7c4641d0SOliver Tappe# exported (BuildSetup) default parameter values
273*7c4641d0SOliver Tappe#
274*7c4641d0SOliver TappeHAIKU_GCC_RAW_VERSION=
275*7c4641d0SOliver TappeHAIKU_GCC_MACHINE=i586-pc-haiku
276*7c4641d0SOliver TappeHAIKU_STATIC_LIBSTDCXX=
277*7c4641d0SOliver TappeHAIKU_SHARED_LIBSTDCXX=
278*7c4641d0SOliver TappeHAIKU_STATIC_LIBSUPCXX=
279*7c4641d0SOliver TappeHAIKU_SHARED_LIBSUPCXX=
280*7c4641d0SOliver TappeHAIKU_CXX_HEADERS_DIR=
281*7c4641d0SOliver TappeHOST_GCC_RAW_VERSION=`gcc -dumpversion`
282*7c4641d0SOliver TappeHOST_GCC_MACHINE=`gcc -dumpmachine`
283*7c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS=0
284*7c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE=0
285*7c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY=0
286*7c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER=0
287*7c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY=default
288*7c4641d0SOliver TappeTARGET_PLATFORM=haiku
289*7c4641d0SOliver TappeHAIKU_USE_GCC_PIPE=0
290*7c4641d0SOliver TappeHAIKU_USE_32BIT=0
291*7c4641d0SOliver TappeHAIKU_USE_XATTR=0
292*7c4641d0SOliver TappeHAIKU_ALTERNATIVE_GCC_OUTPUT_DIR=
293*7c4641d0SOliver TappeHAIKU_ADD_ALTERNATIVE_GCC_LIBS=
294*7c4641d0SOliver TappeHOST_GCC_LD=`gcc -print-prog-name=ld`
295*7c4641d0SOliver TappeHOST_GCC_OBJCOPY=`gcc -print-prog-name=objcopy`
296338b8dc3SIngo Weinhold
29716d5c24eSOliver TappehaikuRequiredLegacyGCCVersion="2.95.3-haiku-090629"
298a559f87aSFrançois Revolexport haikuRequiredLegacyGCCVersion
299af4bf973SOliver Tappe	# version of legacy gcc required to build haiku
300af4bf973SOliver Tappe
301338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
302338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
303338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
304338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
305338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
30677e84f21SIngo Weinholdset_default_value HAIKU_YASM		yasm
307338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
308338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
309338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
310338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
31123eb9a9eSFrançois Revolset_default_value HAIKU_ARFLAGS		cru
312338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
31362339647SAxel Dörfler
314*7c4641d0SOliver Tappe# determine output directory
315*7c4641d0SOliver Tappeif [ "$currentDir" = "$sourceDir" ]; then
316*7c4641d0SOliver Tappe	outputDir=$currentDir/generated
317*7c4641d0SOliver Tappeelse
318*7c4641d0SOliver Tappe	outputDir=$currentDir
319*7c4641d0SOliver Tappefi
320*7c4641d0SOliver TappebuildOutputDir="$outputDir/build"
321*7c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR="$outputDir/attributes"
322*7c4641d0SOliver TappebuildConfigFile="$buildOutputDir/BuildConfig"
323*7c4641d0SOliver Tappe
324*7c4641d0SOliver Tappe# check for update request
325*7c4641d0SOliver Tappeif [ "$1" = "--update" ]; then
326*7c4641d0SOliver Tappe	if ! [ -e "$buildConfigFile" ]; then
327*7c4641d0SOliver Tappe		echo $0 --update: \'$buildConfigFile\' not found - updating not possible.
328*7c4641d0SOliver Tappe		exit 1
329*7c4641d0SOliver Tappe	fi
330*7c4641d0SOliver Tappe	if ! type perl >/dev/null 2>&1; then
331*7c4641d0SOliver Tappe		echo $0 --update: \'perl\' not found - updating not possible.
332*7c4641d0SOliver Tappe		exit 1
333*7c4641d0SOliver Tappe	fi
334*7c4641d0SOliver Tappe	# convert BuildConfig from jam format to shell format and evaluate it
335*7c4641d0SOliver Tappe	shellConfigFile="${buildConfigFile}.shell"
336*7c4641d0SOliver Tappe	perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
337*7c4641d0SOliver Tappe		<"$buildConfigFile" >"$shellConfigFile"
338*7c4641d0SOliver Tappe	. "$shellConfigFile"
339*7c4641d0SOliver Tappe	rm "$shellConfigFile"
340*7c4641d0SOliver Tappe	shift
341*7c4641d0SOliver Tappefi
342*7c4641d0SOliver Tappe
343022fa244SIngo Weinhold# parse parameters
344022fa244SIngo Weinhold#
34520ab75e6SIngo Weinholdwhile [ $# -gt 0 ] ; do
346022fa244SIngo Weinhold	case "$1" in
34760d8d8fcSIngo Weinhold		--alternative-gcc-output-dir)
34860d8d8fcSIngo Weinhold			assertparam "$1" $#
34960d8d8fcSIngo Weinhold			cd $2 || exit 1
350*7c4641d0SOliver Tappe			HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR=`pwd`
351*7c4641d0SOliver Tappe			HAIKU_ADD_ALTERNATIVE_GCC_LIBS=1
35260d8d8fcSIngo Weinhold			cd $currentDir
35360d8d8fcSIngo Weinhold			shift 2
35460d8d8fcSIngo Weinhold			;;
355a5b60fa8SOliver Tappe		--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
3569b0dd528SIngo Weinhold		--build-cross-tools-gcc4)
3579b0dd528SIngo Weinhold			assertparams "$1" 2 $#
3589b0dd528SIngo Weinhold			buildCrossTools=$3
3599b0dd528SIngo Weinhold			buildCrossToolsScript="${buildCrossToolsScript}_gcc4"
36020ab75e6SIngo Weinhold			case "$2" in
361*7c4641d0SOliver Tappe				x86)	HAIKU_GCC_MACHINE=i586-pc-haiku;;
362*7c4641d0SOliver Tappe				ppc)	HAIKU_GCC_MACHINE=powerpc-apple-haiku; targetArch=ppc;;
363*7c4641d0SOliver Tappe				m68k)	HAIKU_GCC_MACHINE=m68k-unknown-haiku; targetArch=m86k;;
364*7c4641d0SOliver Tappe				arm)	HAIKU_GCC_MACHINE=arm-unknown-haiku; targetArch=arm;;
365*7c4641d0SOliver Tappe				mipsel)	HAIKU_GCC_MACHINE=mipsel-unknown-haiku; targetArch=mips;;
36620ab75e6SIngo Weinhold				*)		echo "Unsupported target architecture: $2"
36720ab75e6SIngo Weinhold						exit 1;;
36820ab75e6SIngo Weinhold			esac
369*7c4641d0SOliver Tappe			buildCrossToolsMachine=$HAIKU_GCC_MACHINE
3709b0dd528SIngo Weinhold			shift 3
3719b0dd528SIngo Weinhold			;;
3729b0dd528SIngo Weinhold		--cross-tools-prefix)
3739b0dd528SIngo Weinhold			assertparam "$1" $#
3749b0dd528SIngo Weinhold			crossToolsPrefix=$2
3759b0dd528SIngo Weinhold			shift 2
3769b0dd528SIngo Weinhold			;;
377a66c32ddSIngo Weinhold		--distro-compatibility)
3789b0dd528SIngo Weinhold			assertparam "$1" $#
379*7c4641d0SOliver Tappe			HAIKU_DISTRO_COMPATIBILITY=$2
380*7c4641d0SOliver Tappe			case "$HAIKU_DISTRO_COMPATIBILITY" in
381a66c32ddSIngo Weinhold				official)	;;
382a66c32ddSIngo Weinhold				compatible)	;;
383a66c32ddSIngo Weinhold				default)	;;
384a66c32ddSIngo Weinhold				*)			echo "Invalid distro compatibility" \
385*7c4641d0SOliver Tappe								"level: $HAIKU_DISTRO_COMPATIBILITY"
386a66c32ddSIngo Weinhold							exit 1;;
387a66c32ddSIngo Weinhold			esac
3889b0dd528SIngo Weinhold			shift 2
3899b0dd528SIngo Weinhold			;;
390*7c4641d0SOliver Tappe		--enable-multiuser)	HAIKU_ENABLE_MULTIUSER=1; shift 1;;
39160d8d8fcSIngo Weinhold		--help | -h)	usage; exit 0;;
392*7c4641d0SOliver Tappe		--include-gpl-addons)	HAIKU_INCLUDE_GPL_ADDONS=1; shift 1;;
393*7c4641d0SOliver Tappe		--include-patented-code)	HAIKU_INCLUDE_PATENTED_CODE=1; shift 1;;
394*7c4641d0SOliver Tappe		--include-3rdparty)	HAIKU_INCLUDE_3RDPARTY=1; shift 1;;
39560d8d8fcSIngo Weinhold        -j*)				buildCrossToolsJobs="$1"; shift 1;;
396*7c4641d0SOliver Tappe		--target=*)     TARGET_PLATFORM=`echo $1 | cut -d'=' -f2-`; shift 1;;
397*7c4641d0SOliver Tappe		--use-gcc-pipe)	HAIKU_USE_GCC_PIPE=1; shift 1;;
398*7c4641d0SOliver Tappe		--use-32bit)	HAIKU_USE_32BIT=1; shift 1;;
399*7c4641d0SOliver Tappe		--use-xattr)	HAIKU_USE_XATTR=1; shift 1;;
400022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
401022fa244SIngo Weinhold	esac
402022fa244SIngo Weinholddone
403022fa244SIngo Weinhold
4040df3cc9cSIngo Weinhold# detect the build platform
405338b8dc3SIngo Weinholdcase "${platform}" in
4060df3cc9cSIngo Weinhold	BeOS)	revision=`uname -r`
4070df3cc9cSIngo Weinhold			case "$revision" in
408*7c4641d0SOliver Tappe				6.*)	HOST_PLATFORM=dano ;;
409*7c4641d0SOliver Tappe				5.1)	HOST_PLATFORM=dano ;;
410*7c4641d0SOliver Tappe				5.0.4)	HOST_PLATFORM=bone ;;
411*7c4641d0SOliver Tappe				5.0*)	HOST_PLATFORM=r5 ;;
4120df3cc9cSIngo Weinhold				*)		echo Unknown BeOS version: $revision
4130df3cc9cSIngo Weinhold						exit 1 ;;
4140df3cc9cSIngo Weinhold			esac
4150df3cc9cSIngo Weinhold			;;
416*7c4641d0SOliver Tappe	Darwin)	HOST_PLATFORM=darwin ;;
417*7c4641d0SOliver Tappe	FreeBSD)	HOST_PLATFORM=freebsd
418*7c4641d0SOliver Tappe				if [ "$HAIKU_USE_32BIT" = 1 ] ; then
4195abd9a46SIngo Weinhold					echo Unsupported platform: FreeBSD ${platformMachine}
420308c212cSIngo Weinhold					exit 1
421308c212cSIngo Weinhold				fi	;;
422*7c4641d0SOliver Tappe	Haiku)	HOST_PLATFORM=haiku_host ;;
423*7c4641d0SOliver Tappe	Linux)	HOST_PLATFORM=linux ;;
424*7c4641d0SOliver Tappe	OpenBSD) HOST_PLATFORM=openbsd ;;
425*7c4641d0SOliver Tappe	SunOS)	HOST_PLATFORM=sunos ;;
426*7c4641d0SOliver Tappe	CYGWIN_NT-*) HOST_PLATFORM=cygwin ;;
427338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
4284cbe4925SAxel Dörfler			exit 1 ;;
4294cbe4925SAxel Dörfleresac
43052a38012Sejakowatz
43177e84f21SIngo Weinhold# check yasm version
43277e84f21SIngo Weinholdif [ $targetArch = "x86" ]; then
43377e84f21SIngo Weinhold	$HAIKU_YASM --version > /dev/null || {
43492696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
43577e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
43677e84f21SIngo Weinhold		exit 1
43777e84f21SIngo Weinhold	}
43877e84f21SIngo Weinhold
43977e84f21SIngo Weinhold	set -- $($HAIKU_YASM --version | head -n 1)
44077e84f21SIngo Weinhold	versionOK=0
44177e84f21SIngo Weinhold	case $2 in
44292696166SIngo Weinhold		0.[0-6].*)		;;
44377e84f21SIngo Weinhold		*)				versionOK=1 ;;
44477e84f21SIngo Weinhold	esac
44577e84f21SIngo Weinhold
44677e84f21SIngo Weinhold	if [ $versionOK = 0 ]; then
44792696166SIngo Weinhold		echo "The yasm assembler version 0.7.0 or later must be installed."
44877e84f21SIngo Weinhold		echo "The installed version is $2."
44977e84f21SIngo Weinhold		echo "Download from: http://www.tortall.net/projects/yasm/wiki/Download"
45077e84f21SIngo Weinhold		exit 1
45177e84f21SIngo Weinhold	fi
45277e84f21SIngo Weinholdfi
45377e84f21SIngo Weinhold
4543ecc5287SMichael Lotz# check for case-sensitive filesystem if on darwin
455*7c4641d0SOliver Tappeif [ $HOST_PLATFORM = "darwin" ]; then
4560651c859SMichael Pfeiffer	diskutil info $(pwd) | grep -i "case-sensitive" > /dev/null
4573ecc5287SMichael Lotz	if [ $? != 0 ]; then
4583ecc5287SMichael Lotz		echo "You need a case-sensitive file-system to build Haiku."
4593ecc5287SMichael Lotz		echo "Please see the following guide on how to set one up:"
4603ecc5287SMichael Lotz		echo "http://haiku-os.org/documents/dev/how_to_build_haiku_on_mac_os_x"
4613ecc5287SMichael Lotz		exit 1
4623ecc5287SMichael Lotz	fi
4633ecc5287SMichael Lotzfi
4643ecc5287SMichael Lotz
465338b8dc3SIngo Weinhold# create output directory
4666e7c6fe5SIngo Weinholdmkdir -p "$buildOutputDir" || exit 1
467338b8dc3SIngo Weinhold
468338b8dc3SIngo Weinhold# build cross tools from sources
469338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then
47020ab75e6SIngo Weinhold	"$buildCrossToolsScript" $buildCrossToolsMachine "$sourceDir" \
47160d8d8fcSIngo Weinhold		"$buildCrossTools" "$outputDir" $buildCrossToolsJobs || exit 1
472*7c4641d0SOliver Tappe	crossToolsPrefix="$outputDir/cross-tools/bin/${HAIKU_GCC_MACHINE}-"
473338b8dc3SIngo Weinholdfi
474338b8dc3SIngo Weinhold
475338b8dc3SIngo Weinhold# cross tools
476338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then
477338b8dc3SIngo Weinhold	get_build_tool_path AR ar
478338b8dc3SIngo Weinhold	get_build_tool_path CC gcc
479338b8dc3SIngo Weinhold	get_build_tool_path LD ld
480338b8dc3SIngo Weinhold	get_build_tool_path OBJCOPY objcopy
481338b8dc3SIngo Weinhold	get_build_tool_path RANLIB ranlib
482338b8dc3SIngo Weinholdfi
483338b8dc3SIngo Weinhold
484338b8dc3SIngo Weinhold# prepare gcc settings
485338b8dc3SIngo Weinholdstandard_gcc_settings
486338b8dc3SIngo Weinhold
487eedc3d0bSIngo Weinhold# check whether the Haiku compiler really targets Haiku or BeOS
488*7c4641d0SOliver Tappecase "$HAIKU_GCC_MACHINE" in
489eedc3d0bSIngo Weinhold	*-*-haiku)	;;
490eedc3d0bSIngo Weinhold	*-*-beos)	;;
491eedc3d0bSIngo Weinhold	*) echo The compiler specified as Haiku target compiler is not a valid \
492eedc3d0bSIngo Weinhold			Haiku cross-compiler. Please see ReadMe.cross-compile. >&2
493eedc3d0bSIngo Weinhold	   echo compiler: $HAIKU_CC
494*7c4641d0SOliver Tappe	   echo compiler is configured for target: $HAIKU_GCC_MACHINE
495eedc3d0bSIngo Weinhold	   exit 1 ;;
496eedc3d0bSIngo Weinholdesac
497eedc3d0bSIngo Weinhold
49852a38012Sejakowatz# Generate BuildConfig
499*7c4641d0SOliver Tappecat << EOF > "$buildConfigFile"
50052a38012Sejakowatz# BuildConfig
50155d267a4SFrançois Revol# Note: This file has been automatically generated by configure with the following arguments:
50255d267a4SFrançois Revol# ${configureArgs}
50352a38012Sejakowatz
504*7c4641d0SOliver TappeTARGET_PLATFORM 			?= "${TARGET_PLATFORM}" ;
505*7c4641d0SOliver TappeHOST_PLATFORM				?= "${HOST_PLATFORM}" ;
506338b8dc3SIngo Weinhold
507*7c4641d0SOliver TappeHAIKU_INCLUDE_GPL_ADDONS			?= "${HAIKU_INCLUDE_GPL_ADDONS}" ;
508*7c4641d0SOliver TappeHAIKU_INCLUDE_PATENTED_CODE			?= "${HAIKU_INCLUDE_PATENTED_CODE}" ;
509*7c4641d0SOliver TappeHAIKU_INCLUDE_3RDPARTY				?= "${HAIKU_INCLUDE_3RDPARTY}" ;
510*7c4641d0SOliver TappeHAIKU_ENABLE_MULTIUSER				?= "${HAIKU_ENABLE_MULTIUSER}" ;
511*7c4641d0SOliver TappeHAIKU_DISTRO_COMPATIBILITY			?= "${HAIKU_DISTRO_COMPATIBILITY}" ;
512*7c4641d0SOliver TappeHAIKU_USE_GCC_PIPE					?= "${HAIKU_USE_GCC_PIPE}" ;
513*7c4641d0SOliver TappeHAIKU_HOST_USE_32BIT				?= "${HAIKU_USE_32BIT}" ;
514*7c4641d0SOliver TappeHAIKU_HOST_USE_XATTR				?= "${HAIKU_USE_XATTR}" ;
515*7c4641d0SOliver TappeHAIKU_ALTERNATIVE_GCC_OUTPUT_DIR	?= ${HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR} ;
516*7c4641d0SOliver TappeHAIKU_ADD_ALTERNATIVE_GCC_LIBS		?= ${HAIKU_ADD_ALTERNATIVE_GCC_LIBS} ;
517eccc7665SIngo Weinhold
518*7c4641d0SOliver TappeHAIKU_GCC_RAW_VERSION		?= ${HAIKU_GCC_RAW_VERSION} ;
519*7c4641d0SOliver TappeHAIKU_GCC_MACHINE			?= ${HAIKU_GCC_MACHINE} ;
520338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR			?= ${HAIKU_GCC_LIB_DIR} ;
521338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR		?= ${HAIKU_GCC_HEADERS_DIR} ;
522338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC			?= ${HAIKU_GCC_LIBGCC} ;
523338b8dc3SIngo Weinhold
524*7c4641d0SOliver TappeHAIKU_STATIC_LIBSTDC++		?= ${HAIKU_STATIC_LIBSTDCXX} ;
525*7c4641d0SOliver TappeHAIKU_SHARED_LIBSTDC++		?= ${HAIKU_SHARED_LIBSTDCXX} ;
526*7c4641d0SOliver TappeHAIKU_STATIC_LIBSUPC++		?= ${HAIKU_STATIC_LIBSUPCXX} ;
527*7c4641d0SOliver TappeHAIKU_SHARED_LIBSUPC++		?= ${HAIKU_SHARED_LIBSUPCXX} ;
528*7c4641d0SOliver TappeHAIKU_C++_HEADERS_DIR		?= ${HAIKU_CXX_HEADERS_DIR} ;
5298b5934c9SIngo Weinhold
530*7c4641d0SOliver TappeHAIKU_BUILD_ATTRIBUTES_DIR	?= ${HAIKU_BUILD_ATTRIBUTES_DIR} ;
531338b8dc3SIngo Weinhold
532338b8dc3SIngo WeinholdHAIKU_AR					?= ${HAIKU_AR} ;
533338b8dc3SIngo WeinholdHAIKU_CC					?= ${HAIKU_CC} ;
534338b8dc3SIngo WeinholdHAIKU_LD					?= ${HAIKU_LD} ;
535338b8dc3SIngo WeinholdHAIKU_OBJCOPY				?= ${HAIKU_OBJCOPY} ;
536338b8dc3SIngo WeinholdHAIKU_RANLIB				?= ${HAIKU_RANLIB} ;
53777e84f21SIngo WeinholdHAIKU_YASM					?= ${HAIKU_YASM} ;
538338b8dc3SIngo WeinholdHAIKU_CPPFLAGS				?= ${HAIKU_CPPFLAGS} ;
539338b8dc3SIngo WeinholdHAIKU_CCFLAGS				?= ${HAIKU_CCFLAGS} ;
540338b8dc3SIngo WeinholdHAIKU_CXXFLAGS				?= ${HAIKU_CXXFLAGS} ;
541338b8dc3SIngo WeinholdHAIKU_LDFLAGS				?= ${HAIKU_LDFLAGS} ;
542338b8dc3SIngo WeinholdHAIKU_ARFLAGS				?= ${HAIKU_ARFLAGS} ;
543338b8dc3SIngo WeinholdHAIKU_UNARFLAGS				?= ${HAIKU_UNARFLAGS} ;
544338b8dc3SIngo Weinhold
545*7c4641d0SOliver TappeHOST_GCC_RAW_VERSION		?= ${HOST_GCC_RAW_VERSION} ;
546*7c4641d0SOliver TappeHOST_GCC_MACHINE			?= ${HOST_GCC_MACHINE} ;
547*7c4641d0SOliver TappeHOST_LD						?= ${HOST_GCC_LD} ;
548*7c4641d0SOliver TappeHOST_OBJCOPY				?= ${HOST_GCC_OBJCOPY} ;
5498b5934c9SIngo Weinhold
550c4786ea6SlilloEOF
551c4786ea6Slillo
552b1e5b60cSAxel Dörfler# Libgcc.a objects
553b1e5b60cSAxel Dörfler
5546e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/libgccObjects"
555b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
556b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
557b1e5b60cSAxel Dörfler
558338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
559b1e5b60cSAxel DörflerEOF
560b1e5b60cSAxel Dörfler
5614c74bde8SJérôme Duval# Generate Timezones binaries bindings
5624c74bde8SJérôme Duval
563338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
564338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
565338b8dc3SIngo Weinhold
5666e7c6fe5SIngo Weinholdcat << EOF > "$buildOutputDir/Timezones"
567b1e5b60cSAxel Dörfler# Timezones used for the build
568b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
569b1e5b60cSAxel Dörfler
570338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
571338b8dc3SIngo Weinhold
572b1e5b60cSAxel DörflerEOF
573b1e5b60cSAxel Dörfler
574338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
5753578c56aSAxel Dörfler	f=$sourceDir/src/data/timezones/$source
5764c74bde8SJérôme Duval
5776e7c6fe5SIngo WeinholdTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' "$f" `
5784c74bde8SJérôme Duval
5796e7c6fe5SIngo Weinholdcat << EOF >> "$buildOutputDir/Timezones"
580338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
5814c74bde8SJérôme DuvalEOF
5824c74bde8SJérôme Duvaldone
583338b8dc3SIngo Weinhold
5849b0dd528SIngo Weinhold# Generate a boot strap Jamfile in the output directory.
585338b8dc3SIngo Weinhold
586338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
587338b8dc3SIngo Weinhold# automatically generated Jamfile
588338b8dc3SIngo Weinhold
589338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
590338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
591338b8dc3SIngo Weinhold
592338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
593338b8dc3SIngo Weinhold
594338b8dc3SIngo WeinholdEOF
595