]> git.saurik.com Git - ldid.git/blame - make.sh
Improve compatibility across different Cydia eras.
[ldid.git] / make.sh
CommitLineData
6212944b 1#!/bin/bash
6579543e 2
a5b37447 3set -e
15babeef 4shopt -s extglob
1d58df4c 5
15babeef
JF
6if [[ $# == 0 ]]; then
7 ios=false
8else
9 ios=$1
a50bb1be 10 shift
15babeef
JF
11fi
12
7b048e81
JF
13export DEVELOPER_DIR=/Applications/Xcode-5.1.1.app
14
6b3aca98
JF
15os=()
16
15babeef
JF
17if "${ios}"; then
18
19out=ios
7b048e81 20flags=(cycc -- -miphoneos-version-min=2.0 -arch armv6 -arch arm64)
15babeef 21
6b3aca98
JF
22flags+=(-Xarch_armv6 -Isysroot32/usr/include)
23flags+=(-Xarch_arm64 -Isysroot64/usr/include)
24
25flags+=(-Xarch_armv6 -Lsysroot32/usr/lib)
26flags+=(-Xarch_arm64 -Lsysroot64/usr/lib)
27
28static=false
29flags+=(-framework CoreFoundation)
30
31flags+=(-lplist)
32flags+=(-lcrypto)
33
15babeef
JF
34else
35
36out=out
69d2fe54 37
cd35ba9e
JF
38if which xcrun &>/dev/null; then
39 flags=(xcrun -sdk macosx g++)
40 flags+=(-mmacosx-version-min=10.4)
6579543e 41
cd35ba9e 42 for arch in i386 x86_64; do
bf29b0fe 43 flags+=(-arch "${arch}")
cd35ba9e
JF
44 done
45else
46 flags=(g++)
47fi
bf29b0fe 48
6b3aca98
JF
49#flags+=(-L../../lib-osx/openssl)
50
51# XXX: cannot redistribute
52static=true
53flags+=(-Isysroot64/usr/include)
54flags+=(-lcrypto)
55#flags+=(-Wl,/usr/lib/libcrypto.42.dylib)
56
15babeef
JF
57fi
58
59sdk=$(xcodebuild -sdk iphoneos -version Path)
60
4374152f 61flags+=(-I.)
6b3aca98
JF
62
63if ${static}; then
64
15babeef
JF
65flags+=(-I"${sdk}"/usr/include/libxml2)
66flags+=(-Ilibplist/include)
67flags+=(-Ilibplist/libcnary/include)
68
15babeef
JF
69for 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
76done
4374152f 77
6b3aca98
JF
78fi
79
80flags+=("$@")
81
82mkdir -p "${out}"
bf29b0fe 83set -x
15babeef 84
6b3aca98
JF
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
15babeef
JF
87
88if ! "${ios}"; then
89 ln -sf out/ldid .
90fi