-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathutils.sh
executable file
·100 lines (93 loc) · 2.69 KB
/
utils.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# If command fails the script exits
try () {
if [ $VERBOSE -eq 1 ]; then
"$@" | tee -a $OUTPUT_FILE 2>&1 || exit -1
else
"$@" >> $OUTPUT_FILE 2>&1 || exit -1
fi
}
# Prepares the directory structure needed for the compilation and any additional
# requirement
prepare() {
# ImageMagick requires crt_externals.h, that doesn't
# exist for the iPhone - Just copying it make things compile/work
if [ -e $IOSSDKROOT/usr/include/crt_externs.h ]; then
:;
else
echo "[INFO] need to copy crt_externals.h for compilation, please enter sudo password"
sudo ln -s "$SIMSDKROOT/usr/include/crt_externs.h" "$IOSSDKROOT/usr/include/crt_externs.h"
fi
# Check if IMDelegates is inside the IM directory or link it
if [ -e $IM_DELEGATES_DIR ]; then
:;
else
echo "[INFO] IMDelegates not found, linking it"
ln -s "$BUILDROOT/IMDelegates" "$IM_DIR/IMDelegates"
fi
# target folder
mkdir -p $TARGET_LIB_DIR
# includes
mkdir -p $LIB_DIR/include/im_config
mkdir -p $LIB_DIR/include/jpeg
mkdir -p $LIB_DIR/include/magick
mkdir -p $LIB_DIR/include/png
mkdir -p $LIB_DIR/include/tiff
mkdir -p $LIB_DIR/include/wand
# lib directories
mkdir -p $JPEG_LIB_DIR
mkdir -p $PNG_LIB_DIR
mkdir -p $TIFF_LIB_DIR
# DYLIB directories
for i in "jpeg" "png" "tiff"; do
for j in $ARCHS; do
mkdir -p $LIB_DIR/${i}_${j}_dylib
done
done
}
# For every architecture checks if the coresponding library file exists. Used
# later to merge (with lipo) all the library archives in a fat one
check_for_archs() {
local to_check=$1
local ret="OK"
for i in $ARCHS; do
if [ ! -e $to_check.$i ]; then
ret="NO"
break
fi
done
echo $ret
}
# Creates the structure that can be imported in XCode as it is done in the
# example project
structure_for_xcode() {
echo "[+ Prepairing import for XCode]"
if [ -e $FINAL_DIR ]; then
echo "[|- RM $FINAL_DIR/*]"
try rm -rf ${FINAL_DIR}/*
else
echo "[|- MKDIR: $FINAL_DIR]"
try mkdir -p ${FINAL_DIR}
fi
echo "[|- CP ...]"
try cp -r ${LIB_DIR}/include/ ${FINAL_DIR}/include/
try cp ${LIB_DIR}/*.a ${FINAL_DIR}/
echo "[+ DONE!]"
}
# Creates .zips to be uploaded on the ImageMagick FTP site.
# Not useful to many, used by Claudio Marforio.
zip_for_ftp() {
echo "[+ ZIP]"
if [ -e $FINAL_DIR ]; then
tmp_dir="$(pwd)/TMP_IM"
try cp -R $FINAL_DIR/ $tmp_dir
try ditto -c -k -rsrc "$tmp_dir" "iOSMagick-FIXME-libs.zip" && echo "[|- CREATED W/ libs]"
try rm $tmp_dir/libjpeg.a $tmp_dir/libpng.a $tmp_dir/libtiff.a
try rm -rf $tmp_dir/include/jpeg/ $tmp_dir/include/png/ $tmp_dir/include/tiff/
try ditto -c -k -rsrc "$tmp_dir" "iOSMagick-FIXME.zip" && echo "[|- CREATED W/O libs]"
try rm -rf $tmp_dir
else
echo "[ERR $FINAL_DIR not present..."
fi
echo "[+ DONE: ZIP]"
}