build: clean up build related files
[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 "$*"
147
148 while [ "$#" -gt "0" ]
149 do
150     case $1 in
151     x86|i386|i486|i586|i686|arm|all)
152         set_target $1
153     ;;
154     -d|--debug)
155         CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-debug"
156     ;;
157     -e|--extra)
158         shift
159         CONFIGURE_APPEND="$CONFIGURE_APPEND $1"
160     ;;
161     -vgl|--virtio-gl)
162         virtgl_enable 1
163     ;;
164     -yagl|--yagl-device)
165         yagl_enable 1
166     ;;
167     -ys|--yagl-stats)
168         yagl_stats_enable 1
169     ;;
170     -vigs|--vigs-device)
171         vigs_enable 1
172     ;;
173     -u|-h|--help|--usage)
174         usage
175         exit 0
176     ;;
177     *)
178         echo "Syntax Error"
179         usage
180         exit 1
181     ;;
182     esac
183     shift
184 done
185
186 if [ -z "$EMUL_TARGET_LIST" ] ; then
187   set_target all
188 fi
189
190 CONFIGURE_APPEND="--target-list=$EMUL_TARGET_LIST $CONFIGURE_APPEND"
191
192 if test "$VIRTIOGL_EN" = "yes" ; then
193   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-gl"
194 else
195   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-gl"
196 fi
197
198 if test "$YAGL_EN" = "yes" ; then
199   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-yagl"
200 else
201   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-yagl"
202 fi
203
204 if test "$YAGL_STATS_EN" = "yes" ; then
205   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-yagl-stats"
206 else
207   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-yagl-stats"
208 fi
209
210 if test "$VIGS_EN" = "yes" ; then
211   CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-vigs"
212 else
213   CONFIGURE_APPEND="$CONFIGURE_APPEND --disable-vigs"
214 fi
215
216 # append common flags
217 CONFIGURE_APPEND="--enable-maru --enable-libav $CONFIGURE_APPEND"
218
219 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/distrib/lib/pkgconfig:${PKG_CONFIG_PATH}
220
221 case $targetos in
222 Linux*)
223 cd ..
224 echo ""
225 echo "##### QEMU configuring for emulator"
226 echo "##### QEMU configure append:" $CONFIGURE_APPEND
227 exec ./configure \
228  --enable-werror \
229  --audio-drv-list=alsa \
230  --disable-vnc \
231  --disable-pie \
232  --enable-virtfs \
233  --disable-xen \
234  $CONFIGURE_APPEND \
235 ;;
236 MINGW*)
237 cd ..
238 echo ""
239 echo "##### QEMU configuring for emulator"
240 echo "##### QEMU configure append:" $CONFIGURE_APPEND
241 # We add CFLAGS '-fno-omit-frame-pointer'.
242 # A GCC might have a bug related with omitting frame pointer. It generates weird instructions.
243 exec ./configure \
244  --extra-cflags=-fno-omit-frame-pointer \
245  --extra-ldflags=-Wl,--large-address-aware \
246  --cc=gcc \
247  --audio-drv-list=winwave \
248  --enable-hax \
249  --disable-vnc \
250  $CONFIGURE_APPEND \
251 ;;
252 Darwin*)
253 cd ..
254 echo ""
255 echo "##### QEMU configuring for emulator"
256 echo "##### QEMU configure append:" $CONFIGURE_APPEND
257 ./configure \
258  --extra-cflags=-mmacosx-version-min=10.4 \
259  --audio-drv-list=coreaudio \
260  --enable-shm \
261  --enable-hax \
262  --disable-vnc \
263  --disable-cocoa \
264  --disable-sdl \
265  $CONFIGURE_APPEND \
266 ;;
267 esac