Skip to content

Commit 54559ca

Browse files
authored
Merge pull request #6 from lanza/darwin
Fix some issues with Darwin host compatibility
2 parents e406ef2 + 2e34551 commit 54559ca

6 files changed

+63
-69
lines changed

build.sh

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ set -x
44

55
export BUILDDIR=`pwd`
66

7-
NCPU=8
8-
uname -s | grep -i "linux" && NCPU=`cat /proc/cpuinfo | grep -c -i processor`
7+
if uname -s | grep -i 'linux' &> /dev/null; then
8+
IS_LINUX=1
9+
fi
10+
11+
if [ $IS_LINUX ]; then
12+
NCPU=`cat /proc/cpuinfo | grep -c -i processor`
13+
else
14+
NCPU=8
15+
fi
916

1017
NDK=`which ndk-build`
1118
NDK=`dirname $NDK`
12-
NDK=`readlink -f $NDK`
19+
if [ $IS_LINUX ]; then
20+
NDK=`readlink -f $NDK`
21+
fi
1322

1423
export CLANG=1
1524

@@ -26,13 +35,13 @@ cd $BUILDDIR/$ARCH
2635
# =========== libandroid_support.a ===========
2736

2837
[ -e libandroid_support.a ] || {
29-
mkdir -p android_support
30-
cd android_support
31-
ln -sf $NDK/sources/android/support jni
38+
mkdir -p android_support
39+
cd android_support
40+
ln -sf $NDK/sources/android/support jni
3241

33-
#ndk-build -j$NCPU APP_ABI=$ARCH APP_MODULES=android_support LIBCXX_FORCE_REBUILD=true CLANG=1 || exit 1
34-
#cp -f obj/local/$ARCH/libandroid_support.a ../
35-
ln -sf $NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libandroid_support.a ../
42+
#ndk-build -j$NCPU APP_ABI=$ARCH APP_MODULES=android_support LIBCXX_FORCE_REBUILD=true CLANG=1 || exit 1
43+
#cp -f obj/local/$ARCH/libandroid_support.a ../
44+
ln -sf $NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libandroid_support.a ../
3645

3746
} || exit 1
3847

@@ -53,7 +62,7 @@ cd $BUILDDIR/$ARCH
5362
cp -f $BUILDDIR/config.sub libcharset/build-aux/
5463
cp -f $BUILDDIR/config.guess libcharset/build-aux/
5564

56-
sed -i 's/MB_CUR_MAX/1/g' lib/loop_wchar.h
65+
sed -i,tmp 's/MB_CUR_MAX/1/g' lib/loop_wchar.h
5766

5867
env CFLAGS="-I$NDK/sources/android/support/include -D_IO_getc=getc" \
5968
LDFLAGS="-L$BUILDDIR/$ARCH -landroid_support" \
@@ -116,7 +125,7 @@ cd $BUILDDIR/$ARCH
116125
cp -f $BUILDDIR/config.sub .
117126
cp -f $BUILDDIR/config.guess .
118127

119-
sed -i 's/ld_shlibs=no/ld_shlibs=yes/g' ./configure
128+
sed -i,tmp 's/ld_shlibs=no/ld_shlibs=yes/g' ./configure
120129

121130
env CFLAGS="-I$NDK/sources/android/support/include -frtti -fexceptions -I$BUILDDIR/$ARCH/include" \
122131
LDFLAGS="-frtti -fexceptions -L$BUILDDIR/$ARCH/lib" \
@@ -178,8 +187,8 @@ cd $BUILDDIR/$ARCH
178187
cd ..
179188
} || exit 1
180189

181-
sed -i "s@LD_SONAME *=.*@LD_SONAME =@g" config/mh-linux
182-
sed -i "s%ln -s *%cp -f \$(dir \$@)/%g" config/mh-linux
190+
sed -i,tmp "s@LD_SONAME *=.*@LD_SONAME =@g" config/mh-linux
191+
sed -i,tmp "s%ln -s *%cp -f \$(dir \$@)/%g" config/mh-linux
183192

