xref: /haiku/configure (revision 338b8dc301721b1f472e8297a898d4eaa2f2ee3a)
152a38012Sejakowatz#!/bin/sh
252a38012Sejakowatz#
3*338b8dc3SIngo 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:
15022fa244SIngo Weinhold  --floppy <floppy location>  Specifies the location of the floppy
16022fa244SIngo Weinhold                              (device or image).
176f9587ddSAxel Dörfler  --bochs-debug               Enables bochs serial debug emulation (activated 
186f9587ddSAxel Dörfler                              via kernel settings file).
19*338b8dc3SIngo Weinhold  --cross-tools-prefix <prefix>
20*338b8dc3SIngo Weinhold                              Assume cross compilation. <prefix> should be a
21*338b8dc3SIngo Weinhold                              path to the directory where the cross
22*338b8dc3SIngo Weinhold                              compilation tools are located, plus the platform
23*338b8dc3SIngo Weinhold                              prefix, e.g. "/path/to/tools/i586-pc-beos-".
24*338b8dc3SIngo Weinhold                              This overrides the HAIKU_* tool variables.
25*338b8dc3SIngo Weinhold  --build-cross-tools <build tools dir>
26*338b8dc3SIngo Weinhold                              Assume cross compilation. <build tools dir>
27*338b8dc3SIngo Weinhold                              defines the location of the build tools sources.
28*338b8dc3SIngo Weinhold                              They will be compiled and placed in the output
29*338b8dc3SIngo Weinhold                              directory under "cross-tools". The HAIKU_* tools
30*338b8dc3SIngo Weinhold                              variables will be set accordingly.
31614026d7Sshatty  --target=TARGET             Select build target platform. [default=${target}]
32a17b9c0cSshatty                              valid targets=r5,bone,dano,haiku
33e91f3ca1Sbeveloper  --include-gpl-addons        Include GPL licensed add-ons.
34022fa244SIngo Weinhold  --help                      Prints out this help.
35*338b8dc3SIngo Weinhold
36*338b8dc3SIngo Weinholdenvironment variables:
37*338b8dc3SIngo Weinhold  HAIKU_AR                    The static library archiver. Defaults to "ar".
38*338b8dc3SIngo Weinhold  HAIKU_CC                    The compiler. Defaults to "gcc".
39*338b8dc3SIngo Weinhold  HAIKU_LD                    The linker. Defaults to "ld".
40*338b8dc3SIngo Weinhold  HAIKU_OBJCOPY               The objcopy to be used. Defaults to "objcopy".
41*338b8dc3SIngo Weinhold  HAIKU_RANLIB                The static library indexer. Defaults to "ranlib".
42*338b8dc3SIngo Weinhold  HAIKU_CPPFLAGS              The preprocessor flags. Defaults to "".
43*338b8dc3SIngo Weinhold  HAIKU_CCFLAGS               The C flags. Defaults to "".
44*338b8dc3SIngo Weinhold  HAIKU_CXXFLAGS              The C++ flags. Defaults to "".
45*338b8dc3SIngo Weinhold  HAIKU_LDFLAGS               The linker flags. Defaults to "".
46*338b8dc3SIngo Weinhold  HAIKU_ARFLAGS               The flags passed to HAIKU_AR for archiving.
47*338b8dc3SIngo Weinhold                              Defaults to "ru".
48*338b8dc3SIngo Weinhold  HAIKU_UNARFLAGS             The flags passed to HAIKU_AR for unarchiving.
49*338b8dc3SIngo Weinhold                              Defaults to "x".
50022fa244SIngo WeinholdEOF
51022fa244SIngo Weinhold}
52022fa244SIngo Weinhold
53022fa244SIngo Weinhold# assertparam
54022fa244SIngo Weinhold#
55022fa244SIngo Weinhold# Checks whether at least one parameter is left.
56022fa244SIngo Weinhold#
57022fa244SIngo Weinholdassertparam()
58022fa244SIngo Weinhold{
59022fa244SIngo Weinhold	if [ $2 \< 2 ]; then
60022fa244SIngo Weinhold		echo $0: \`$1\': Parameter expected.
61022fa244SIngo Weinhold		exit 1
62022fa244SIngo Weinhold	fi
63022fa244SIngo Weinhold}
64022fa244SIngo Weinhold
6509c5682dSIngo Weinhold# standard_gcc_settings
6609c5682dSIngo Weinhold#
6709c5682dSIngo Weinhold# Sets the variables for a GCC platform.
6809c5682dSIngo Weinhold#
6909c5682dSIngo Weinholdstandard_gcc_settings()
7009c5682dSIngo Weinhold{
7109c5682dSIngo Weinhold	# PLATFORM_LINKLIBS
72*338b8dc3SIngo Weinhold	gcclib=`$HAIKU_CC -print-libgcc-file-name`
7309c5682dSIngo Weinhold	gccdir=`dirname ${gcclib}`
74*338b8dc3SIngo Weinhold	haikuGCCVersion=`$HAIKU_CC -dumpversion`
75*338b8dc3SIngo Weinhold	haikuGCCMachine=`$HAIKU_CC -dumpmachine`
76*338b8dc3SIngo Weinhold
77*338b8dc3SIngo Weinhold	HAIKU_GCC_LIB_DIR=${gccdir}
78*338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
79*338b8dc3SIngo Weinhold	HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
80*338b8dc3SIngo Weinhold	HAIKU_GCC_HEADERS_DIR=${gccdir}/include
81*338b8dc3SIngo Weinhold	HAIKU_GCC_LIBGCC_OBJECTS=`ar t ${HAIKU_GCC_LIBGCC}`
8209c5682dSIngo Weinhold}
8309c5682dSIngo Weinhold
84*338b8dc3SIngo Weinhold# set_default_value
85*338b8dc3SIngo Weinhold#
86*338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet.
87*338b8dc3SIngo Weinhold#
88*338b8dc3SIngo Weinholdset_default_value()
89*338b8dc3SIngo Weinhold{
90*338b8dc3SIngo Weinhold	local var=$1;
91*338b8dc3SIngo Weinhold	# any better way?
92*338b8dc3SIngo Weinhold	(set -u; (eval "echo \${$var}") &> /dev/null) || eval "$var=$2"
93*338b8dc3SIngo Weinhold}
94*338b8dc3SIngo Weinhold
95*338b8dc3SIngo Weinhold# get_build_tool_path
96*338b8dc3SIngo Weinhold#
97*338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool.
98*338b8dc3SIngo Weinhold#
99*338b8dc3SIngo Weinholdget_build_tool_path()
100*338b8dc3SIngo Weinhold{
101*338b8dc3SIngo Weinhold	local var="HAIKU_$1"
102*338b8dc3SIngo Weinhold	local tool=$2
103*338b8dc3SIngo Weinhold	local path="${crossToolsPrefix}$tool"
104*338b8dc3SIngo Weinhold
105*338b8dc3SIngo Weinhold	if [ -f "$path" ]; then
106*338b8dc3SIngo Weinhold		# get absolute path
107*338b8dc3SIngo Weinhold		local oldPwd=$(pwd)
108*338b8dc3SIngo Weinhold		cd $(dirname "$path")
109*338b8dc3SIngo Weinhold		path="$(pwd)/$(basename "$path")"
110*338b8dc3SIngo Weinhold		cd $oldPwd
111*338b8dc3SIngo Weinhold	else
112*338b8dc3SIngo Weinhold		which "$path" &> /dev/null || {
113*338b8dc3SIngo Weinhold			echo "Build tool \"$path\" not found." >&2
114*338b8dc3SIngo Weinhold			exit 1
115*338b8dc3SIngo Weinhold		}
116*338b8dc3SIngo Weinhold	fi
117*338b8dc3SIngo Weinhold
118*338b8dc3SIngo Weinhold	eval "$var=$path"
119*338b8dc3SIngo Weinhold}
120*338b8dc3SIngo Weinhold
121*338b8dc3SIngo Weinhold# get cwd and the source directory
122*338b8dc3SIngo WeinholdcurrentDir=`pwd`
123*338b8dc3SIngo Weinholdcd `dirname $0`
124*338b8dc3SIngo WeinholdsourceDir=`pwd`
125*338b8dc3SIngo Weinholdcd $currentDir
126*338b8dc3SIngo Weinhold
127022fa244SIngo Weinhold# default parameter values
128022fa244SIngo Weinhold#
12952a38012Sejakowatzplatform=`uname`
130*338b8dc3SIngo WeinholdhaikuGCCVersion=
131022fa244SIngo Weinholdfloppy=
1322b94bc7bSlillobochs_debug=0
133e91f3ca1Sbeveloperinclude_gpl_addons=0
13462339647SAxel Dörflertarget=haiku
135*338b8dc3SIngo WeinholdcrossToolsPrefix=
136*338b8dc3SIngo WeinholdbuildCrossTools=
137*338b8dc3SIngo Weinhold
138*338b8dc3SIngo Weinholdset_default_value HAIKU_AR			ar
139*338b8dc3SIngo Weinholdset_default_value HAIKU_CC			gcc
140*338b8dc3SIngo Weinholdset_default_value HAIKU_LD			ld
141*338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY		objcopy
142*338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB		ranlib
143*338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS	""
144*338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS		""
145*338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS	""
146*338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS		""
147*338b8dc3SIngo Weinholdset_default_value HAIKU_ARFLAGS		ru
148*338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS	x
14962339647SAxel Dörfler
15062339647SAxel Dörfler# host BeOS recognition not needed anymore
15162339647SAxel Dörfler# revision=`uname -r`
15262339647SAxel Dörfler# case "$revision" in
15362339647SAxel Dörfler#  5.1)   target=dano ;;
15462339647SAxel Dörfler#  5.0.4) target=bone ;;
15562339647SAxel Dörfler#  5.0*)  target=r5 ;;
15662339647SAxel Dörfler#  *)     target=haiku ;;
15762339647SAxel Dörfler#esac
158022fa244SIngo Weinhold
159022fa244SIngo Weinhold# parse parameters
160022fa244SIngo Weinhold#
161022fa244SIngo Weinholdwhile [ $# \> 0 ] ; do
162022fa244SIngo Weinhold	case "$1" in
163e91f3ca1Sbeveloper		--include-gpl-addons)	include_gpl_addons=1; shift 1;;
164022fa244SIngo Weinhold		--floppy)		assertparam "$1" $#; floppy=$2; shift 2;;
1652b94bc7bSlillo		--bochs-debug)	bochs_debug=1; shift 1;;
1667c8bb86fSIngo Weinhold		--target=*)     target=`echo $1 | cut -d'=' -f2-`; shift 1;;
167*338b8dc3SIngo Weinhold		--cross-tools-prefix) assertparam "$1" $#; crossToolsPrefix=$2; shift 2;;
168*338b8dc3SIngo Weinhold		--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
169022fa244SIngo Weinhold		--help | -h)	usage; exit 0;;
170022fa244SIngo Weinhold		*)				echo Invalid argument: \`$1\'; exit 1;;
171022fa244SIngo Weinhold	esac
172022fa244SIngo Weinholddone
173022fa244SIngo Weinhold
174022fa244SIngo Weinhold# check parameters
175022fa244SIngo Weinhold#
176022fa244SIngo Weinholdif [ -n "$floppy" ]; then
177022fa244SIngo Weinhold	case "$floppy" in
178022fa244SIngo Weinhold		/*)	;;
179022fa244SIngo Weinhold		*)	echo "Warning: non-absolute floppy path. Parameter ignored.";
180022fa244SIngo Weinhold			floppy=;;
181022fa244SIngo Weinhold	esac
182022fa244SIngo Weinholdfi
18352a38012Sejakowatz
184*338b8dc3SIngo Weinholdcase "${platform}" in
185*338b8dc3SIngo Weinhold	BeOS)	buildPlatform=r5 ;;
186*338b8dc3SIngo Weinhold	Linux)	buildPlatform=linux ;;
187*338b8dc3SIngo Weinhold	*)		echo Unsupported platform: ${platform}
1884cbe4925SAxel Dörfler			exit 1 ;;
1894cbe4925SAxel Dörfleresac
19052a38012Sejakowatz
191*338b8dc3SIngo Weinhold# create output directory
192*338b8dc3SIngo Weinholdif [ "$currentDir" = "$sourceDir" ]; then
193*338b8dc3SIngo Weinhold	outputDir=$currentDir/generated
194*338b8dc3SIngo Weinholdelse
195*338b8dc3SIngo Weinhold	outputDir=$currentDir
196*338b8dc3SIngo Weinholdfi
197*338b8dc3SIngo WeinholdbuildOutputDir=$outputDir/build
198*338b8dc3SIngo WeinholdbuildAttributesDir=$outputDir/attributes
199*338b8dc3SIngo Weinholdmkdir -p $buildOutputDir || exit 1
200*338b8dc3SIngo Weinhold
201*338b8dc3SIngo Weinhold# build cross tools from sources
202*338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then
203*338b8dc3SIngo Weinhold	"$sourceDir/build/scripts/build_cross_tools"  "$sourceDir" \
204*338b8dc3SIngo Weinhold		"$buildCrossTools" || exit 1
205*338b8dc3SIngo Weinhold	crossToolsPrefix=$outputDir/cross-tools/bin/i586-pc-beos-
206*338b8dc3SIngo Weinholdfi
207*338b8dc3SIngo Weinhold
208*338b8dc3SIngo Weinhold# cross tools
209*338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then
210*338b8dc3SIngo Weinhold	get_build_tool_path AR ar
211*338b8dc3SIngo Weinhold	get_build_tool_path CC gcc
212*338b8dc3SIngo Weinhold	get_build_tool_path LD ld
213*338b8dc3SIngo Weinhold	get_build_tool_path OBJCOPY objcopy
214*338b8dc3SIngo Weinhold	get_build_tool_path RANLIB ranlib
215*338b8dc3SIngo Weinholdfi
216*338b8dc3SIngo Weinhold
217*338b8dc3SIngo Weinhold# prepare gcc settings
218*338b8dc3SIngo Weinholdstandard_gcc_settings
219*338b8dc3SIngo Weinhold
22052a38012Sejakowatz# Generate BuildConfig
221*338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/BuildConfig
22252a38012Sejakowatz# BuildConfig
22352a38012Sejakowatz# Note: This file has been automatically generated by configure.
22452a38012Sejakowatz
22509c5682dSIngo WeinholdFLOPPY_PATH			?= "${floppy}" ;
22609c5682dSIngo WeinholdBOCHS_DEBUG_HACK	?= ${bochs_debug} ;
227e91f3ca1SbeveloperINCLUDE_GPL_ADDONS	?= ${include_gpl_addons} ;
228614026d7SshattyTARGET_PLATFORM 	?= ${target} ;
229*338b8dc3SIngo WeinholdHOST_PLATFORM		?= ${buildPlatform} ;
230*338b8dc3SIngo Weinhold
231*338b8dc3SIngo WeinholdHAIKU_GCC_RAW_VERSION	?= ${haikuGCCVersion} ;
232*338b8dc3SIngo WeinholdHAIKU_GCC_MACHINE		?= ${haikuGCCMachine} ;
233*338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR		?= ${HAIKU_GCC_LIB_DIR} ;
234*338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR	?= ${HAIKU_GCC_HEADERS_DIR} ;
235*338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC		?= ${HAIKU_GCC_LIBGCC} ;
236*338b8dc3SIngo Weinhold
237*338b8dc3SIngo WeinholdHAIKU_BUILD_ATTRIBUTES_DIR	?= ${buildAttributesDir} ;
238*338b8dc3SIngo Weinhold
239*338b8dc3SIngo WeinholdHAIKU_AR			?= ${HAIKU_AR} ;
240*338b8dc3SIngo WeinholdHAIKU_CC			?= ${HAIKU_CC} ;
241*338b8dc3SIngo WeinholdHAIKU_LD			?= ${HAIKU_LD} ;
242*338b8dc3SIngo WeinholdHAIKU_OBJCOPY		?= ${HAIKU_OBJCOPY} ;
243*338b8dc3SIngo WeinholdHAIKU_RANLIB		?= ${HAIKU_RANLIB} ;
244*338b8dc3SIngo WeinholdHAIKU_CPPFLAGS		?= ${HAIKU_CPPFLAGS} ;
245*338b8dc3SIngo WeinholdHAIKU_CCFLAGS		?= ${HAIKU_CCFLAGS} ;
246*338b8dc3SIngo WeinholdHAIKU_CXXFLAGS		?= ${HAIKU_CXXFLAGS} ;
247*338b8dc3SIngo WeinholdHAIKU_LDFLAGS		?= ${HAIKU_LDFLAGS} ;
248*338b8dc3SIngo WeinholdHAIKU_ARFLAGS		?= ${HAIKU_ARFLAGS} ;
249*338b8dc3SIngo WeinholdHAIKU_UNARFLAGS		?= ${HAIKU_UNARFLAGS} ;
250*338b8dc3SIngo Weinhold
251c4786ea6SlilloEOF
252c4786ea6Slillo
253b1e5b60cSAxel Dörfler# Libgcc.a objects
254b1e5b60cSAxel Dörfler
255*338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/libgccObjects
256b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so
257b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
258b1e5b60cSAxel Dörfler
259*338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS	?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
260b1e5b60cSAxel DörflerEOF
261b1e5b60cSAxel Dörfler
2624c74bde8SJérôme Duval# Generate Timezones binaries bindings
2634c74bde8SJérôme Duval
264*338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica
265*338b8dc3SIngo Weinhold	southamerica pacificnew etcetera factory backward"
266*338b8dc3SIngo Weinhold
267*338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/Timezones
268b1e5b60cSAxel Dörfler# Timezones used for the build
269b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure.
270b1e5b60cSAxel Dörfler
271*338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
272*338b8dc3SIngo Weinhold
273b1e5b60cSAxel DörflerEOF
274b1e5b60cSAxel Dörfler
275*338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do
276*338b8dc3SIngo Weinhold	f=$sourceDir/src/data/etc/timezones/$source
2774c74bde8SJérôme Duval
278d2ab012dSJérôme DuvalTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' $f `
2794c74bde8SJérôme Duval
280*338b8dc3SIngo Weinholdcat << EOF >> $buildOutputDir/Timezones
281*338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
2824c74bde8SJérôme DuvalEOF
2834c74bde8SJérôme Duvaldone
284*338b8dc3SIngo Weinhold
285*338b8dc3SIngo Weinhold# Generate a boot strap Jamfile in the output directory, if it is not in
286*338b8dc3SIngo Weinhold# the source dir.
287*338b8dc3SIngo Weinhold
288*338b8dc3SIngo Weinholdif [ "$currentDir" != "$sourceDir" ]; then
289*338b8dc3SIngo Weinhold
290*338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile
291*338b8dc3SIngo Weinhold# automatically generated Jamfile
292*338b8dc3SIngo Weinhold
293*338b8dc3SIngo WeinholdHAIKU_TOP			= ${sourceDir} ;
294*338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR	= ${outputDir} ;
295*338b8dc3SIngo Weinhold
296*338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ;
297*338b8dc3SIngo Weinhold
298*338b8dc3SIngo WeinholdEOF
299*338b8dc3SIngo Weinhold
300*338b8dc3SIngo Weinholdfi
301*338b8dc3SIngo Weinhold
302