Fixed focal glibc build issues for ubuntu and windows
[sdk/emulator/qemu.git] / tizen / emulator_configure.sh
1 #!/bin/sh
2
3 CONFIGURE_APPEND=""
4 EMUL_TARGET_LIST="x86_64-softmmu"
5
6 usage() {
7     echo "usage: build.sh [options] [target]"
8     echo ""
9     echo "target"
10     echo "    emulator target, one of: [i386|x86_64|arm|all]. Defaults to \"x86_64\""
11     echo ""
12     echo "options:"
13     echo "-d, --debug"
14     echo "    build debug configuration"
15     echo "-e|--extra EXTRA"
16     echo "    extra options for QEMU configure"
17     echo "-p|--cross-prefix CROSS_PREFIX"
18     echo "    extra options for QEMU configure"
19     echo "-u|-h|--help|--usage"
20     echo "    display this help message and exit"
21 }
22
23 set_target() {
24   case "$1" in
25   i386)
26     EMUL_TARGET_LIST="i386-softmmu"
27   ;;
28   x86_64)
29     EMUL_TARGET_LIST="x86_64-softmmu"
30   ;;
31   arm)
32     EMUL_TARGET_LIST="arm-softmmu"
33   ;;
34   all)
35     EMUL_TARGET_LIST="i386-softmmu,x86_64-softmmu,arm-softmmu"
36   ;;
37   esac
38 }
39
40 while [ "$#" -gt "0" ]
41 do
42     case $1 in
43     i386|x86_64|arm|all)
44         set_target $1
45     ;;
46     -d|--debug)
47         CONFIGURE_APPEND="$CONFIGURE_APPEND --enable-debug"
48     ;;
49     -e|--extra)
50         shift
51         CONFIGURE_APPEND="$CONFIGURE_APPEND $1"
52     ;;
53     -p|--cross-prefix)
54         shift
55         CROSS_PREFIX="$1"
56     ;;
57     -u|-h|--help|--usage)
58         usage
59         exit 0
60     ;;
61     *)
62         echo "Syntax Error"
63         usage
64         exit 1
65     ;;
66     esac
67     shift
68 done
69
70 hostos=`uname -s`
71 if [ -z "$CROSS_PREFIX" ] ; then
72     targetos=$hostos
73 else
74     # FIXME
75     case "$CROSS_PREFIX" in
76     x86_64*)
77         targetos="CROSS_MINGW64";
78     ;;
79     *)
80         targetos="CROSS_MINGW32";
81     ;;
82     esac
83 fi
84
85 if [ -z "$TIZEN_SDK_DEV_PATH" ] ; then
86     TIZEN_SDK_DEV_PATH=${HOME}/tizen-sdk-dev
87 fi
88
89 if [ ! -z "$CROSS_PREFIX" ] ; then
90     if [ -d "$TIZEN_SDK_DEV_PATH/$CROSS_PREFIX" ] ; then
91         TIZEN_SDK_DEV_PATH=${TIZEN_SDK_DEV_PATH}/$CROSS_PREFIX
92     fi
93 fi
94
95 if [ -d "../.git" ] ; then
96     BRANCH=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
97     if [ -d "$TIZEN_SDK_DEV_PATH/$BRANCH" ] ; then
98         TIZEN_SDK_DEV_PATH="$TIZEN_SDK_DEV_PATH/$BRANCH"
99     fi
100 fi
101
102 if [ ! -z "$EXTRA_CFLAGS" ] ; then
103         CONFIGURE_APPEND="$CONFIGURE_APPEND --extra-cflags=$EXTRA_CFLAGS"
104 fi
105
106 if [ ! -z "$EXTRA_LDFLAGS" ] ; then
107         CONFIGURE_APPEND="$CONFIGURE_APPEND --extra-ldflags=$EXTRA_LDFLAGS"
108 fi
109
110 echo "##### checking for os... Host OS $hostos, Target OS $targetos"
111 echo "##### TIZEN_SDK_DEV_PATH: ${TIZEN_SDK_DEV_PATH}"
112 echo "$*"
113
114 # avoid pkg-config bug on Windows
115 if [ -z ${PKG_CONFIG_PATH} ] ; then
116 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/lib/pkgconfig
117 else
118 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}
119 fi
120
121 if [ -z ${PKG_CONFIG_LIBDIR} ] ; then
122     if [ ! -z "$CROSS_PREFIX" ] ; then
123         export PKG_CONFIG_LIBDIR=${TIZEN_SDK_DEV_PATH}/lib/pkgconfig
124     fi  
125 fi
126
127 # append common options
128 CONFIGURE_APPEND="
129  --target-list=$EMUL_TARGET_LIST
130  --disable-werror
131  --enable-maru
132  --enable-yagl
133  --enable-vigs
134  --enable-qt
135  --enable-libav
136  --enable-libpng
137  --enable-virtfs
138  --disable-bzip2
139  --disable-curl
140  --disable-lzo
141  --disable-snappy
142  --disable-gnutls
143  --disable-gcrypt
144  --disable-nettle
145  --disable-gtk
146  --disable-vte
147  --disable-vnc
148  --disable-spice
149  --disable-curses
150  --disable-xen
151  $CONFIGURE_APPEND"
152
153 CONFIGURE_APPEND_WIN="
154  --extra-ldflags=-static-libgcc
155  --extra-ldflags=-static-libstdc++
156  --audio-drv-list=dsound
157  --winver=0x0600
158  --enable-sdl
159  --with-sdlabi=2.0
160  --enable-hax"
161
162 # append platform specific options
163 case $targetos in
164 Linux*)
165 CONFIGURE_APPEND="
166  --extra-ldflags=-rdynamic
167  --extra-ldflags=-Wl,-rpath,'\$\$ORIGIN'
168  --audio-drv-list=alsa
169  --enable-sdl
170  --enable-kvm
171  $CONFIGURE_APPEND
172 "
173 ;;
174 CROSS_MINGW32*)
175 CONFIGURE_APPEND="
176  --cross-prefix=${CROSS_PREFIX}-
177  --extra-ldflags=-Wl,--large-address-aware
178  $CONFIGURE_APPEND_WIN
179  $CONFIGURE_APPEND
180 "
181 ;;
182 CROSS_MINGW64*)
183 CONFIGURE_APPEND="
184  --cross-prefix=${CROSS_PREFIX}-
185  $CONFIGURE_APPEND_WIN
186  $CONFIGURE_APPEND
187 "
188 ;;
189 MINGW*)
190 CONFIGURE_APPEND="
191  --cc=gcc
192  --cxx=g++
193  --extra-ldflags=-Wl,--large-address-aware
194  $CONFIGURE_APPEND_WIN
195  $CONFIGURE_APPEND
196 "
197 # Do not support building Win64 binary on Windows now
198 ;;
199 Darwin*)
200 CONFIGURE_APPEND="
201  --cc=clang
202  --cxx=clang++
203  --extra-cflags=-mmacosx-version-min=10.11
204  --extra-cflags=-Wno-error=deprecated-declarations
205  --extra-cflags=-Wno-error=address-of-packed-member
206  --extra-cflags=-Wno-error=logical-not-parentheses
207  --extra-cflags=-Wno-error=strict-prototypes 
208  --extra-ldflags=-Wl,-rpath,'@executable_path'
209  --extra-ldflags=-Wl,-no_weak_imports
210  --audio-drv-list=coreaudio
211  --enable-cocoa
212  --enable-hax
213  $CONFIGURE_APPEND
214 "
215 #--extra-ldflags=-rdynamic
216 # TODO: we need general GUI for MacOS
217 # we should use cocoa or sdl
218 ;;
219 esac
220
221 cd ..
222 echo ""
223 echo "##### QEMU configuring for emulator"
224 echo "##### QEMU configure append:" $CONFIGURE_APPEND
225 exec ./configure $CONFIGURE_APPEND