- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / gonacl_appengine / src / smoothlife / build.sh
1 #!/bin/bash
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 set -o nounset
7 set -o errexit
8
9 SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
10 cd ${SCRIPT_DIR}
11
12 OUT_DIR=out
13 SMOOTHLIFE_URL=https://github.com/binji/smoothnacl
14 SMOOTHLIFE_DIR=${OUT_DIR}/smoothlife
15 SMOOTHLIFE_SHA=63f115f2393aa629aab1403948cbfb28acc54360
16
17 if [ -z "${NACL_SDK_ROOT:-}" ]; then
18   echo "-------------------------------------------------------------------"
19   echo "NACL_SDK_ROOT is unset."
20   echo "This environment variable needs to be pointed at some version of"
21   echo "the Native Client SDK (the directory containing toolchain/)."
22   echo "NOTE: set this to an absolute path."
23   echo "-------------------------------------------------------------------"
24   exit -1
25 fi
26
27 Banner() {
28   echo "######################################################################"
29   echo $*
30   echo "######################################################################"
31 }
32
33 # echo a command to stdout and then execute it.
34 LogExecute() {
35   echo $*
36   $*
37 }
38
39 Clone() {
40   local url=$1
41   local dir=$2
42   local sha=$3
43   if [ ! -d $dir ]; then
44     LogExecute git clone $url $dir
45   else
46     pushd $dir
47     LogExecute git fetch origin
48     popd
49   fi
50
51   pushd $dir
52   LogExecute git checkout $sha
53   popd
54 }
55
56 readonly OS_NAME=$(uname -s)
57 if [ $OS_NAME = "Darwin" ]; then
58   OS_JOBS=4
59 elif [ $OS_NAME = "Linux" ]; then
60   OS_JOBS=`nproc`
61 else
62   OS_JOBS=1
63 fi
64
65 Banner Cloning smoothlife
66 Clone ${SMOOTHLIFE_URL} ${SMOOTHLIFE_DIR} ${SMOOTHLIFE_SHA}
67
68 pushd ${SMOOTHLIFE_DIR}
69
70 Banner Updating submodules
71 LogExecute git submodule update --init
72
73 Banner Building FFTW
74 LogExecute make ports
75
76 Banner Building smoothlife
77 LogExecute make TOOLCHAIN=pnacl CONFIG=Release -j${OS_JOBS}
78
79 popd
80
81 LogExecute cp ${SMOOTHLIFE_DIR}/pnacl/Release/smoothnacl.{pexe,nmf} ${OUT_DIR}
82
83 Banner Done!