forked from marforic/imagemagick_lib_iphone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile_png.sh
executable file
·58 lines (53 loc) · 1.66 KB
/
compile_png.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
png_compile() {
echo "[|- MAKE $BUILDINGFOR]"
try make -j$CORESNUM
try make install
echo "[|- CP STATIC/DYLIB $BUILDINGFOR]"
try cp $PNG_LIB_DIR/lib/$LIBPATH_png $LIB_DIR/libpng.a.$BUILDINGFOR
try cp $PNG_LIB_DIR/lib/$LIBPATH_png_dylib $LIB_DIR/png_${BUILDINGFOR}_dylib/libpng.dylib
first=`echo $ARCHS | awk '{print $1;}'`
if [ "$BUILDINGFOR" == "$first" ]; then
echo "[|- CP include files (arch ref: $first)]"
# copy the include files
try cp -r $PNG_LIB_DIR/include/libpng*/ $LIB_DIR/include/png/
fi
echo "[|- CLEAN $BUILDINGFOR]"
try make distclean
}
png () {
echo "[+ PNG: $1]"
cd $PNG_DIR
LIBPATH_png=libpng16.a
LIBPATH_png_dylib=libpng16.dylib
if [ "$1" == "armv7" ] || [ "$1" == "armv7s" ] || [ "$1" == "arm64" ]; then
save
armflags $1
echo "[|- CONFIG $BUILDINGFOR]"
export CC="$(xcode-select -print-path)/usr/bin/gcc" # override clang
try ./configure prefix=$PNG_LIB_DIR --enable-shared --enable-static --host=arm-apple-darwin
png_compile
restore
elif [ "$1" == "i386" ] || [ "$1" == "x86_64" ]; then
save
intelflags $1
echo "[|- CONFIG $BUILDINGFOR]"
export CC="$(xcode-select -print-path)/usr/bin/gcc" # override clang
try ./configure prefix=$PNG_LIB_DIR --enable-shared --enable-static --host=${BUILDINGFOR}-apple-darwin
png_compile
restore
else
echo "[ERR: Nothing to do for $1]"
fi
joinlibs=$(check_for_archs $LIB_DIR/libpng.a)
if [ $joinlibs == "OK" ]; then
echo "[|- COMBINE $ARCHS]"
accumul=""
for i in $ARCHS; do
accumul="$accumul -arch $i $LIB_DIR/libpng.a.$i"
done
# combine the static libraries
try xcrun -sdk iphoneos lipo $accumul -create -output $LIB_DIR/libpng.a
echo "[+ DONE]"
fi
}