184193
env CFLAGS="-I$NDK/sources/android/support/include -frtti -fexceptions" \
185194
LDFLAGS="-frtti -fexceptions -L$BUILDDIR/$ARCH/lib" \
@@ -198,13 +207,13 @@ cd $BUILDDIR/$ARCH
198207
# ICULEHB_LIBS="-licu-le-hb" \
199208
# --enable-layoutex \
200209

201-
sed -i "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1
210+
sed -i,tmp "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1
202211

203212
env PATH=`pwd`:$PATH \
204213
$BUILDDIR/setCrossEnvironment-$ARCH.sh \
205214
make -j$NCPU VERBOSE=1 || exit 1
206215

207-
sed -i "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1
216+
sed -i,tmp "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1
208217

209218
env PATH=`pwd`:$PATH \
210219
$BUILDDIR/setCrossEnvironment-$ARCH.sh \
@@ -231,7 +240,7 @@ cd $BUILDDIR/$ARCH
231240
cp -f $BUILDDIR/config.sub .
232241
cp -f $BUILDDIR/config.guess .
233242

234-
sed -i 's/ld_shlibs=no/ld_shlibs=yes/g' ./configure
243+
sed -i,tmp 's/ld_shlibs=no/ld_shlibs=yes/g' ./configure
235244

236245
env CFLAGS="-I$NDK/sources/android/support/include -frtti -fexceptions" \
237246
CXXFLAGS="-std=c++11" \
@@ -251,7 +260,7 @@ cd $BUILDDIR/$ARCH
251260
env PATH=`pwd`:$PATH \
252261
$BUILDDIR/setCrossEnvironment-$ARCH.sh \
253262
make V=1 || \
254-
env PATH=`pwd`:$PATH \
263+
env PATH=`pwd`:$PATH \
255264
$BUILDDIR/setCrossEnvironment-$ARCH.sh \
256265
sh -c '$LD $CFLAGS -shared src/.libs/*.o -o src/.libs/libicu-le-hb.so.0.0.0 -L../lib -lharfbuzz -licuuc $LDFLAGS' || exit 1
257266

@@ -340,13 +349,13 @@ cd $BUILDDIR/$ARCH
340349
--enable-layoutex \
341350
|| exit 1
342351

343-
sed -i "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1
352+
sed -i,tmp "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1
344353

345354
env PATH=`pwd`:$PATH \
346355
$BUILDDIR/setCrossEnvironment-$ARCH.sh \
347356
make -j$NCPU VERBOSE=1 || exit 1
348357

349-
sed -i "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1
358+
sed -i,tmp "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1
350359

351360
env PATH=`pwd`:$PATH \
352361
$BUILDDIR/setCrossEnvironment-$ARCH.sh \

setCrossEnvironment-arm64-v8a.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
IFS='
44
'
55

6-
MYARCH=linux-x86_64
6+
NDK=`which ndk-build`
7+
NDK=`dirname $NDK`
8+
79
if uname -s | grep -i "linux" > /dev/null ; then
8-
MYARCH=linux-x86_64
9-
fi
10-
if uname -s | grep -i "darwin" > /dev/null ; then
10+
MYARCH=linux-$(arch)
11+
NDK=`readlink -f $NDK`
12+
elif uname -s | grep -i "darwin" > /dev/null ; then
1113
MYARCH=darwin-x86_64
12-
fi
13-
if uname -s | grep -i "windows" > /dev/null ; then
14+
elif uname -s | grep -i "windows" > /dev/null ; then
1415
MYARCH=windows-x86_64
1516
fi
1617

17-
NDK=`which ndk-build`
18-
NDK=`dirname $NDK`
19-
NDK=`readlink -f $NDK`
20-
2118
#echo NDK $NDK
2219
GCCPREFIX=aarch64-linux-android
2320
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9

setCrossEnvironment-armeabi-v7a.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
IFS='
44
'
55

