Don't map memory with PROT_EXEC for x86emu.
[v86d.git] / configure
blobcbbd6b38b40c9f31dd2ced90fa397beac3cff9c3
1 #!/bin/bash
3 # ./configure -- A very simple configure script for v86d.
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_debug=CONFIG_DEBUG
16 copt_debug_desc="Use additional debugging features"
17 copt_debug_type="bool"
18 copt_debug_def=n
20 copt_x86emu=CONFIG_X86EMU
21 copt_x86emu_desc="Use x86emu for BIOS calls"
22 copt_x86emu_type="bool"
23 copt_x86emu_def=auto
24 copt_x86emu_test()
26 local m=`uname -m`
27 if [ "$m" = "i686" -o "$m" = "i586" -o "$m" = "i486" -o "$m" = "i386" ]; then
28 echo "n";
29 elif [ "$m" = "x86_64" ]; then
30 echo "y";
31 else
32 echo "It looks like your architecture '$m' isn't supported by this version of v86d." >&2
33 exit 1
37 options=`set | grep '^copt_' | sed -re 's/copt_([^_=]+)[_=].*/\1/' | uniq`
39 write_conf()
41 echo -n > config.h
43 for i in ${options} ; do
44 eval vval=\$copt_$i\_val
45 eval vtype=\$copt_$i\_type
46 eval vname=\$copt_$i
48 if [[ "$vtype" == "bool" ]]; then
49 if [[ "$vval" == "y" ]]; then
50 echo "#define $vname" >> config.h
51 else
52 echo "#undef $vname" >> config.h
54 else
55 echo "#define $vname \"$vval\"" >> config.h
57 done
59 echo "config.h successfully created."
60 echo "You can run \`make\` now."
63 usage()
65 cat <<EOTB
66 v86d configuration script
68 Please use the following options to configure v86d.
69 EOTB
70 printf " %-20s %-s\n\n" --default "Use a default v86d configuration"
72 for i in ${options} ; do
73 eval vtype=\$copt_$i\_type
74 eval vdesc=\$copt_$i\_desc
75 eval vdef=\$copt_$i\_def
77 if [[ ${vtype} == "string" ]]; then
78 with="--with-${i}=VAL"
79 else
80 with="--with-${i}"
83 vdesc="${vdesc} (default: $vdef)"
85 printf " %-20s %-s\n" ${with} "${vdesc}"
86 done
89 if [[ $# == 0 ]]; then
90 usage
91 exit
94 for i in ${options} ; do
95 eval copt_${i}_val="\$copt_${i}_def"
96 if [ -n "$(set | grep copt_${i}_test)" ]; then
97 eval copt_${i}_val="\$(copt_${i}_test)"
99 done
101 for i in $* ; do
102 if [[ "$i" == "--help" ]]; then
103 usage
104 exit
105 elif [[ "$i" == "--default" ]]; then
106 write_conf
107 exit
110 j=${i//--with-}
111 if [[ "$j" != "$i" ]]; then
112 with=y
113 else
114 j=${i//--without-}
115 if [[ "$j" != "$i" ]]; then
116 with=n
117 else
118 usage
119 exit
123 optval=${j#*=}
124 optname=${j%=*}
126 eval t=\$copt_${optname}_val
127 if [[ "x$t" == "x" ]]; then
128 echo "Unrecognized setting ${optname}." 1>&2
129 exit
132 eval vtype=\$copt_${optname}_type
133 if [[ "$vtype" == "bool" ]]; then
134 eval copt_${optname}_val=${with}
135 else
136 eval copt_${optname}_val=${optval}
138 done
140 write_conf
141 exit