Merge "hax: modify some codes for QEMU 2.0" into tizen_qemu_2.0
[sdk/emulator/qemu.git] / tizen / emulator_configure.sh
1 #!/bin/sh
2
3 if [ -z "$TIZEN_SDK_DEV_PATH" ] ; then
4         TIZEN_SDK_DEV_PATH=${HOME}/tizen-sdk-dev
5 fi
6
7 CONFIGURE_APPEND=""
8 EMUL_TARGET_LIST=""
9 VIRTIOGL_EN=""
10 YAGL_EN=""
11 YAGL_STATS_EN=""
12 VIGS_EN=""
13
14 usage() {
15     echo "usage: build.sh [options] [target]"
16     echo ""
17     echo "target"
18     echo "    emulator target, one of: [x86|i386|i486|i586|i686|arm|all]. Defaults to \"all\""
19     echo ""
20     echo "options:"
21     echo "-d, --debug"
22     echo "    build debug configuration"
23     echo "-vgl|--virtio-gl"
24     echo "    enable virtio GL support"
25     echo "-yagl|--yagl-device"
26     echo "    enable YaGL passthrough device"
27     echo "-ys|--yagl-stats"
28     echo "    enable YaGL stats"
29     echo "-vigs|--vigs-device"
30     echo "    enable VIGS device"
31     echo "-e|--extra"
32     echo "    extra options for QEMU configure"
33     echo "-u|-h|--help|--usage"
34     echo "    display this help message and exit"
35 }
36
37 virtgl_enable() {
38   case "$1" in
39   0|no|disable)
40     VIRTIOGL_EN="no"
41   ;;
42   1|yes|enable)
43     VIRTIOGL_EN="yes"
44   ;;
45   *)
46     usage
47     exit 1
48   ;;
49   esac
50 }
51
52 yagl_enable() {
53   case "$1" in
54   0|no|disable)
55     YAGL_EN="no"
56   ;;
57   1|yes|enable)
58     YAGL_EN="yes"
59   ;;
60   *)
61     usage
62     exit 1
63   ;;
64   esac
65 }
66
67 yagl_stats_enable() {
68   case "$1" in
69   0|no|disable)
70     YAGL_STATS_EN="no"
71   ;;
72   1|yes|enable)
73     YAGL_STATS_EN="yes"
74   ;;
75   *)
76     usage
77     exit 1
78   ;;
79   esac
80 }
81
82 vigs_enable() {
83   case "$1" in
84   0|no|disable)
85     VIGS_EN="no"
86   ;;
87   1|yes|enable)
88     VIGS_EN="yes"
89   ;;
90   *)
91     usage
92     exit 1
93   ;;
94   esac
95 }
96
97 set_target() {
98   if [ ! -z "$EMUL_TARGET_LIST" ] ; then
99       usage
100       exit 1
101   fi
102
103   case "$1" in
104   x86|i386|i486|i586|i686)
105     EMUL_TARGET_LIST="i386-softmmu"
106     if [ -z "$VIRTIOGL_EN" ] ; then
107       virtgl_enable yes
108     fi
109     if [ -z "$YAGL_EN" ] ; then
110       yagl_enable yes
111     fi
112     if [ -z "$VIGS_EN" ] ; then
113       vigs_enable yes
114     fi
115   ;;
116   arm)
117     EMUL_TARGET_LIST="arm-softmmu"
118     if [ -z "$YAGL_EN" ] && [ "$targetos" != "Darwin" ] ; then
119       yagl_enable yes
120     fi
121     if [ -z "$VIGS_EN" ] && [ "$targetos" != "Darwin" ] ; then
122       vigs_enable yes
123     fi
124   ;;
125   all)
126 #    EMUL_TARGET_LIST="i386-softmmu,arm-softmmu"
127     EMUL_TARGET_LIST="i386-softmmu"
128     if [ -z "$VIRTIOGL_EN" ] ; then
129       virtgl_enable yes
130     fi
131     if [ -z "$YAGL_EN" ] ; then   
132         yagl_enable yes
133     fi
134     if [ -z "$VIGS_EN" ] ; then
135       vigs_enable yes
136     fi
137   ;;
138   esac
139 }
140
141
142 # OS specific
143 targetos=`uname -s`
144 echo "##### checking for os... targetos $targetos"
145
146 echo "##### TIZEN_SDK_DEV_PATH: ${TIZEN_SDK_DEV_PATH}"
147
148 echo "$*"
149
150 while [ "$#" -gt "0" ]
151 do
152     case $1 in
153     x86|i386|i486|i586|i686|arm|all)
154         set_target $1
155     ;;
156     -d|--debug)
157         CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-debug"
158     ;;
159     -e|--extra)
160         shift
161         CONFIGURE_APPEND="$CONFIGURE_APPEND $1"
162     ;;
163     -vgl|--virtio-gl)
164         virtgl_enable 1
165     ;;
166     -yagl|--yagl-device)
167         yagl_enable 1
168     ;;
169     -ys|--yagl-stats)
170         yagl_stats_enable 1
171     ;;
172     -vigs|--vigs-device)
173         vigs_enable 1
174     ;;
175     -u|-h|--help|--usage)
176         usage
177         exit 0
178     ;;
179     *)
180         echo "Syntax Error"
181         usage
182         exit 1
183     ;;
184     esac
185     shift
186 done
187
188 if [ -z "$EMUL_TARGET_LIST" ] ; then
189   set_target all
190 fi
191
192 CONFIGURE_APPEND="--target-list=$EMUL_TARGET_LIST $CONFIGURE_APPEND"
193
194 if test "$VIRTIOGL_EN" = "yes" ; then
195   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-gl"
196 else
197   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-gl"
198 fi
199
200 if test "$YAGL_EN" = "yes" ; then
201   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-yagl"
202 else
203   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-yagl"
204 fi
205
206 if test "$YAGL_STATS_EN" = "yes" ; then
207   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-yagl-stats"
208 else
209   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-yagl-stats"
210 fi
211
212 if test "$VIGS_EN" = "yes" ; then
213   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-vigs"
214 else
215   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-vigs"
216 fi
217
218 # append common flags
219 CONFIGURE_APPEND="--enable-maru --enable-libav --enable-curl --disable-gtk $CONFIGURE_APPEND"
220
221 if [ -z ${PKG_CONFIG_PATH} ] ; then     # avoid pkg-config bug on Windows
222 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/distrib/lib/pkgconfig
223 else
224 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/distrib/lib/pkgconfig:${PKG_CONFIG_PATH}
225 fi
226
227 case $targetos in
228 Linux*)
229 cd ..
230 echo ""
231 echo "##### QEMU configuring for emulator"
232 echo "##### QEMU configure append:" $CONFIGURE_APPEND
233 exec ./configure \
234  --enable-werror \
235  --audio-drv-list=alsa \
236  --disable-vnc \
237  --disable-pie \
238  --enable-virtfs \
239  --disable-xen \
240  --enable-png \
241  $CONFIGURE_APPEND \
242 ;;
243 MINGW*)
244 cd ..
245 echo ""
246 echo "##### QEMU configuring for emulator"
247 echo "##### QEMU configure append:" $CONFIGURE_APPEND
248 exec ./configure \
249  --extra-ldflags=-Wl,--large-address-aware \
250  --cc=gcc \
251  --audio-drv-list=winwave \
252  --enable-hax \
253  --disable-vnc \
254  --enable-png \
255  $CONFIGURE_APPEND \
256 ;;
257 Darwin*)
258 cd ..
259 echo ""
260 echo "##### QEMU configuring for emulator"
261 echo "##### QEMU configure append:" $CONFIGURE_APPEND
262 ./configure \
263  --extra-cflags=-mmacosx-version-min=10.4 \
264  --audio-drv-list=coreaudio \
265  --enable-shm \
266  --enable-hax \
267  --disable-vnc \
268  --disable-cocoa \
269  --disable-sdl \
270  $CONFIGURE_APPEND \
271 ;;
272 esac