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