]>
Commit | Line | Data |
---|---|---|
6212944b | 1 | #!/bin/bash |
6579543e | 2 | |
a5b37447 | 3 | set -e |
15babeef | 4 | shopt -s extglob |
1d58df4c | 5 | |
15babeef JF |
6 | if [[ $# == 0 ]]; then |
7 | ios=false | |
8 | else | |
9 | ios=$1 | |
a50bb1be | 10 | shift |
15babeef JF |
11 | fi |
12 | ||
7b048e81 JF |
13 | export DEVELOPER_DIR=/Applications/Xcode-5.1.1.app |
14 | ||
6b3aca98 JF |
15 | os=() |
16 | ||
15babeef JF |
17 | if "${ios}"; then |
18 | ||
19 | out=ios | |
7b048e81 | 20 | flags=(cycc -- -miphoneos-version-min=2.0 -arch armv6 -arch arm64) |
15babeef | 21 | |
6b3aca98 JF |
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 | ||
15babeef JF |
34 | else |
35 | ||
36 | out=out | |
69d2fe54 | 37 | |
cd35ba9e JF |
38 | if 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 |
45 | else | |
46 | flags=(g++) | |
47 | fi | |
bf29b0fe | 48 | |
6b3aca98 JF |
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 | ||
15babeef JF |
57 | fi |
58 | ||
59 | sdk=$(xcodebuild -sdk iphoneos -version Path) | |
60 | ||
4374152f | 61 | flags+=(-I.) |
6b3aca98 JF |
62 | |
63 | if ${static}; then | |
64 | ||
15babeef JF |
65 | flags+=(-I"${sdk}"/usr/include/libxml2) |
66 | flags+=(-Ilibplist/include) | |
67 | flags+=(-Ilibplist/libcnary/include) | |
68 | ||
15babeef JF |
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 | |
4374152f | 77 | |
6b3aca98 JF |
78 | fi |
79 | ||
80 | flags+=("$@") | |
81 | ||
82 | mkdir -p "${out}" | |
bf29b0fe | 83 | set -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 | |
88 | if ! "${ios}"; then | |
89 | ln -sf out/ldid . | |
90 | fi |