1010MODULES=$MODULES
1111
1212# Paths
13- ROOT_PATH=" $( dirname $( readlink -f $0 ) ) "
13+ ROOT_PATH=" $( dirname $( python -c ' import os,sys;print os.path.realpath(sys.argv[1]) ' $0 ) ) "
1414RECIPES_PATH=" $ROOT_PATH /recipes"
1515BUILD_PATH=" $ROOT_PATH /build"
1616LIBS_PATH=" $ROOT_PATH /build/libs"
@@ -23,6 +23,10 @@ DIST_PATH="$ROOT_PATH/dist/default"
2323export LIBLINK_PATH=" $BUILD_PATH /objects"
2424export LIBLINK=" $ROOT_PATH /src/tools/liblink"
2525export BIGLINK=" $ROOT_PATH /src/tools/biglink"
26+ MD5SUM=$( which md5sum)
27+ if [ " X$MD5SUM " == " X" ]; then
28+ MD5SUM=" md5 -r"
29+ fi
2630
2731# Internals
2832CRED=" \x1b[31;01m"
@@ -39,7 +43,7 @@ if [ $? -eq 0 ]; then
3943 export NDK_CCACHE=" ccache"
4044fi
4145
42- # set -x
46+ set -x
4347
4448function try () {
4549 " $@ " || exit -1
@@ -98,7 +102,13 @@ function push_arm() {
98102 export CXXFLAGS=" $CFLAGS "
99103
100104 # this must be something depending of the API level of Android
101- export PATH=" $ANDROIDNDK /toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
105+ PYPLATFORM=$( python -c ' import sys; print sys.platform' )
106+ if [ " $PYPLATFORM " == " linux2" ]; then
107+ PYPLATFORM=" linux"
108+ elif [ " $PYPLATFORM " == " linux3" ]; then
109+ PYPLATFORM=" linux"
110+ fi
111+ export PATH=" $ANDROIDNDK /toolchains/arm-eabi-4.4.0/prebuilt/$PYPLATFORM -x86/bin/:$ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
102112 if [ " X${ANDROIDNDKVER: 0: 2} " == " Xr7" ] || [ " X$ANDROIDNDKVER " == " Xr8" ]; then
103113 export TOOLCHAIN_PREFIX=arm-linux-androideabi
104114 export TOOLCHAIN_VERSION=4.4.3
@@ -110,7 +120,7 @@ function push_arm() {
110120 exit -1
111121 fi
112122
113- export PATH=" $ANDROIDNDK /toolchains/$TOOLCHAIN_PREFIX -$TOOLCHAIN_VERSION /prebuilt/linux -x86/bin/:$ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
123+ export PATH=" $ANDROIDNDK /toolchains/$TOOLCHAIN_PREFIX -$TOOLCHAIN_VERSION /prebuilt/$PYPLATFORM -x86/bin/:$ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
114124
115125 # search compiler in the path, to fail now instead of later.
116126 CC=$( which $TOOLCHAIN_PREFIX -gcc)
@@ -219,7 +229,7 @@ function run_prepare() {
219229
220230 info " Check mandatory tools"
221231 # ensure that some tools are existing
222- for tool in md5sum tar bzip2 unzip make gcc g++; do
232+ for tool in tar bzip2 unzip make gcc g++; do
223233 which $tool & > /dev/null
224234 if [ $? -ne 0 ]; then
225235 error " Tool $tool is missing"
@@ -274,7 +284,7 @@ function in_array() {
274284
275285function run_source_modules() {
276286 needed=($MODULES )
277- declare -A processed
287+ declare -a processed
278288 order=()
279289
280290 while [ ${# needed[*]} -ne 0 ]; do
@@ -285,13 +295,14 @@ function run_source_modules() {
285295 needed=( ${needed[@]} )
286296
287297 # check if the module have already been declared
288- if [[ ${processed[$module]} ]]; then
298+ in_array $module " ${processed[@]} "
299+ if [ $? -ne 255 ]; then
289300 debug " Ignored $module , already processed"
290301 continue ;
291302 fi
292303
293304 # add this module as done
294- processed[ $module ]=1
305+ processed=( ${processed[@]} $module )
295306
296307 # append our module at the end only if we are not exist yet
297308 in_array $module " ${order[@]} "
@@ -369,7 +380,7 @@ function run_get_packages() {
369380 if [ -f $filename ]; then
370381 if [ -n " $md5 " ]; then
371382 # check if the md5 is correct
372- current_md5=$( md5sum $filename | cut -d\ -f1)
383+ current_md5=$( $MD5SUM $filename | cut -d\ -f1)
373384 if [ " X$current_md5 " == " X$md5 " ]; then
374385 # correct, no need to download
375386 do_download=0
@@ -393,7 +404,7 @@ function run_get_packages() {
393404
394405 # check md5
395406 if [ -n " $md5 " ]; then
396- current_md5=$( md5sum $filename | cut -d\ -f1)
407+ current_md5=$( $MD5SUM $filename | cut -d\ -f1)
397408 if [ " X$current_md5 " != " X$md5 " ]; then
398409 error " File $filename md5 check failed (got $current_md5 instead of $md5 )."
399410 error " Ensure the file is correctly downloaded, and update MD5S_$module "
0 commit comments