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