2002-07-09 16:24:59 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-10-29 20:27:43 +04:00
|
|
|
# configure [ <options> ]
|
2004-10-18 05:59:54 +04:00
|
|
|
|
2002-07-15 02:09:44 +04:00
|
|
|
# usage
|
|
|
|
#
|
|
|
|
# Prints usage.
|
|
|
|
#
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
Usage: $0 <options>
|
|
|
|
options:
|
2004-10-18 05:59:54 +04:00
|
|
|
--floppy <floppy location> Specifies the location of the floppy
|
|
|
|
(device or image).
|
2005-01-20 23:09:25 +03:00
|
|
|
--bochs-debug Enables bochs serial debug emulation (activated
|
|
|
|
via kernel settings file).
|
2005-10-29 20:27:43 +04:00
|
|
|
--cross-tools-prefix <prefix>
|
|
|
|
Assume cross compilation. <prefix> should be a
|
|
|
|
path to the directory where the cross
|
|
|
|
compilation tools are located, plus the platform
|
|
|
|
prefix, e.g. "/path/to/tools/i586-pc-beos-".
|
|
|
|
This overrides the HAIKU_* tool variables.
|
|
|
|
--build-cross-tools <build tools dir>
|
|
|
|
Assume cross compilation. <build tools dir>
|
|
|
|
defines the location of the build tools sources.
|
|
|
|
They will be compiled and placed in the output
|
|
|
|
directory under "cross-tools". The HAIKU_* tools
|
|
|
|
variables will be set accordingly.
|
2004-10-18 05:59:54 +04:00
|
|
|
--target=TARGET Select build target platform. [default=${target}]
|
2004-10-25 12:44:06 +04:00
|
|
|
valid targets=r5,bone,dano,haiku
|
2004-10-18 05:59:54 +04:00
|
|
|
--include-gpl-addons Include GPL licensed add-ons.
|
|
|
|
--help Prints out this help.
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
environment variables:
|
|
|
|
HAIKU_AR The static library archiver. Defaults to "ar".
|
|
|
|
HAIKU_CC The compiler. Defaults to "gcc".
|
|
|
|
HAIKU_LD The linker. Defaults to "ld".
|
|
|
|
HAIKU_OBJCOPY The objcopy to be used. Defaults to "objcopy".
|
|
|
|
HAIKU_RANLIB The static library indexer. Defaults to "ranlib".
|
|
|
|
HAIKU_CPPFLAGS The preprocessor flags. Defaults to "".
|
|
|
|
HAIKU_CCFLAGS The C flags. Defaults to "".
|
|
|
|
HAIKU_CXXFLAGS The C++ flags. Defaults to "".
|
|
|
|
HAIKU_LDFLAGS The linker flags. Defaults to "".
|
|
|
|
HAIKU_ARFLAGS The flags passed to HAIKU_AR for archiving.
|
|
|
|
Defaults to "ru".
|
|
|
|
HAIKU_UNARFLAGS The flags passed to HAIKU_AR for unarchiving.
|
|
|
|
Defaults to "x".
|
2002-07-15 02:09:44 +04:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
# assertparam
|
|
|
|
#
|
|
|
|
# Checks whether at least one parameter is left.
|
|
|
|
#
|
|
|
|
assertparam()
|
|
|
|
{
|
|
|
|
if [ $2 \< 2 ]; then
|
|
|
|
echo $0: \`$1\': Parameter expected.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2003-05-06 02:07:33 +04:00
|
|
|
# standard_gcc_settings
|
|
|
|
#
|
|
|
|
# Sets the variables for a GCC platform.
|
|
|
|
#
|
|
|
|
standard_gcc_settings()
|
|
|
|
{
|
|
|
|
# PLATFORM_LINKLIBS
|
2005-10-29 20:27:43 +04:00
|
|
|
gcclib=`$HAIKU_CC -print-libgcc-file-name`
|
2003-05-06 02:07:33 +04:00
|
|
|
gccdir=`dirname ${gcclib}`
|
2005-10-29 20:27:43 +04:00
|
|
|
haikuGCCVersion=`$HAIKU_CC -dumpversion`
|
|
|
|
haikuGCCMachine=`$HAIKU_CC -dumpmachine`
|
|
|
|
|
|
|
|
HAIKU_GCC_LIB_DIR=${gccdir}
|
|
|
|
HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a
|
|
|
|
HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
|
|
|
|
HAIKU_GCC_HEADERS_DIR=${gccdir}/include
|
|
|
|
HAIKU_GCC_LIBGCC_OBJECTS=`ar t ${HAIKU_GCC_LIBGCC}`
|
2005-11-13 01:58:54 +03:00
|
|
|
|
2005-11-14 16:47:52 +03:00
|
|
|
# for gcc 4 we use the libstdc++ and libsupc++ that come with the compiler
|
2005-11-13 01:58:54 +03:00
|
|
|
case $haikuGCCVersion in
|
|
|
|
4.*)
|
|
|
|
haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
|
|
|
|
haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
|
2005-11-14 16:47:52 +03:00
|
|
|
haikuStaticLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.a`
|
|
|
|
haikuSharedLibSupCxx=`$HAIKU_CC -print-file-name=libsupc++.so`
|
2005-11-13 01:58:54 +03:00
|
|
|
local headers=$gccdir/../../../../include/c++/$haikuGCCVersion
|
|
|
|
haikuCxxHeadersDir=$headers
|
|
|
|
for d in $haikuGCCMachine backward ext debug; do
|
|
|
|
haikuCxxHeadersDir="$haikuCxxHeadersDir $headers/$d"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
|
|
|
|
haikuStaticLibStdCxx=
|
|
|
|
fi
|
|
|
|
if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
|
|
|
|
haikuSharedLibStdCxx=
|
|
|
|
fi
|
2005-11-14 16:47:52 +03:00
|
|
|
if [ $haikuStaticLibSupCxx = libsupc++.a ]; then
|
|
|
|
haikuStaticLibSupCxx=
|
|
|
|
fi
|
|
|
|
if [ $haikuSharedLibSupCxx = libsupc++.so ]; then
|
|
|
|
haikuSharedLibSupCxx=
|
|
|
|
fi
|
2005-11-13 01:58:54 +03:00
|
|
|
;;
|
|
|
|
esac
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# set_default_value
|
|
|
|
#
|
|
|
|
# Set the value for a variable, if no value is set yet.
|
|
|
|
#
|
|
|
|
set_default_value()
|
|
|
|
{
|
|
|
|
local var=$1;
|
|
|
|
# any better way?
|
|
|
|
(set -u; (eval "echo \${$var}") &> /dev/null) || eval "$var=$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
# get_build_tool_path
|
|
|
|
#
|
|
|
|
# Gets a usable absolute path of a build tool.
|
|
|
|
#
|
|
|
|
get_build_tool_path()
|
|
|
|
{
|
|
|
|
local var="HAIKU_$1"
|
|
|
|
local tool=$2
|
|
|
|
local path="${crossToolsPrefix}$tool"
|
|
|
|
|
|
|
|
if [ -f "$path" ]; then
|
|
|
|
# get absolute path
|
|
|
|
local oldPwd=$(pwd)
|
|
|
|
cd $(dirname "$path")
|
|
|
|
path="$(pwd)/$(basename "$path")"
|
|
|
|
cd $oldPwd
|
|
|
|
else
|
|
|
|
which "$path" &> /dev/null || {
|
|
|
|
echo "Build tool \"$path\" not found." >&2
|
|
|
|
exit 1
|
|
|
|
}
|
2004-07-05 22:35:35 +04:00
|
|
|
fi
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
eval "$var=$path"
|
2003-05-06 02:07:33 +04:00
|
|
|
}
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# get cwd and the source directory
|
|
|
|
currentDir=`pwd`
|
|
|
|
cd `dirname $0`
|
|
|
|
sourceDir=`pwd`
|
|
|
|
cd $currentDir
|
|
|
|
|
2002-07-15 02:09:44 +04:00
|
|
|
# default parameter values
|
|
|
|
#
|
2002-07-09 16:24:59 +04:00
|
|
|
platform=`uname`
|
2005-10-29 20:27:43 +04:00
|
|
|
haikuGCCVersion=
|
2005-11-13 01:58:54 +03:00
|
|
|
haikuStaticLibStdCxx=
|
|
|
|
haikuSharedLibStdCxx=
|
2005-11-14 16:47:52 +03:00
|
|
|
haikuStaticLibSupCxx=
|
|
|
|
haikuSharedLibSupCxx=
|
2005-11-13 01:58:54 +03:00
|
|
|
haikuCxxHeadersDir=
|
|
|
|
hostGCCVersion=`cc -dumpversion`
|
2002-07-15 02:09:44 +04:00
|
|
|
floppy=
|
2002-07-16 16:39:57 +04:00
|
|
|
bochs_debug=0
|
2004-03-07 01:39:28 +03:00
|
|
|
include_gpl_addons=0
|
2005-06-01 18:33:46 +04:00
|
|
|
target=haiku
|
2005-10-29 20:27:43 +04:00
|
|
|
crossToolsPrefix=
|
|
|
|
buildCrossTools=
|
|
|
|
|
|
|
|
set_default_value HAIKU_AR ar
|
|
|
|
set_default_value HAIKU_CC gcc
|
|
|
|
set_default_value HAIKU_LD ld
|
|
|
|
set_default_value HAIKU_OBJCOPY objcopy
|
|
|
|
set_default_value HAIKU_RANLIB ranlib
|
|
|
|
set_default_value HAIKU_CPPFLAGS ""
|
|
|
|
set_default_value HAIKU_CCFLAGS ""
|
|
|
|
set_default_value HAIKU_CXXFLAGS ""
|
|
|
|
set_default_value HAIKU_LDFLAGS ""
|
|
|
|
set_default_value HAIKU_ARFLAGS ru
|
|
|
|
set_default_value HAIKU_UNARFLAGS x
|
2005-06-01 18:33:46 +04:00
|
|
|
|
2002-07-15 02:09:44 +04:00
|
|
|
# parse parameters
|
|
|
|
#
|
|
|
|
while [ $# \> 0 ] ; do
|
|
|
|
case "$1" in
|
2004-03-07 01:39:28 +03:00
|
|
|
--include-gpl-addons) include_gpl_addons=1; shift 1;;
|
2002-07-15 02:09:44 +04:00
|
|
|
--floppy) assertparam "$1" $#; floppy=$2; shift 2;;
|
2002-07-17 20:27:37 +04:00
|
|
|
--bochs-debug) bochs_debug=1; shift 1;;
|
2004-11-01 02:56:16 +03:00
|
|
|
--target=*) target=`echo $1 | cut -d'=' -f2-`; shift 1;;
|
2005-10-29 20:27:43 +04:00
|
|
|
--cross-tools-prefix) assertparam "$1" $#; crossToolsPrefix=$2; shift 2;;
|
|
|
|
--build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;;
|
2002-07-15 02:09:44 +04:00
|
|
|
--help | -h) usage; exit 0;;
|
|
|
|
*) echo Invalid argument: \`$1\'; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# check parameters
|
|
|
|
#
|
|
|
|
if [ -n "$floppy" ]; then
|
|
|
|
case "$floppy" in
|
|
|
|
/*) ;;
|
|
|
|
*) echo "Warning: non-absolute floppy path. Parameter ignored.";
|
|
|
|
floppy=;;
|
|
|
|
esac
|
|
|
|
fi
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-10-31 03:00:27 +03:00
|
|
|
# detect the build platform
|
2005-10-29 20:27:43 +04:00
|
|
|
case "${platform}" in
|
2005-10-31 03:00:27 +03:00
|
|
|
BeOS) revision=`uname -r`
|
|
|
|
case "$revision" in
|
2005-11-08 12:29:13 +03:00
|
|
|
6.*) buildPlatform=dano ;;
|
2005-10-31 03:00:27 +03:00
|
|
|
5.1) buildPlatform=dano ;;
|
|
|
|
5.0.4) buildPlatform=bone ;;
|
|
|
|
5.0*) buildPlatform=r5 ;;
|
|
|
|
*) echo Unknown BeOS version: $revision
|
|
|
|
exit 1 ;;
|
|
|
|
esac
|
|
|
|
;;
|
2005-10-29 20:27:43 +04:00
|
|
|
Linux) buildPlatform=linux ;;
|
|
|
|
*) echo Unsupported platform: ${platform}
|
|
|
|
exit 1 ;;
|
2005-09-02 17:23:51 +04:00
|
|
|
esac
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# create output directory
|
|
|
|
if [ "$currentDir" = "$sourceDir" ]; then
|
|
|
|
outputDir=$currentDir/generated
|
|
|
|
else
|
|
|
|
outputDir=$currentDir
|
|
|
|
fi
|
|
|
|
buildOutputDir=$outputDir/build
|
|
|
|
buildAttributesDir=$outputDir/attributes
|
|
|
|
mkdir -p $buildOutputDir || exit 1
|
|
|
|
|
|
|
|
# build cross tools from sources
|
|
|
|
if [ -n "$buildCrossTools" ]; then
|
|
|
|
"$sourceDir/build/scripts/build_cross_tools" "$sourceDir" \
|
|
|
|
"$buildCrossTools" || exit 1
|
|
|
|
crossToolsPrefix=$outputDir/cross-tools/bin/i586-pc-beos-
|
|
|
|
fi
|
|
|
|
|
|
|
|
# cross tools
|
|
|
|
if [ -n "$crossToolsPrefix" ]; then
|
|
|
|
get_build_tool_path AR ar
|
|
|
|
get_build_tool_path CC gcc
|
|
|
|
get_build_tool_path LD ld
|
|
|
|
get_build_tool_path OBJCOPY objcopy
|
|
|
|
get_build_tool_path RANLIB ranlib
|
|
|
|
fi
|
|
|
|
|
|
|
|
# prepare gcc settings
|
|
|
|
standard_gcc_settings
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
# Generate BuildConfig
|
2005-10-29 20:27:43 +04:00
|
|
|
cat << EOF > $buildOutputDir/BuildConfig
|
2002-07-09 16:24:59 +04:00
|
|
|
# BuildConfig
|
|
|
|
# Note: This file has been automatically generated by configure.
|
|
|
|
|
2003-05-06 02:07:33 +04:00
|
|
|
FLOPPY_PATH ?= "${floppy}" ;
|
|
|
|
BOCHS_DEBUG_HACK ?= ${bochs_debug} ;
|
2004-03-07 01:39:28 +03:00
|
|
|
INCLUDE_GPL_ADDONS ?= ${include_gpl_addons} ;
|
2004-10-18 05:59:54 +04:00
|
|
|
TARGET_PLATFORM ?= ${target} ;
|
2005-10-29 20:27:43 +04:00
|
|
|
HOST_PLATFORM ?= ${buildPlatform} ;
|
|
|
|
|
|
|
|
HAIKU_GCC_RAW_VERSION ?= ${haikuGCCVersion} ;
|
|
|
|
HAIKU_GCC_MACHINE ?= ${haikuGCCMachine} ;
|
|
|
|
HAIKU_GCC_LIB_DIR ?= ${HAIKU_GCC_LIB_DIR} ;
|
|
|
|
HAIKU_GCC_HEADERS_DIR ?= ${HAIKU_GCC_HEADERS_DIR} ;
|
|
|
|
HAIKU_GCC_LIBGCC ?= ${HAIKU_GCC_LIBGCC} ;
|
|
|
|
|
2005-11-13 01:58:54 +03:00
|
|
|
HAIKU_STATIC_LIBSTDC++ ?= ${haikuStaticLibStdCxx} ;
|
|
|
|
HAIKU_SHARED_LIBSTDC++ ?= ${haikuSharedLibStdCxx} ;
|
2005-11-14 16:47:52 +03:00
|
|
|
HAIKU_STATIC_LIBSUPC++ ?= ${haikuStaticLibSupCxx} ;
|
|
|
|
HAIKU_SHARED_LIBSUPC++ ?= ${haikuSharedLibSupCxx} ;
|
2005-11-13 01:58:54 +03:00
|
|
|
HAIKU_C++_HEADERS_DIR ?= ${haikuCxxHeadersDir} ;
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
HAIKU_BUILD_ATTRIBUTES_DIR ?= ${buildAttributesDir} ;
|
|
|
|
|
|
|
|
HAIKU_AR ?= ${HAIKU_AR} ;
|
|
|
|
HAIKU_CC ?= ${HAIKU_CC} ;
|
|
|
|
HAIKU_LD ?= ${HAIKU_LD} ;
|
|
|
|
HAIKU_OBJCOPY ?= ${HAIKU_OBJCOPY} ;
|
|
|
|
HAIKU_RANLIB ?= ${HAIKU_RANLIB} ;
|
|
|
|
HAIKU_CPPFLAGS ?= ${HAIKU_CPPFLAGS} ;
|
|
|
|
HAIKU_CCFLAGS ?= ${HAIKU_CCFLAGS} ;
|
|
|
|
HAIKU_CXXFLAGS ?= ${HAIKU_CXXFLAGS} ;
|
|
|
|
HAIKU_LDFLAGS ?= ${HAIKU_LDFLAGS} ;
|
|
|
|
HAIKU_ARFLAGS ?= ${HAIKU_ARFLAGS} ;
|
|
|
|
HAIKU_UNARFLAGS ?= ${HAIKU_UNARFLAGS} ;
|
|
|
|
|
2005-11-13 01:58:54 +03:00
|
|
|
HOST_GCC_RAW_VERSION ?= ${hostGCCVersion} ;
|
|
|
|
|
2002-07-16 03:42:06 +04:00
|
|
|
EOF
|
|
|
|
|
2005-01-26 04:34:37 +03:00
|
|
|
# Libgcc.a objects
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
cat << EOF > $buildOutputDir/libgccObjects
|
2005-01-26 04:34:37 +03:00
|
|
|
# libgcc.a objects to be linked against libroot.so
|
|
|
|
# Note: This file has been automatically generated by configure.
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
HAIKU_GCC_LIBGCC_OBJECTS ?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
|
2005-01-26 04:34:37 +03:00
|
|
|
EOF
|
|
|
|
|
2004-11-19 22:24:10 +03:00
|
|
|
# Generate Timezones binaries bindings
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
timezoneSources="africa antarctica asia australasia europe northamerica
|
|
|
|
southamerica pacificnew etcetera factory backward"
|
|
|
|
|
|
|
|
cat << EOF > $buildOutputDir/Timezones
|
2005-01-26 04:34:37 +03:00
|
|
|
# Timezones used for the build
|
|
|
|
# Note: This file has been automatically generated by configure.
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
HAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ;
|
|
|
|
|
2005-01-26 04:34:37 +03:00
|
|
|
EOF
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
for source in ${timezoneSources}; do
|
|
|
|
f=$sourceDir/src/data/etc/timezones/$source
|
2004-11-19 22:24:10 +03:00
|
|
|
|
2004-11-22 02:22:56 +03:00
|
|
|
TZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' $f `
|
2004-11-19 22:24:10 +03:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
cat << EOF >> $buildOutputDir/Timezones
|
|
|
|
TZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ;
|
2004-11-19 22:24:10 +03:00
|
|
|
EOF
|
|
|
|
done
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
# Generate a boot strap Jamfile in the output directory, if it is not in
|
|
|
|
# the source dir.
|
|
|
|
|
|
|
|
if [ "$currentDir" != "$sourceDir" ]; then
|
|
|
|
|
|
|
|
cat << EOF > $outputDir/Jamfile
|
|
|
|
# automatically generated Jamfile
|
|
|
|
|
|
|
|
HAIKU_TOP = ${sourceDir} ;
|
|
|
|
HAIKU_OUTPUT_DIR = ${outputDir} ;
|
|
|
|
|
|
|
|
include [ FDirName \$(HAIKU_TOP) Jamfile ] ;
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
fi
|
|
|
|
|