2 # Copyright 2008, Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #@ usage: xaos_tool.sh <mode>
36 #@ this script bootstraps a nacl module for the xaos fractal rendering
37 #@ engine off the web including the gsl package it depends on.
39 #@ This works on linux only, assumes you have web access
40 #@ and that you have the typical linux tools installed
45 readonly SAVE_PWD
=$
(pwd)
47 readonly DIR_TMP
=${DIR_TMP:-/tmp/nacl}
48 readonly DIR_INSTALL
=${DIR_INSTALL:-/tmp/nacl}
49 readonly OS_NAME
=$
(uname
-s)
50 if [ $OS_NAME = "Darwin" ]; then
51 readonly OS_SUBDIR
="mac"
52 elif [ $OS_NAME = "Linux" ]; then
53 readonly OS_SUBDIR
="linux"
55 readonly OS_SUBDIR
="windows"
57 readonly NACL_SDK_BASE
=${SAVE_PWD}/..
/..
/..
/third_party
/nacl_sdk
/$OS_SUBDIR/sdk
/nacl-sdk
/
60 readonly URL_XAOS
=http
://downloads.sourceforge.net
/xaos
/XaoS-3.4.
tar.gz
61 readonly URL_GSL
=http
://ftp.gnu.org
/pub
/gnu
/gsl
/gsl-1.9.
tar.gz
63 readonly PATCH_GSL
=${SAVE_PWD}/gsl-1.9.
patch
64 readonly PATCH_XAOS
=${SAVE_PWD}/XaoS-3.4.
patch
67 # TODO: the dimensions need a little bit of more work in the xaos patch
68 readonly NACL_DIM_W
=800
69 readonly NACL_DIM_H
=600
70 readonly NACLCC
=${NACL_SDK_BASE}/bin
/nacl-gcc
71 readonly NACLAR
=${NACL_SDK_BASE}/bin
/nacl-ar
72 readonly NACLRANLIB
=${NACL_SDK_BASE}/bin
/nacl-ranlib
73 readonly DIR_AV_LIB
=${NACL_SDK_BASE}/nacl
/lib
74 readonly DIR_AV_INCLUDE
=${NACL_SDK_BASE}/nacl
/include
77 ######################################################################
79 ######################################################################
82 echo "######################################################################"
84 echo "######################################################################"
89 egrep "^#@" $0 | cut
--bytes=3-
101 elif which curl
; then
102 curl
--location --url $1 -o $2
104 Banner
"Problem encountered"
105 echo "Please install curl or wget and rerun this script"
106 echo "or manually download $1 to $2"
108 echo "press any key when done"
112 if [ ! -s $2 ] ; then
113 echo "ERROR: could not find $2"
120 Banner
"downloading gsl"
123 Banner
"untaring and patching gsl"
130 # params (tmp, install)
132 Banner
"configuring gsl"
136 export RANLIB
=${NACLRANLIB}
137 export LIBS
="-lm -lsrpc"
141 ..
/gsl-1.9
/configure\
145 Banner
"building and installing gsl"
150 # params (tmp, url, patch)
152 Banner
"downloading xaos"
157 Banner
"untaring, patching and autoconfing xaos"
163 # params (tmp, install)
165 Banner
"configuring xaos"
167 export PATH
="$2/bin:${PATH}"
170 export RANLIB
=${NACLRANLIB}
171 export LDFLAGS
="-static"
172 export CFLAGS
="-DNACL_DIM_H=${NACL_DIM_H} -DNACL_DIM_W=${NACL_DIM_W} -I${DIR_AV_INCLUDE}"
173 export LIBS
="-L${DIR_AV_LIB} -lav -lsrpc -lpthread"
175 # sadly xaos seem wants to be built in-place
176 cp -r XaoS-3.4 xaos-build
178 ..
/XaoS-3.4
/configure\
183 Banner
"building and installing xaos"
187 ######################################################################
188 # Parse the mode and extract the needed arguments
189 ######################################################################
190 if [ $# -eq 0 ] ; then
191 echo "no mode specified"
202 #@ Prints help for all modes.
203 if [ ${MODE} = 'help' ] ; then
212 if [ ${MODE} = 'download_gsl' ] ; then
214 DownloadGsl
${DIR_TMP} ${URL_GSL} ${PATCH_GSL}
222 if [ ${MODE} = 'build_gsl' ] ; then
223 BuildGsl
${DIR_TMP} ${DIR_INSTALL}
231 if [ ${MODE} = 'download_xaos' ] ; then
233 DownloadXaos
${DIR_TMP} ${URL_XAOS} ${PATCH_XAOS}
241 if [ ${MODE} = 'build_xaos' ] ; then
242 BuildXaos
${DIR_TMP} ${DIR_INSTALL}
250 if [ ${MODE} = 'all' ] ; then
252 DownloadGsl
${DIR_TMP} ${URL_GSL} ${PATCH_GSL}
253 BuildGsl
${DIR_TMP} ${DIR_INSTALL}
254 DownloadXaos
${DIR_TMP} ${URL_XAOS} ${PATCH_XAOS}
255 BuildXaos
${DIR_TMP} ${DIR_INSTALL}
257 Banner
"Copying relevant files into this directory"
258 cp ${DIR_TMP}/xaos-build
/bin
/xaos
${SAVE_PWD}/xaos.nexe
259 cp ${DIR_TMP}/xaos-build
/help
/xaos.hlp
${SAVE_PWD}/
261 Banner
"To view the demo"
263 echo "either point your browser at"
265 echo "http://localhost:5103/tests/xaos/xaos.html"
267 echo "after running tools/httpd.py while in the native_client directory"
270 echo "../../scons-out/opt-linux/staging/sel_ldr ./xaos.nexe"
275 ######################################################################
276 # Mode is not handled
277 ######################################################################
279 echo "unknown mode: ${MODE}"