prex: cleanup configuration mecahnism changes introduced in 0.50
[prex.git] / configure
blobd3eb36455c9037b89f3ff2d2a6f5a02fb8f90cfd
1 #! /bin/sh
3 # Prex configuration script
6 [ ! -d conf ] && { echo "configure: must be run from the top source level"; exit 1; }
8 while [ $# != 0 ]
9 do
10 case $1 in
11 --*=*)
12 option=`expr "x$1" : 'x\([^=]*\)='`
13 optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
15 --*)
16 option=$1
19 echo "configure: unrecognized option $1"
20 exit 1
22 esac
24 case $option in
25 --help)
26 echo "Usage: configure [options]"
27 echo " General options:"
28 echo " --target=TARGET target system"
29 echo " --cross-compile=PREFIX prefix for cros-compile tools"
30 echo " --no-debug disable all debug code"
31 echo " Supported targets:"
32 echo " i386-pc i386-nommu arm-gba"
33 exit 0
35 --target)
36 target=$optarg ;;
37 --cross-compile)
38 cross=$optarg ;;
39 --no-debug)
40 nodebug=1 ;;
42 echo "configure: unrecognized option $1"
43 exit 1
44 ;;
45 esac
46 shift
47 done
49 default_target=0
50 if [ "x$target" = x ] ; then
51 target="i386-pc"
52 default_target=1
55 srcdir=`pwd`
57 arch=`expr "x$target" : 'x\([^=]*\)-'`
58 platform=`expr "x$target" : 'x[^=]*-\(.*\)'`
60 host_name=`uname -s`
61 case $host_name in
62 CYGWIN*)
63 if [ x$cross = x ]; then
64 case $arch in
65 i386) cross="i386-elf-" ;;
66 arm) cross="arm-elf-" ;;
67 powerpc) cross="powerpc-eabi-" ;;
68 sh) cross="sh-elf-" ;;
69 mips) cross="mips-elf-" ;;
70 esac
73 esac
75 CONFIG_IN=$srcdir/conf/config.$arch-$platform
76 CONFIG_MK=$srcdir/conf/config.mk
77 CONFIG_H=$srcdir/conf/config.h
79 [ ! -f $CONFIG_IN ] && { echo "configure: can not find conf/config.$arch-$platform"; exit 1; }
81 echo "Processing configuration file..."
83 echo "#" > $CONFIG_MK
84 echo "# Automatically generated from $CONFIG_IN." >> $CONFIG_MK
85 echo "# Don't edit!" >> $CONFIG_MK
86 echo "#" >> $CONFIG_MK
88 echo "/*" > $CONFIG_H
89 echo " * Automatically generated from $CONFIG_IN." >> $CONFIG_H
90 echo " * Don't edit!" >> $CONFIG_H
91 echo " */" >> $CONFIG_H
93 echo "PREX_SRC=$srcdir" >> $CONFIG_MK
94 echo "PREX_ARCH=$arch" >> $CONFIG_MK
95 echo "PREX_PLATFORM=$platform" >> $CONFIG_MK
96 [ "x$cross" != x ] && echo "CROSS_COMPILE=$cross" >> $CONFIG_MK
97 [ "x$nodebug" != x ] && echo "NDEBUG=1" >> $CONFIG_MK
99 echo "" >> $CONFIG_MK
101 while read line
103 word=`expr "x$line" : 'x\(CONFIG_[A-Za-z0-9_]*=[^ ]*\)'`
104 param=`expr "x$word" : 'x\([^=]*\)='`
105 value=`expr "x$word" : 'x[^=]*=\(.*\)'`
106 if [ -n "$param" ] ; then
107 echo "$word"
108 echo "export $word" >> $CONFIG_MK
109 if [ "$value" = "n" ] ; then
110 echo "#undef $param" >> $CONFIG_H
111 else
112 echo "#define $param $value" >> $CONFIG_H
115 done < $CONFIG_IN
117 if [ $default_target = 1 ]; then
118 echo
119 echo "Warning: '--target' option was not specified."
120 echo "The target system was set to 'i386-pc' as default."
121 echo
124 exit 0