--- /dev/null
+#!/bin/bash
+rm -rf _
+mkdir -p _/usr/bin
+cp -a ios/ldid _/usr/bin/ldid
+mkdir -p _/DEBIAN
+./control.sh _ >_/DEBIAN/control
+mkdir -p debs
+ln -sf debs/ldid_$(./version.sh)_iphoneos-arm.deb ldid.deb
+dpkg-deb -b _ ldid.deb
+readlink ldid.deb
#!/bin/bash
-
-set -e -x
-
-sudo xcode-select --switch /Applications/Xcode-4.6.3.app
-cycc -i2.0 -oldid.arm -- -c -std=c++11 ldid.cpp -I.
-cycc -i2.0 -oldid.arm -- ldid.arm -x c sha1.c lookup2.c -I .
-
-rm -rf _
-mkdir -p _/usr/bin
-cp -a ldid.arm _/usr/bin/ldid
-mkdir -p _/DEBIAN
-./control.sh _ >_/DEBIAN/control
-mkdir -p debs
-ln -sf debs/ldid_$(./version.sh)_iphoneos-arm.deb ldid.deb
-dpkg-deb -b _ ldid.deb
-readlink ldid.deb
+./make.sh true
#!/bin/bash
set -e
+shopt -s extglob
+if [[ $# == 0 ]]; then
+ ios=false
+else
+ ios=$1
+fi
+
+if "${ios}"; then
+
+out=ios
+sudo xcode-select --switch /Applications/Xcode-4.6.3.app
+flags=(cycc -- -miphoneos-version-min=2.0 -arch armv6)
+
+else
+
+out=out
sudo xcode-select --switch /Applications/Xcode-5.1.1.app
if which xcrun &>/dev/null; then
flags=(g++)
fi
+fi
+
+sdk=$(xcodebuild -sdk iphoneos -version Path)
+
flags+=(-I.)
+flags+=(-I"${sdk}"/usr/include/libxml2)
+flags+=(-Ilibplist/include)
+flags+=(-Ilibplist/libcnary/include)
+
+mkdir -p "${out}"
+os=()
+
+for c in libplist/libcnary/!(cnary).c libplist/src/*.c; do
+ o=${c%.c}.o
+ o="${out}"/${o##*/}
+ os+=("${o}")
+ if [[ "${c}" -nt "${o}" ]]; then
+ "${flags[@]}" -c -o "${o}" -x c "${c}"
+ fi
+done
set -x
-"${flags[@]}" -c -std=c++11 -o ldid.o ldid.cpp
-"${flags[@]}" -o ldid ldid.o -x c lookup2.c -x c sha1.c
+
+"${flags[@]}" -c -std=c++11 -o "${out}"/ldid.o ldid.cpp
+"${flags[@]}" -o "${out}"/ldid "${out}"/ldid.o "${os[@]}" -x c lookup2.c -x c sha1.c -lxml2
+
+if ! "${ios}"; then
+ ln -sf out/ldid .
+fi