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: 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). 19338b8dc3SIngo Weinhold --cross-tools-prefix <prefix> 20338b8dc3SIngo Weinhold Assume cross compilation. <prefix> should be a 21338b8dc3SIngo Weinhold path to the directory where the cross 22338b8dc3SIngo Weinhold compilation tools are located, plus the platform 23338b8dc3SIngo Weinhold prefix, e.g. "/path/to/tools/i586-pc-beos-". 24338b8dc3SIngo Weinhold This overrides the HAIKU_* tool variables. 25338b8dc3SIngo Weinhold --build-cross-tools <build tools dir> 26338b8dc3SIngo Weinhold Assume cross compilation. <build tools dir> 27338b8dc3SIngo Weinhold defines the location of the build tools sources. 28338b8dc3SIngo Weinhold They will be compiled and placed in the output 29338b8dc3SIngo Weinhold directory under "cross-tools". The HAIKU_* tools 30338b8dc3SIngo 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. 35338b8dc3SIngo Weinhold 36338b8dc3SIngo Weinholdenvironment variables: 37338b8dc3SIngo Weinhold HAIKU_AR The static library archiver. Defaults to "ar". 38338b8dc3SIngo Weinhold HAIKU_CC The compiler. Defaults to "gcc". 39338b8dc3SIngo Weinhold HAIKU_LD The linker. Defaults to "ld". 40338b8dc3SIngo Weinhold HAIKU_OBJCOPY The objcopy to be used. Defaults to "objcopy". 41338b8dc3SIngo Weinhold HAIKU_RANLIB The static library indexer. Defaults to "ranlib". 42338b8dc3SIngo Weinhold HAIKU_CPPFLAGS The preprocessor flags. Defaults to "". 43338b8dc3SIngo Weinhold HAIKU_CCFLAGS The C flags. Defaults to "". 44338b8dc3SIngo Weinhold HAIKU_CXXFLAGS The C++ flags. Defaults to "". 45338b8dc3SIngo Weinhold HAIKU_LDFLAGS The linker flags. Defaults to "". 46338b8dc3SIngo Weinhold HAIKU_ARFLAGS The flags passed to HAIKU_AR for archiving. 47338b8dc3SIngo Weinhold Defaults to "ru". 48338b8dc3SIngo Weinhold HAIKU_UNARFLAGS The flags passed to HAIKU_AR for unarchiving. 49338b8dc3SIngo 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 72338b8dc3SIngo Weinhold gcclib=`$HAIKU_CC -print-libgcc-file-name` 7309c5682dSIngo Weinhold gccdir=`dirname ${gcclib}` 74338b8dc3SIngo Weinhold haikuGCCVersion=`$HAIKU_CC -dumpversion` 75338b8dc3SIngo Weinhold haikuGCCMachine=`$HAIKU_CC -dumpmachine` 76338b8dc3SIngo Weinhold 77338b8dc3SIngo Weinhold HAIKU_GCC_LIB_DIR=${gccdir} 78338b8dc3SIngo Weinhold HAIKU_GCC_LIBGCC=${gccdir}/libgcc.a 79338b8dc3SIngo Weinhold HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o" 80338b8dc3SIngo Weinhold HAIKU_GCC_HEADERS_DIR=${gccdir}/include 81338b8dc3SIngo Weinhold HAIKU_GCC_LIBGCC_OBJECTS=`ar t ${HAIKU_GCC_LIBGCC}` 82*8b5934c9SIngo Weinhold 83*8b5934c9SIngo Weinhold # for gcc 4 we use the libstdc++ that comes with the compiler 84*8b5934c9SIngo Weinhold case $haikuGCCVersion in 85*8b5934c9SIngo Weinhold 4.*) 86*8b5934c9SIngo Weinhold haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a` 87*8b5934c9SIngo Weinhold haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so` 88*8b5934c9SIngo Weinhold local headers=$gccdir/../../../../include/c++/$haikuGCCVersion 89*8b5934c9SIngo Weinhold haikuCxxHeadersDir=$headers 90*8b5934c9SIngo Weinhold for d in $haikuGCCMachine backward ext debug; do 91*8b5934c9SIngo Weinhold haikuCxxHeadersDir="$haikuCxxHeadersDir $headers/$d" 92*8b5934c9SIngo Weinhold done 93*8b5934c9SIngo Weinhold 94*8b5934c9SIngo Weinhold if [ $haikuStaticLibStdCxx = libstdc++.a ]; then 95*8b5934c9SIngo Weinhold haikuStaticLibStdCxx= 96*8b5934c9SIngo Weinhold fi 97*8b5934c9SIngo Weinhold if [ $haikuSharedLibStdCxx = libstdc++.so ]; then 98*8b5934c9SIngo Weinhold haikuSharedLibStdCxx= 99*8b5934c9SIngo Weinhold fi 100*8b5934c9SIngo Weinhold ;; 101*8b5934c9SIngo Weinhold esac 10209c5682dSIngo Weinhold} 10309c5682dSIngo Weinhold 104338b8dc3SIngo Weinhold# set_default_value 105338b8dc3SIngo Weinhold# 106338b8dc3SIngo Weinhold# Set the value for a variable, if no value is set yet. 107338b8dc3SIngo Weinhold# 108338b8dc3SIngo Weinholdset_default_value() 109338b8dc3SIngo Weinhold{ 110338b8dc3SIngo Weinhold local var=$1; 111338b8dc3SIngo Weinhold # any better way? 112338b8dc3SIngo Weinhold (set -u; (eval "echo \${$var}") &> /dev/null) || eval "$var=$2" 113338b8dc3SIngo Weinhold} 114338b8dc3SIngo Weinhold 115338b8dc3SIngo Weinhold# get_build_tool_path 116338b8dc3SIngo Weinhold# 117338b8dc3SIngo Weinhold# Gets a usable absolute path of a build tool. 118338b8dc3SIngo Weinhold# 119338b8dc3SIngo Weinholdget_build_tool_path() 120338b8dc3SIngo Weinhold{ 121338b8dc3SIngo Weinhold local var="HAIKU_$1" 122338b8dc3SIngo Weinhold local tool=$2 123338b8dc3SIngo Weinhold local path="${crossToolsPrefix}$tool" 124338b8dc3SIngo Weinhold 125338b8dc3SIngo Weinhold if [ -f "$path" ]; then 126338b8dc3SIngo Weinhold # get absolute path 127338b8dc3SIngo Weinhold local oldPwd=$(pwd) 128338b8dc3SIngo Weinhold cd $(dirname "$path") 129338b8dc3SIngo Weinhold path="$(pwd)/$(basename "$path")" 130338b8dc3SIngo Weinhold cd $oldPwd 131338b8dc3SIngo Weinhold else 132338b8dc3SIngo Weinhold which "$path" &> /dev/null || { 133338b8dc3SIngo Weinhold echo "Build tool \"$path\" not found." >&2 134338b8dc3SIngo Weinhold exit 1 135338b8dc3SIngo Weinhold } 136338b8dc3SIngo Weinhold fi 137338b8dc3SIngo Weinhold 138338b8dc3SIngo Weinhold eval "$var=$path" 139338b8dc3SIngo Weinhold} 140338b8dc3SIngo Weinhold 141338b8dc3SIngo Weinhold# get cwd and the source directory 142338b8dc3SIngo WeinholdcurrentDir=`pwd` 143338b8dc3SIngo Weinholdcd `dirname $0` 144338b8dc3SIngo WeinholdsourceDir=`pwd` 145338b8dc3SIngo Weinholdcd $currentDir 146338b8dc3SIngo Weinhold 147022fa244SIngo Weinhold# default parameter values 148022fa244SIngo Weinhold# 14952a38012Sejakowatzplatform=`uname` 150338b8dc3SIngo WeinholdhaikuGCCVersion= 151*8b5934c9SIngo WeinholdhaikuStaticLibStdCxx= 152*8b5934c9SIngo WeinholdhaikuSharedLibStdCxx= 153*8b5934c9SIngo WeinholdhaikuCxxHeadersDir= 154*8b5934c9SIngo WeinholdhostGCCVersion=`cc -dumpversion` 155022fa244SIngo Weinholdfloppy= 1562b94bc7bSlillobochs_debug=0 157e91f3ca1Sbeveloperinclude_gpl_addons=0 15862339647SAxel Dörflertarget=haiku 159338b8dc3SIngo WeinholdcrossToolsPrefix= 160338b8dc3SIngo WeinholdbuildCrossTools= 161338b8dc3SIngo Weinhold 162338b8dc3SIngo Weinholdset_default_value HAIKU_AR ar 163338b8dc3SIngo Weinholdset_default_value HAIKU_CC gcc 164338b8dc3SIngo Weinholdset_default_value HAIKU_LD ld 165338b8dc3SIngo Weinholdset_default_value HAIKU_OBJCOPY objcopy 166338b8dc3SIngo Weinholdset_default_value HAIKU_RANLIB ranlib 167338b8dc3SIngo Weinholdset_default_value HAIKU_CPPFLAGS "" 168338b8dc3SIngo Weinholdset_default_value HAIKU_CCFLAGS "" 169338b8dc3SIngo Weinholdset_default_value HAIKU_CXXFLAGS "" 170338b8dc3SIngo Weinholdset_default_value HAIKU_LDFLAGS "" 171338b8dc3SIngo Weinholdset_default_value HAIKU_ARFLAGS ru 172338b8dc3SIngo Weinholdset_default_value HAIKU_UNARFLAGS x 17362339647SAxel Dörfler 174022fa244SIngo Weinhold# parse parameters 175022fa244SIngo Weinhold# 176022fa244SIngo Weinholdwhile [ $# \> 0 ] ; do 177022fa244SIngo Weinhold case "$1" in 178e91f3ca1Sbeveloper --include-gpl-addons) include_gpl_addons=1; shift 1;; 179022fa244SIngo Weinhold --floppy) assertparam "$1" $#; floppy=$2; shift 2;; 1802b94bc7bSlillo --bochs-debug) bochs_debug=1; shift 1;; 1817c8bb86fSIngo Weinhold --target=*) target=`echo $1 | cut -d'=' -f2-`; shift 1;; 182338b8dc3SIngo Weinhold --cross-tools-prefix) assertparam "$1" $#; crossToolsPrefix=$2; shift 2;; 183338b8dc3SIngo Weinhold --build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;; 184022fa244SIngo Weinhold --help | -h) usage; exit 0;; 185022fa244SIngo Weinhold *) echo Invalid argument: \`$1\'; exit 1;; 186022fa244SIngo Weinhold esac 187022fa244SIngo Weinholddone 188022fa244SIngo Weinhold 189022fa244SIngo Weinhold# check parameters 190022fa244SIngo Weinhold# 191022fa244SIngo Weinholdif [ -n "$floppy" ]; then 192022fa244SIngo Weinhold case "$floppy" in 193022fa244SIngo Weinhold /*) ;; 194022fa244SIngo Weinhold *) echo "Warning: non-absolute floppy path. Parameter ignored."; 195022fa244SIngo Weinhold floppy=;; 196022fa244SIngo Weinhold esac 197022fa244SIngo Weinholdfi 19852a38012Sejakowatz 1990df3cc9cSIngo Weinhold# detect the build platform 200338b8dc3SIngo Weinholdcase "${platform}" in 2010df3cc9cSIngo Weinhold BeOS) revision=`uname -r` 2020df3cc9cSIngo Weinhold case "$revision" in 20314998c8bSIngo Weinhold 6.*) buildPlatform=dano ;; 2040df3cc9cSIngo Weinhold 5.1) buildPlatform=dano ;; 2050df3cc9cSIngo Weinhold 5.0.4) buildPlatform=bone ;; 2060df3cc9cSIngo Weinhold 5.0*) buildPlatform=r5 ;; 2070df3cc9cSIngo Weinhold *) echo Unknown BeOS version: $revision 2080df3cc9cSIngo Weinhold exit 1 ;; 2090df3cc9cSIngo Weinhold esac 2100df3cc9cSIngo Weinhold ;; 211338b8dc3SIngo Weinhold Linux) buildPlatform=linux ;; 212338b8dc3SIngo Weinhold *) echo Unsupported platform: ${platform} 2134cbe4925SAxel Dörfler exit 1 ;; 2144cbe4925SAxel Dörfleresac 21552a38012Sejakowatz 216338b8dc3SIngo Weinhold# create output directory 217338b8dc3SIngo Weinholdif [ "$currentDir" = "$sourceDir" ]; then 218338b8dc3SIngo Weinhold outputDir=$currentDir/generated 219338b8dc3SIngo Weinholdelse 220338b8dc3SIngo Weinhold outputDir=$currentDir 221338b8dc3SIngo Weinholdfi 222338b8dc3SIngo WeinholdbuildOutputDir=$outputDir/build 223338b8dc3SIngo WeinholdbuildAttributesDir=$outputDir/attributes 224338b8dc3SIngo Weinholdmkdir -p $buildOutputDir || exit 1 225338b8dc3SIngo Weinhold 226338b8dc3SIngo Weinhold# build cross tools from sources 227338b8dc3SIngo Weinholdif [ -n "$buildCrossTools" ]; then 228338b8dc3SIngo Weinhold "$sourceDir/build/scripts/build_cross_tools" "$sourceDir" \ 229338b8dc3SIngo Weinhold "$buildCrossTools" || exit 1 230338b8dc3SIngo Weinhold crossToolsPrefix=$outputDir/cross-tools/bin/i586-pc-beos- 231338b8dc3SIngo Weinholdfi 232338b8dc3SIngo Weinhold 233338b8dc3SIngo Weinhold# cross tools 234338b8dc3SIngo Weinholdif [ -n "$crossToolsPrefix" ]; then 235338b8dc3SIngo Weinhold get_build_tool_path AR ar 236338b8dc3SIngo Weinhold get_build_tool_path CC gcc 237338b8dc3SIngo Weinhold get_build_tool_path LD ld 238338b8dc3SIngo Weinhold get_build_tool_path OBJCOPY objcopy 239338b8dc3SIngo Weinhold get_build_tool_path RANLIB ranlib 240338b8dc3SIngo Weinholdfi 241338b8dc3SIngo Weinhold 242338b8dc3SIngo Weinhold# prepare gcc settings 243338b8dc3SIngo Weinholdstandard_gcc_settings 244338b8dc3SIngo Weinhold 24552a38012Sejakowatz# Generate BuildConfig 246338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/BuildConfig 24752a38012Sejakowatz# BuildConfig 24852a38012Sejakowatz# Note: This file has been automatically generated by configure. 24952a38012Sejakowatz 25009c5682dSIngo WeinholdFLOPPY_PATH ?= "${floppy}" ; 25109c5682dSIngo WeinholdBOCHS_DEBUG_HACK ?= ${bochs_debug} ; 252e91f3ca1SbeveloperINCLUDE_GPL_ADDONS ?= ${include_gpl_addons} ; 253614026d7SshattyTARGET_PLATFORM ?= ${target} ; 254338b8dc3SIngo WeinholdHOST_PLATFORM ?= ${buildPlatform} ; 255338b8dc3SIngo Weinhold 256338b8dc3SIngo WeinholdHAIKU_GCC_RAW_VERSION ?= ${haikuGCCVersion} ; 257338b8dc3SIngo WeinholdHAIKU_GCC_MACHINE ?= ${haikuGCCMachine} ; 258338b8dc3SIngo WeinholdHAIKU_GCC_LIB_DIR ?= ${HAIKU_GCC_LIB_DIR} ; 259338b8dc3SIngo WeinholdHAIKU_GCC_HEADERS_DIR ?= ${HAIKU_GCC_HEADERS_DIR} ; 260338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC ?= ${HAIKU_GCC_LIBGCC} ; 261338b8dc3SIngo Weinhold 262*8b5934c9SIngo WeinholdHAIKU_STATIC_LIBSTDC++ ?= ${haikuStaticLibStdCxx} ; 263*8b5934c9SIngo WeinholdHAIKU_SHARED_LIBSTDC++ ?= ${haikuSharedLibStdCxx} ; 264*8b5934c9SIngo WeinholdHAIKU_C++_HEADERS_DIR ?= ${haikuCxxHeadersDir} ; 265*8b5934c9SIngo Weinhold 266338b8dc3SIngo WeinholdHAIKU_BUILD_ATTRIBUTES_DIR ?= ${buildAttributesDir} ; 267338b8dc3SIngo Weinhold 268338b8dc3SIngo WeinholdHAIKU_AR ?= ${HAIKU_AR} ; 269338b8dc3SIngo WeinholdHAIKU_CC ?= ${HAIKU_CC} ; 270338b8dc3SIngo WeinholdHAIKU_LD ?= ${HAIKU_LD} ; 271338b8dc3SIngo WeinholdHAIKU_OBJCOPY ?= ${HAIKU_OBJCOPY} ; 272338b8dc3SIngo WeinholdHAIKU_RANLIB ?= ${HAIKU_RANLIB} ; 273338b8dc3SIngo WeinholdHAIKU_CPPFLAGS ?= ${HAIKU_CPPFLAGS} ; 274338b8dc3SIngo WeinholdHAIKU_CCFLAGS ?= ${HAIKU_CCFLAGS} ; 275338b8dc3SIngo WeinholdHAIKU_CXXFLAGS ?= ${HAIKU_CXXFLAGS} ; 276338b8dc3SIngo WeinholdHAIKU_LDFLAGS ?= ${HAIKU_LDFLAGS} ; 277338b8dc3SIngo WeinholdHAIKU_ARFLAGS ?= ${HAIKU_ARFLAGS} ; 278338b8dc3SIngo WeinholdHAIKU_UNARFLAGS ?= ${HAIKU_UNARFLAGS} ; 279338b8dc3SIngo Weinhold 280*8b5934c9SIngo WeinholdHOST_GCC_RAW_VERSION ?= ${hostGCCVersion} ; 281*8b5934c9SIngo Weinhold 282c4786ea6SlilloEOF 283c4786ea6Slillo 284b1e5b60cSAxel Dörfler# Libgcc.a objects 285b1e5b60cSAxel Dörfler 286338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/libgccObjects 287b1e5b60cSAxel Dörfler# libgcc.a objects to be linked against libroot.so 288b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure. 289b1e5b60cSAxel Dörfler 290338b8dc3SIngo WeinholdHAIKU_GCC_LIBGCC_OBJECTS ?= ${HAIKU_GCC_LIBGCC_OBJECTS} ; 291b1e5b60cSAxel DörflerEOF 292b1e5b60cSAxel Dörfler 2934c74bde8SJérôme Duval# Generate Timezones binaries bindings 2944c74bde8SJérôme Duval 295338b8dc3SIngo WeinholdtimezoneSources="africa antarctica asia australasia europe northamerica 296338b8dc3SIngo Weinhold southamerica pacificnew etcetera factory backward" 297338b8dc3SIngo Weinhold 298338b8dc3SIngo Weinholdcat << EOF > $buildOutputDir/Timezones 299b1e5b60cSAxel Dörfler# Timezones used for the build 300b1e5b60cSAxel Dörfler# Note: This file has been automatically generated by configure. 301b1e5b60cSAxel Dörfler 302338b8dc3SIngo WeinholdHAIKU_TIME_ZONE_SOURCES = ${timezoneSources} ; 303338b8dc3SIngo Weinhold 304b1e5b60cSAxel DörflerEOF 305b1e5b60cSAxel Dörfler 306338b8dc3SIngo Weinholdfor source in ${timezoneSources}; do 307338b8dc3SIngo Weinhold f=$sourceDir/src/data/etc/timezones/$source 3084c74bde8SJérôme Duval 309d2ab012dSJérôme DuvalTZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' $f ` 3104c74bde8SJérôme Duval 311338b8dc3SIngo Weinholdcat << EOF >> $buildOutputDir/Timezones 312338b8dc3SIngo WeinholdTZ_OBJECTS on <timezone-source>${source} ?= $TZOBJECTS ; 3134c74bde8SJérôme DuvalEOF 3144c74bde8SJérôme Duvaldone 315338b8dc3SIngo Weinhold 316338b8dc3SIngo Weinhold# Generate a boot strap Jamfile in the output directory, if it is not in 317338b8dc3SIngo Weinhold# the source dir. 318338b8dc3SIngo Weinhold 319338b8dc3SIngo Weinholdif [ "$currentDir" != "$sourceDir" ]; then 320338b8dc3SIngo Weinhold 321338b8dc3SIngo Weinholdcat << EOF > $outputDir/Jamfile 322338b8dc3SIngo Weinhold# automatically generated Jamfile 323338b8dc3SIngo Weinhold 324338b8dc3SIngo WeinholdHAIKU_TOP = ${sourceDir} ; 325338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR = ${outputDir} ; 326338b8dc3SIngo Weinhold 327338b8dc3SIngo Weinholdinclude [ FDirName \$(HAIKU_TOP) Jamfile ] ; 328338b8dc3SIngo Weinhold 329338b8dc3SIngo WeinholdEOF 330338b8dc3SIngo Weinhold 331338b8dc3SIngo Weinholdfi 332338b8dc3SIngo Weinhold 333