]> git.saurik.com Git - ldid.git/blob - make.sh
The behavior of usage made absolutely no sense :/.
[ldid.git] / make.sh
1 #!/bin/bash
2
3 set -e
4 shopt -s extglob
5
6 if [[ $# == 0 ]]; then
7 ios=false
8 else
9 ios=$1
10 shift
11 fi
12
13 export DEVELOPER_DIR=/Applications/Xcode-5.1.1.app
14
15 os=()
16
17 if "${ios}"; then
18
19 out=ios
20 flags=(cycc -- -miphoneos-version-min=2.0 -arch armv6 -arch arm64)
21
22 flags+=(-Xarch_armv6 -Isysroot32/usr/include)
23 flags+=(-Xarch_arm64 -Isysroot64/usr/include)
24
25 flags+=(-Xarch_armv6 -Lsysroot32/usr/lib)
26 flags+=(-Xarch_arm64 -Lsysroot64/usr/lib)
27
28 static=false
29 flags+=(-framework CoreFoundation)
30
31 flags+=(-lplist)
32 flags+=(-lcrypto)
33
34 else
35
36 out=out
37
38 if which xcrun &>/dev/null; then
39 flags=(xcrun -sdk macosx g++)
40 flags+=(-mmacosx-version-min=10.4)
41
42 for arch in i386 x86_64; do
43 flags+=(-arch "${arch}")
44 done
45 else
46 flags=(g++)
47 fi
48
49 #flags+=(-L../../lib-osx/openssl)
50
51 # XXX: cannot redistribute
52 static=true
53 flags+=(-Isysroot64/usr/include)
54 flags+=(-lcrypto)
55 #flags+=(-Wl,/usr/lib/libcrypto.42.dylib)
56
57 fi
58
59 sdk=$(xcodebuild -sdk iphoneos -version Path)
60
61 flags+=(-I.)
62
63 if ${static}; then
64
65 flags+=(-I"${sdk}"/usr/include/libxml2)
66 flags+=(-Ilibplist/include)
67 flags+=(-Ilibplist/libcnary/include)
68
69 for c in libplist/libcnary/!(cnary).c libplist/src/*.c; do
70 o=${c%.c}.o
71 o="${out}"/${o##*/}
72 os+=("${o}")
73 if [[ "${c}" -nt "${o}" ]]; then
74 "${flags[@]}" -c -o "${o}" -x c "${c}"
75 fi
76 done
77
78 fi
79
80 flags+=("$@")
81
82 mkdir -p "${out}"
83 set -x
84
85 "${flags[@]}" -O3 -g0 -c -std=c++11 -o "${out}"/ldid.o ldid.cpp
86 "${flags[@]}" -O3 -g0 -o "${out}"/ldid "${out}"/ldid.o "${os[@]}" -x c lookup2.c -lxml2 -framework Security
87
88 if ! "${ios}"; then
89 ln -sf out/ldid .
90 fi