Formatting fixes for testvbe info display.
[v86d.git] / configure
blob6f201d70cb13a2daa1d5743eb041f7661d988353
1 #!/bin/bash
3 # ./configure -- A very simple configure script for splashutils.
5 # (c) 2006-2007, Michal Januszewski <spock@gentoo.org>
7 # In time, it will be replaced by a fully-fledged version.
10 copt_klibc=CONFIG_KLIBC
11 copt_klibc_desc="Link statically against klibc"
12 copt_klibc_type="bool"
13 copt_klibc_def=n
15 copt_x86emu=CONFIG_X86EMU
16 copt_x86emu_desc="Use x86emu for BIOS calls"
17 copt_x86emu_type="bool"
18 copt_x86emu_def=auto
19 copt_x86emu_test()
21 local m=`uname -m`
22 if [ "$m" = "i686" -o "$m" = "i586" -o "$m" = "i486" -o "$m" = "i386" ]; then
23 echo "n";
24 elif [ "$m" = "x86_64" ]; then
25 echo "y";
26 else
27 echo "It looks like your architecture '$m' isn't supported by this version of v86d." >&2
28 exit 1
32 options=`set | grep '^copt_' | sed -re 's/copt_([^_=]+)[_=].*/\1/' | uniq`
34 write_conf()
36 echo -n > config.h
38 for i in ${options} ; do
39 eval vval=\$copt_$i\_val
40 eval vtype=\$copt_$i\_type
41 eval vname=\$copt_$i
43 if [[ "$vtype" == "bool" ]]; then
44 if [[ "$vval" == "y" ]]; then
45 echo "#define $vname" >> config.h
46 else
47 echo "#undef $vname" >> config.h
49 else
50 echo "#define $vname \"$vval\"" >> config.h
52 done
54 echo "config.h successfully created."
55 echo "You can run \`make\` now."
58 usage()
60 cat <<EOTB
61 v86d configuration script
63 Please use the following options to configure v86d.
64 EOTB
65 printf " %-20s %-s\n\n" --default "Use a default v86d configuration"
67 for i in ${options} ; do
68 eval vtype=\$copt_$i\_type
69 eval vdesc=\$copt_$i\_desc
70 eval vdef=\$copt_$i\_def
72 if [[ ${vtype} == "string" ]]; then
73 with="--with-${i}=VAL"
74 else
75 with="--with-${i}"
78 vdesc="${vdesc} (default: $vdef)"
80 printf " %-20s %-s\n" ${with} "${vdesc}"
81 done
84 if [[ $# == 0 ]]; then
85 usage
86 exit
89 for i in ${options} ; do
90 eval copt_${i}_val="\$copt_${i}_def"
91 if [ -n "$(set | grep copt_${i}_test)" ]; then
92 eval copt_${i}_val="\$(copt_${i}_test)"
94 done
96 for i in $* ; do
97 if [[ "$i" == "--help" ]]; then
98 usage
99 exit
100 elif [[ "$i" == "--default" ]]; then
101 write_conf
102 exit
105 j=${i//--with-}
106 if [[ "$j" != "$i" ]]; then
107 with=y
108 else
109 j=${i//--without-}
110 if [[ "$j" != "$i" ]]; then
111 with=n
112 else
113 usage
114 exit
118 optval=${j#*=}
119 optname=${j%=*}
121 eval t=\$copt_${optname}_val
122 if [[ "x$t" == "x" ]]; then
123 echo "Unrecognized setting ${optname}." 1>&2
124 exit
127 eval vtype=\$copt_${optname}_type
128 if [[ "$vtype" == "bool" ]]; then
129 eval copt_${optname}_val=${with}
130 else
131 eval copt_${optname}_val=${optval}
133 done
135 write_conf
136 exit