Annotation of prex-old/configure, Revision 1.3
1.1 nbrk 1: #! /bin/sh
2: #
3: # Prex configuration script
4: #
5:
6: quit()
7: {
8: cat >&2 <<ERRORMSG
9:
10: ERROR: $@
11: ERRORMSG
12: exit 1
13: }
14:
15: usage()
16: {
17: if [ -n "$*" ]; then
18: echo "configure: $*"
19: fi
20: cat <<USAGE
21:
22: Usage: configure [options]
23:
24: General options:
25: --target=TARGET target system
26: --cross-compile=PREFIX prefix for cros-compile tools
27: --no-debug disable all debug code
28:
29: Supported targets:
1.3 ! nbrk 30: i386-pc i386-nommu arm-gba arm-cats avr32-ngw100
1.1 nbrk 31: USAGE
32: exit 1
33: }
34:
35: setdefaults()
36: {
37: [ -d conf ] ||
38: quit "configure must be run from the top source level"
39:
40: target=""
41: cross=""
42: srcdir=`pwd`
43: }
44:
45: checkpath()
46: {
47: CONFIG_IN=$srcdir/conf/$arch/config.$arch-$platform
48: CMDBOX_IN=$srcdir/conf/etc/cmdbox.conf
49: CONFIG_MK=$srcdir/conf/config.mk
50: CONFIG_H=$srcdir/conf/config.h
51:
52: [ -f $CONFIG_IN ] ||
53: quit "can not find $CONFIG_IN"
54: }
55:
56: getoptions()
57: {
58: while [ $# != 0 ]; do
59: case $1 in
60: --*=*)
61: option=`expr "x$1" : 'x\([^=]*\)='`
62: optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
63: ;;
64: --*)
65: option=$1
66: ;;
67: *)
68: usage "unrecognized option $1"
69: ;;
70: esac
71:
72: case $option in
73: --help)
74: usage
75: ;;
76: --target)
77: target=$optarg
78: ;;
79: --cross-compile)
80: cross=$optarg
81: ;;
82: --no-debug)
83: nodebug=1
84: ;;
85: *)
86: usage "unrecognized option $1"
87: ;;
88: esac
89: shift
90: done
91: }
92:
93: gettarget()
94: {
95: if [ "x$target" = x ] ; then
96: echo "Warning: '--target' option was not specified"
97: echo "The target system was set to 'i386-pc'"
98: target="i386-pc"
99: fi
100:
101: arch=`expr "x$target" : 'x\([^=]*\)-'`
102: platform=`expr "x$target" : 'x[^=]*-\(.*\)'`
103:
104: case "$arch" in
1.2 nbrk 105: i386|arm|avr32|ppc|sh|mips)
1.1 nbrk 106: ;;
107: *)
108: quit "Unkown target architecture: $arch"
109: ;;
110: esac
111:
112: host_name=`uname -s`
113: case $host_name in
114: CYGWIN*)
115: case $arch in
116: i386) cross="i386-elf-" ;;
117: arm) cross="arm-elf-" ;;
1.2 nbrk 118: avr32) cross="avr32-" ;;
1.1 nbrk 119: ppc) cross="powerpc-eabi-" ;;
120: sh) cross="sh-elf-" ;;
121: mips) cross="mips-elf-" ;;
122: esac
123: ;;
124: esac
125: cc="${cross}gcc"
126: }
127:
128: setparm()
129: {
130: echo "$1=$2"
131: echo "$1=$2" >>$CONFIG_MK
132: if [ "$2" = "n" ] ; then
133: echo "#undef $1" >>$CONFIG_H
134: else
135: echo "#define $1 $2" >>$CONFIG_H
136: fi
137: }
138:
139: setgccoption()
140: {
141: if $cc $1 -S -xc /dev/null -o /dev/null > /dev/null 2>&1; then
142: echo "CONFIG_CFLAGS+= $1" >>$CONFIG_MK
143: fi
144: }
145:
146: parseconfig()
147: {
148: while read line; do
149: word=`expr "x$line" : 'x\(CONFIG_[A-Za-z0-9_=]*\)'`
150: param=`expr "x$word" : 'x\([^=]*\)='`
151: value=`expr "x$word" : 'x[^=]*=\([A-Za-z0-9]*\)'`
152: if [ -n "$param" ] ; then
153: setparm "$param" "$value"
154: fi
155: done < $1
156: echo "" >> $CONFIG_MK
157: }
158:
159: main()
160: {
161: setdefaults
162: getoptions "$@"
163: gettarget
164: checkpath
165:
166: echo "Processing configuration files..."
167:
168: echo "#" > $CONFIG_MK
169: echo "# Automatically generated file. Don't edit" >> $CONFIG_MK
170: echo "#" >> $CONFIG_MK
171:
172: echo "/*" > $CONFIG_H
173: echo " * Automatically generated file. Don't edit" >> $CONFIG_H
174: echo " */" >> $CONFIG_H
175:
176: #
177: # Generate configuration parameters
178: #
179: parseconfig $CONFIG_IN
180: parseconfig $CMDBOX_IN
181:
182: #
183: # Check arch/platform setting
184: #
185: echo "SRCDIR=$srcdir" >> $CONFIG_MK
186: echo "ARCH=$arch" >> $CONFIG_MK
187: echo "PLATFORM=$platform" >> $CONFIG_MK
188: [ "x$cross" != x ] && echo "CROSS_COMPILE=$cross" >> $CONFIG_MK
189: [ "x$nodebug" != x ] && echo "NDEBUG=1" >> $CONFIG_MK
190: echo "" >> $CONFIG_MK
191:
192: #
193: # Check gcc options
194: #
195: setgccoption "-fno-stack-protector"
196: setgccoption "-Wno-variadic-macros"
197: }
198:
199: main "$@"
CVSweb