6-
MYARCH=linux-x86_64
6+
NDK=`which ndk-build`
7+
NDK=`dirname $NDK`
8+
79
if uname -s | grep -i "linux" > /dev/null ; then
8-
MYARCH=linux-x86_64
9-
fi
10-
if uname -s | grep -i "darwin" > /dev/null ; then
10+
MYARCH=linux-$(arch)
11+
NDK=`readlink -f $NDK`
12+
elif uname -s | grep -i "darwin" > /dev/null ; then
1113
MYARCH=darwin-x86_64
12-
fi
13-
if uname -s | grep -i "windows" > /dev/null ; then
14+
elif uname -s | grep -i "windows" > /dev/null ; then
1415
MYARCH=windows-x86_64
1516
fi
1617

17-
NDK=`which ndk-build`
18-
NDK=`dirname $NDK`
19-
NDK=`readlink -f $NDK`
20-
2118
#echo NDK $NDK
2219
GCCPREFIX=arm-linux-androideabi
2320
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9

setCrossEnvironment-armeabi.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
IFS='
44
'
55

6-
MYARCH=linux-x86_64
6+
NDK=`which ndk-build`
7+
NDK=`dirname $NDK`
8+
79
if uname -s | grep -i "linux" > /dev/null ; then
8-
MYARCH=linux-x86_64
9-
fi
10-
if uname -s | grep -i "darwin" > /dev/null ; then
10+
MYARCH=linux-$(arch)
11+
NDK=`readlink -f $NDK`
12+
elif uname -s | grep -i "darwin" > /dev/null ; then
1113
MYARCH=darwin-x86_64
12-
fi
13-
if uname -s | grep -i "windows" > /dev/null ; then
14+
elif uname -s | grep -i "windows" > /dev/null ; then
1415
MYARCH=windows-x86_64
1516
fi
1617

17-
NDK=`which ndk-build`
18-
NDK=`dirname $NDK`
19-
NDK=`readlink -f $NDK`
20-
2118
#echo NDK $NDK
2219
GCCPREFIX=arm-linux-androideabi
2320
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9

setCrossEnvironment-x86.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
IFS='
44
'
55

6-
MYARCH=linux-x86_64
6+
NDK=`which ndk-build`
7+
NDK=`dirname $NDK`
8+
79
if uname -s | grep -i "linux" > /dev/null ; then
8-
MYARCH=linux-x86_64
9-
fi
10-
if uname -s | grep -i "darwin" > /dev/null ; then
10+
MYARCH=linux-$(arch)
11+
NDK=`readlink -f $NDK`
12+
elif uname -s | grep -i "darwin" > /dev/null ; then
1113
MYARCH=darwin-x86_64
12-
fi
13-
if uname -s | grep -i "windows" > /dev/null ; then
14+
elif uname -s | grep -i "windows" > /dev/null ; then
1415
MYARCH=windows-x86_64
1516
fi
1617

17-
NDK=`which ndk-build`
18-
NDK=`dirname $NDK`
19-
NDK=`readlink -f $NDK`
20-
2118
#echo NDK $NDK
2219
GCCPREFIX=i686-linux-android
2320
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9

setCrossEnvironment-x86_64.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
IFS='
44
'
55

6-
MYARCH=linux-x86_64
6+
NDK=`which ndk-build`
7+
NDK=`dirname $NDK`
8+
79
if uname -s | grep -i "linux" > /dev/null ; then
8-
MYARCH=linux-x86_64
9-
fi
10-
if uname -s | grep -i "darwin" > /dev/null ; then
10+
MYARCH=linux-$(arch)
11+
NDK=`readlink -f $NDK`
12+
elif uname -s | grep -i "darwin" > /dev/null ; then
1113
MYARCH=darwin-x86_64
12-
fi
13-
if uname -s | grep -i "windows" > /dev/null ; then
14+
elif uname -s | grep -i "windows" > /dev/null ; then
1415
MYARCH=windows-x86_64
1516
fi
1617

17-
NDK=`which ndk-build`
18-
NDK=`dirname $NDK`
19-
NDK=`readlink -f $NDK`
20-
2118
#echo NDK $NDK
2219
GCCPREFIX=x86_64-linux-android
2320
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9

0 commit comments

Comments
 (0)