initial version
[android_pandora.git] / pvr / gfx_rel_es2.x_android / install.sh
1 #!/bin/sh
2
3 # PowerVR SGX DDK for Embedded Linux - installation script
4 #
5 # Copyright     2004-2006 by Imagination Technologies Limited.
6 #                               All rights reserved.  No part of this software, either
7 #                               material or conceptual may be copied or distributed,
8 #                               transmitted, transcribed, stored in a retrieval system
9 #                               or translated into any human or computer language in any
10 #                               form by any means, electronic, mechanical, manual or
11 #                               other-wise, or disclosed to third parties without the
12 #                               express written permission of Imagination Technologies
13 #                               Limited, Unit 8, HomePark Industrial Estate,
14 #                               King's Langley, Hertfordshire, WD4 8LZ, U.K.
15
16 # Auto-generated for omap3430_android from embedded.pj 1.5.15.2766
17 #
18
19 # PVR Consumer services version number
20 #
21 PVRVERSION=1.5.15.2766
22
23 # Where we record what we did so we can undo it.
24 #
25 DDK_INSTALL_LOG=/powervr_ddk_install.log
26
27 # basic installation function
28 # $1=blurb
29 #
30 bail()
31 {
32     echo "$1" >&2
33     echo "" >&2
34     echo "Installation failed" >&2
35     exit 1
36 }
37
38 # basic installation function
39 # $1=fromfile, $2=destfilename, $3=blurb $4=chmod-flags
40 #
41 install_file()
42 {
43         DESTFILE=${DISCIMAGE}$2
44         DESTDIR=`dirname $DESTFILE`
45
46         if [ ! -e $1 ]; then
47                         [ -n "$VERBOSE" ] && echo "skipping file $1 -> $2"
48                  return
49         fi
50         
51         # Destination directory - make sure it's there and writable
52         #
53         if [ -d "${DESTDIR}" ]; then
54                 if [ ! -w "${DESTDIR}" ]; then
55                         bail "${DESTDIR} is not writable."
56                 fi
57         else
58                 $DOIT mkdir -p ${DESTDIR} || bail "Couldn't mkdir -p ${DESTDIR}"
59                 [ -n "$VERBOSE" ] && echo "Created directory `dirname $2`"
60         fi
61
62         # If it already exists then back it up if there isn't a back-up already.
63         #
64         #if [ -f $DESTFILE ]; then
65         #       if [ ! -f ${DESTFILE}.old ]; then
66         #               $DOIT mv $DESTFILE ${DESTFILE}.old ||
67         #                               bail "Couldn't back up $DESTFILE";
68         #               [ -n "$VERBOSE" ] && echo "Backed up $DESTFILE";
69         #       fi
70         #fi
71
72         # Delete the original so that permissions don't persist.
73         #
74         $DOIT rm -f $DESTFILE
75
76         $DOIT cp -f $1 $DESTFILE || bail "Couldn't copy $1 to $DESTFILE"
77         $DOIT chmod 644 ${DESTFILE}
78         if [ "$4" ]; then
79                 $DOIT chmod $4 ${DESTFILE};
80         fi
81         echo "$3 `basename $1` -> $2"
82         $DOIT echo "file $2" >>${DISCIMAGE}${DDK_INSTALL_LOG}
83 }
84
85 # Install a symbolic link
86 # $1=fromfile, $2=destfilename
87 #
88 install_link()
89 {
90         DESTFILE=${DISCIMAGE}$2
91         DESTDIR=`dirname $DESTFILE`
92
93         if [ ! -e ${DESTDIR}/$1 ]; then
94                  [ -n "$VERBOSE" ] && echo $DOIT "skipping link ${DESTDIR}/$1"
95                  return
96         fi
97
98         # Destination directory - make sure it's there and writable
99         #
100         if [ -d "${DESTDIR}" ]; then
101                 if [ ! -w "${DESTDIR}" ]; then
102                         bail "${DESTDIR} is not writable."
103                 fi
104         else
105                 $DOIT mkdir -p ${DESTDIR} || bail "Couldn't mkdir -p ${DESTDIR}"
106                 [ -n "$VERBOSE" ] && echo "Created directory `dirname $2`"
107         fi
108
109         # Delete the original so that permissions don't persist.
110         #
111         $DOIT rm -f $DESTFILE
112
113         $DOIT ln -s $1 $DESTFILE || bail "Couldn't link $1 to $DESTFILE"
114         $DOIT echo "link $2" >>${DISCIMAGE}${DDK_INSTALL_LOG}
115         [ -n "$VERBOSE" ] && echo " linked `basename $1` -> $2"
116 }
117
118 # Tree-based installation function
119 # $1 = fromdir $2=destdir $3=blurb
120 #
121 install_tree()
122 {
123         # Make the destination directory if it's not there
124         #
125         if [ ! -d ${DISCIMAGE}$2 ]; then
126                 $DOIT mkdir -p ${DISCIMAGE}$2 || bail "Couldn't mkdir -p ${DISCIMAGE}$2"
127         fi
128         if [ "$DONTDOIT" ]; then
129                 echo "### tar -C $1 -cf - . | tar -C ${DISCIMAGE}$2 -x${VERBOSE}f -" 
130         else
131                 tar -C $1 -cf - . | tar -C ${DISCIMAGE}$2 -x${VERBOSE}f -
132         fi
133         if [ $? = 0 ]; then
134                 echo "Installed $3 in ${DISCIMAGE}$2"
135                 $DOIT echo "tree $2" >>${DISCIMAGE}${DDK_INSTALL_LOG}
136         else
137                 echo "Failed copying $3 from $1 to ${DISCIMAGE}$2"
138         fi
139 }
140
141 # Uninstall something.
142 #
143 uninstall()
144 {
145         if [ ! -f ${DISCIMAGE}${DDK_INSTALL_LOG} ]; then
146                 echo "Nothing to un-install."
147                 return;
148         fi
149
150         BAD=0
151         VERSION=""
152         while read type data; do
153                 case $type in
154                 version)        # do nothing
155                         echo "Uninstalling existing version $data"
156                         VERSION="$data"
157                         ;;
158                 link|file) 
159                         if [ -z "$VERSION" ]; then
160                                 BAD=1;
161                                 echo "No version record at head of ${DISCIMAGE}${DDK_INSTALL_LOG}"
162                         elif ! $DOIT rm -f ${DISCIMAGE}${data}; then
163                                 BAD=1;
164                         else
165                                 [ -n "$VERBOSE" ] && echo "Deleted $type $data"
166                         fi
167                         ;;
168                 tree)           # so far, do nothing
169                         ;;
170                 esac
171         done < ${DISCIMAGE}${DDK_INSTALL_LOG};
172
173         if [ $BAD = 0 ]; then
174                 echo "Uninstallation completed."
175                 $DOIT rm -f ${DISCIMAGE}${DDK_INSTALL_LOG}
176         else
177                 echo "Uninstallation failed!!!"
178         fi
179 }
180
181 # Help on how to invoke
182 #
183 usage()
184 {
185         echo "usage: $0 [options...]"
186         echo ""
187         echo "Options: -v            verbose mode"
188         echo "         -n            dry-run mode"
189         echo "         -u            uninstall-only mode"
190         echo "         --no-pvr      don't install PowerVR driver components"
191         echo "         --no-x        don't install X window system"
192         echo "         --no-display  don't install integrated PowerVR display module"
193         echo "         --no-bcdevice don't install buffer class device module"
194         echo "         --root path   use path as the root of the install file system"
195         exit 1
196 }
197
198 install_pvr()
199 {
200         $DOIT echo "version 1.5.15.2766" >${DISCIMAGE}${DDK_INSTALL_LOG}
201         # Install the standard scripts
202         #
203         install_file rc.pvr /system/bin/sgx/rc.pvr "boot script" a+x
204
205         # Check the kernel module directory is there
206         #
207         if [ ! -d "${DISCIMAGE}" ]; then
208                 echo ""
209                 echo "Can't find  on file system installation root"
210                 echo -n "There is no kernel module area setup yet. "
211                 if [ "$from" = target ]; then
212                         echo "On your build machine you should invoke:"
213                         echo
214                         echo " $ cd \$KERNELDIR"
215                         echo " $ make INSTALL_MOD_PATH=\$DISCIMAGE modules_install"
216                 else
217                         echo "You should invoke:"
218                         echo
219                         echo " $ cd $KERNELDIR"
220                         echo " $ make INSTALL_MOD_PATH=$DISCIMAGE modules_install"
221                 fi
222                 echo
223                 exit 1;
224         fi
225
226         # Install the standard kernel modules
227         # Touch some files that might not exist so that busybox/modprobe don't complain
228         #
229                 install_file pvrsrvkm.ko /system/bin/sgx/pvrsrvkm.ko "kernel module"
230
231
232
233 if [ -z "$NO_DISPLAYMOD" ]; then
234                 install_file omaplfb.ko /system/bin/sgx/omaplfb.ko "kernel module"
235
236 fi
237
238 if [ -z "$NO_BCDEVICE" ]; then
239                 install_file bc_example.ko /system/bin/sgx/bc_example.ko "kernel module"
240
241 fi
242
243 #       $DOIT touch ${DISCIMAGE}/lib/modules/modprobe.conf
244 #       $DOIT touch ${DISCIMAGE}/etc/modules.conf
245 #       $DOIT rm -f /tmp/modules.$$.tmp
246
247         # Install the standard libraries
248         #
249
250         install_file libGLESv1_CM_POWERVR_SGX530_121.so /system/lib/egl/libGLESv1_CM_POWERVR_SGX530_121.so.1.1.15.2766 "shared library"
251         install_link libGLESv1_CM_POWERVR_SGX530_121.so.1.1.15.2766 /system/lib/egl/libGLESv1_CM_POWERVR_SGX530_121.so
252
253         install_file libGLESv2_POWERVR_SGX530_121.so /system/lib/egl/libGLESv2_POWERVR_SGX530_121.so.1.1.15.2766 "shared library"
254         install_link libGLESv2_POWERVR_SGX530_121.so.1.1.15.2766 /system/lib/egl/libGLESv2_POWERVR_SGX530_121.so
255
256         install_file libglslcompiler.so /system/lib/libglslcompiler.so.1.1.15.2766 "shared library"
257         install_link libglslcompiler.so.1.1.15.2766 /system/lib/libglslcompiler.so
258
259
260         install_file libIMGegl.so /system/lib/libIMGegl.so.1.1.15.2766 "shared library"
261         install_link libIMGegl.so.1.1.15.2766 /system/lib/libIMGegl.so
262         install_file libEGL_POWERVR_SGX530_121.so /system/lib/egl/libEGL_POWERVR_SGX530_121.so.1.1.15.2766 "shared library"
263         install_link libEGL_POWERVR_SGX530_121.so.1.1.15.2766 /system/lib/egl/libEGL_POWERVR_SGX530_121.so
264         install_file libpvr2d.so /system/lib/libpvr2d.so.1.1.15.2766 "shared library"
265         install_link libpvr2d.so.1.1.15.2766 /system/lib/libpvr2d.so
266
267
268
269         install_file libsrv_um.so /system/lib/libsrv_um.so.1.1.15.2766 "shared library"
270         install_link libsrv_um.so.1.1.15.2766 /system/lib/libsrv_um.so
271         install_file libPVRScopeServices.so /system/lib/libPVRScopeServices.so.1.1.15.2766 "shared library"
272         install_link libPVRScopeServices.so.1.1.15.2766 /system/lib/libPVRScopeServices.so
273
274
275
276         install_file gralloc.omap3.so /system/lib/hw/gralloc.omap3.so.1.1.15.2766 "shared library"
277         install_link gralloc.omap3.so.1.1.15.2766 /system/lib/hw/gralloc.omap3.so
278
279         install_file libfakehal.so /system/lib/libfakehal.so.1.1.15.2766 "shared library"
280         install_link libfakehal.so.1.1.15.2766 /system/lib/libfakehal.so
281
282         install_file libpvrANDROID_WSEGL.so /system/lib/libpvrANDROID_WSEGL.so.1.1.15.2766 "shared library"
283         install_link libpvrANDROID_WSEGL.so.1.1.15.2766 /system/lib/libpvrANDROID_WSEGL.so
284
285         install_file libsfutil.so /system/lib/libsfutil.so.1.1.15.2766 "shared library"
286         install_link libsfutil.so.1.1.15.2766 /system/lib/libsfutil.so
287
288
289         # Install the standard executables
290         #
291
292         install_file pvrsrvinit /system/bin/pvrsrvinit "binary" a+x
293         install_file sgx_init_test /system/bin/sgx_init_test "binary" a+x
294
295
296
297         # Install the standard unittests
298         #
299         install_file gles2test1 /system/bin/gles2test1 "binary" a+x
300         install_file glsltest1_vertshader.txt /system/bin/glsltest1_vertshader.txt "shader" a+x
301         install_file glsltest1_fragshaderA.txt /system/bin/glsltest1_fragshaderA.txt "shader" a+x
302         install_file glsltest1_fragshaderB.txt /system/bin/glsltest1_fragshaderB.txt "shader" a+x
303         install_file gles2_texture_stream /system/bin/gles2_texture_stream "binary" a+x
304
305         install_file gles1test1 /system/bin/gles1test1 "binary" a+x
306         install_file gles1_texture_stream /system/bin/gles1_texture_stream "binary" a+x
307
308         install_file services_test /system/bin/services_test "binary" a+x
309         install_file sgx_blit_test /system/bin/sgx_blit_test "binary" a+x
310         install_file sgx_flip_test /system/bin/sgx_flip_test "binary" a+x
311         install_file sgx_render_flip_test /system/bin/sgx_render_flip_test "binary" a+x
312         install_file pvr2d_test /system/bin/pvr2d_test "binary" a+x
313         install_file eglinfo /system/bin/eglinfo "binary" a+x
314 ##GLESUNITTEST(egl_test)dnl
315 ##GLES2UNITTEST(gl2info)dnl
316 ##ifelse(SUPPORT_PVR2D,1,[[UNITTEST(pvr2dtest)]])dnl
317 ##ifdef([[_BUFFER_CLASS_DEVICE_]],
318 ##      if [ -z "$NO_BCDEVICE" ]; then
319 ##      UNITTEST(sw_camera_ctrl)dnl
320 ##      UNITTEST(ogles_camera_ext)dnl
321 ##fi)
322
323         install_file hal_client_test /system/bin/hal_client_test "binary" a+x
324         install_file hal_server_test /system/bin/hal_server_test "binary" a+x
325         install_file framebuffer_test /system/bin/framebuffer_test "binary" a+x
326         install_file texture_benchmark /system/bin/texture_benchmark "binary" a+x
327         install_file xmultiegltest /system/bin/xmultiegltest "binary" a+x
328         VENDOR_LIB_NAME=`echo libEGL_POWERVR_SGX530_121.so | sed 's,libEGL_\|\.so,,g'`
329         $DOIT cat >${DISCIMAGE}/system/lib/egl/egl.cfg <<EOF
330 0 0 android
331 0 1 ${VENDOR_LIB_NAME}
332 EOF
333         $DOIT echo "file /system/lib/egl/egl.cfg" >>${DISCIMAGE}${DDK_INSTALL_LOG}
334 }
335
336
337 # Work out if there are any special instructions.
338 #
339 while [ "$1" ]; do
340         case "$1" in
341         -v|--verbose)
342                 VERBOSE=v;
343                 ;;
344         -r|--root)
345                 DISCIMAGE=$2;
346                 shift; shift;
347                 ;;
348         -u|--uninstall)
349                 UNINSTALL=y
350                 ;;
351         -n)     DOIT=echo
352                 ;;
353         --no-pvr)
354                 NO_PVR=y
355                 ;;
356         --no-x)
357                 NO_X=y
358                 ;;
359         --no-display)
360                 NO_DISPLAYMOD=y
361                 ;;
362         --no-bcdevice)
363                 NO_BCDEVICE=y
364                 ;;
365         -h | --help | *)        
366                 usage
367                 ;;
368         esac
369         shift
370 done
371
372 # Find out where we are?  On the target?  On the host?
373 #
374 case `uname -m` in
375 arm*)   host=0;
376                 from=target;
377                 DISCIMAGE=/;
378                 ;;
379 sh*)    host=0;
380                 from=target;
381                 DISCIMAGE=/;
382                 ;;
383 i?86*)  host=1;
384                 from=host;
385                 if [ -z "$DISCIMAGE" ]; then    
386                         echo "DISCIMAGE must be set for installation to be possible." >&2
387                         exit 1
388                 fi
389                 ;;
390 x86_64*)        host=1;
391                 from=host;
392                 if [ -z "$DISCIMAGE" ]; then    
393                         echo "DISCIMAGE must be set for installation to be possible." >&2
394                         exit 1
395                 fi
396                 ;;
397 *)              echo "Don't know host to perform on machine type `uname -m`" >&2;
398                 exit 1
399                 ;;
400 esac
401
402 if [ ! -d "$DISCIMAGE" ]; then
403         echo "$0: $DISCIMAGE does not exist." >&2
404         exit 1
405 fi
406
407 echo
408 echo "Installing PowerVR Consumer/Embedded DDK 1.5.15.2766 on $from"
409 echo
410 echo "File system installation root is $DISCIMAGE"
411 echo
412
413 # Uninstall whatever's there already.
414 #
415 uninstall
416 [ -n "$UNINSTALL" ] && exit
417
418 #  Now start installing things we want.
419 #
420 [ -z "$NO_PVR" ] && install_pvr
421
422 # All done...
423 #
424 echo 
425 echo "Installation complete!"
426 if [ "$host" = 0 ]; then
427    echo "You may now reboot your target."
428 fi
429 echo