1#!/bin/sh 2# 3# configure [ --floppy <floppy location> ] 4 5target=unknown 6 7# usage 8# 9# Prints usage. 10# 11usage() 12{ 13 cat << EOF 14 15Usage: $0 <options> 16options: 17 --floppy <floppy location> Specifies the location of the floppy 18 (device or image). 19 --bochs-debug Activates bochs serial debug emulation. 20 --target=TARGET Select build target platform. [default=${target}] 21 valid targets=r5,bone,dano,haiku 22 --include-gpl-addons Include GPL licensed add-ons. 23 --help Prints out this help. 24EOF 25} 26 27# assertparam 28# 29# Checks whether at least one parameter is left. 30# 31assertparam() 32{ 33 if [ $2 \< 2 ]; then 34 echo $0: \`$1\': Parameter expected. 35 exit 1 36 fi 37} 38 39# standard_gcc_settings 40# 41# Sets the variables for a GCC platform. 42# 43standard_gcc_settings() 44{ 45 # PLATFORM_LINKLIBS 46 gcclib=`gcc -print-libgcc-file-name` 47 gccdir=`dirname ${gcclib}` 48 gcc_version=`gcc -dumpversion` 49 if [ "x${PLATFORM_LINKLIBS}" == "x" ] ; then 50 PLATFORM_LINKLIBS="-L ${gccdir} -lgcc" 51 fi 52 if [ "x${PLATFORM_HEADERS}" == "x" ] ; then 53 PLATFORM_HEADERS="${gccdir}/include" 54 fi 55 if [ "${LIBGCC_DIR}" == "" ] ; then 56 LIBGCC_DIR="${gccdir}" 57 fi 58 if [ "${LIBGCC_OBJECTS}" == "" ] ; then 59 LIBGCC_OBJECTS=`ar t ${gccdir}/libgcc.a` 60 fi 61} 62 63# default parameter values 64# 65platform=`uname` 66gcc_version= 67floppy= 68bochs_debug=0 69include_gpl_addons=0 70revision=`uname -r` 71case "$revision" in 72 5.1) target=dano ;; 73 5.0.4) target=bone ;; 74 5.0*) target=r5 ;; 75 *) target="$platform" ;; 76esac 77 78# parse parameters 79# 80while [ $# \> 0 ] ; do 81 case "$1" in 82 --include-gpl-addons) include_gpl_addons=1; shift 1;; 83 --floppy) assertparam "$1" $#; floppy=$2; shift 2;; 84 --bochs-debug) bochs_debug=1; shift 1;; 85 --target=*) target=`echo $1 | cut -d'=' -f2-`; shift 1;; 86 --help | -h) usage; exit 0;; 87 *) echo Invalid argument: \`$1\'; exit 1;; 88 esac 89done 90 91# check parameters 92# 93if [ -n "$floppy" ]; then 94 case "$floppy" in 95 /*) ;; 96 *) echo "Warning: non-absolute floppy path. Parameter ignored."; 97 floppy=;; 98 esac 99fi 100 101# BeOS 102if [ "${platform}" = "BeOS" ] ; then 103 standard_gcc_settings 104 105# Linux 106else if [ "${platform}" = "Linux" ] ; then 107 standard_gcc_settings 108 109# Unknown platform 110else 111 echo Unsupported platform: ${platform} 112 exit 1 113fi; fi 114 115# Generate BuildConfig 116cat << EOF > build/BuildConfig 117# BuildConfig 118# Note: This file has been automatically generated by configure. 119 120FLOPPY_PATH ?= "${floppy}" ; 121PLATFORM_LINKLIBS ?= ${PLATFORM_LINKLIBS} ; 122PLATFORM_HEADERS ?= ${PLATFORM_HEADERS} ; 123GCC_RAW_VERSION ?= ${gcc_version} ; 124LIBGCC_DIR ?= ${LIBGCC_DIR} ; 125LIBGCC_OBJECTS ?= ${LIBGCC_OBJECTS} ; 126BOCHS_DEBUG_HACK ?= ${bochs_debug} ; 127INCLUDE_GPL_ADDONS ?= ${include_gpl_addons} ; 128TARGET_PLATFORM ?= ${target} ; 129EOF 130 131# Generate Timezones binaries bindings 132 133timezones=`echo src/data/etc/timezones/* | sed -e s@src/data/etc/timezones/CVS@@` 134for f in ${timezones}; 135do 136 137TZOBJECTS=`gawk '/^Zone/ { print $2 } /^Link/ { print $3 } ' $f ` 138 139cat << EOF >> build/BuildConfig 140TZ_OBJECTS on <src!data!etc!timezones>${f##src/data/etc/timezones/} ?= $TZOBJECTS ; 141EOF 142done 143