+debug: distdepend
+ $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug build
+
+release:: distdepend
+ $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
+
+release:: check_versions
+
+Sparkle.framework:
+ unzip ../archive/Sparkle.framework-2013-12-04.zip
+
+# Download and resize images from jwz.org.
+# This saves us having to include 4MB of images in the tar file
+# that will only be used by a vast minority of people building
+# from source.
+# update-info-plist.pl runs this as needed.
+# Might be better to do this with curl, since that is installed by default.
+
+BASE = xscreensaver/screenshots/
+URL = https://www.jwz.org/$(BASE)
+WGET = wget -q -U xscreensaver-build-osx
+CVT = -thumbnail '200x150^' -gravity center -extent 200x150 \
+ \( +clone -alpha extract \
+ -draw 'fill black polygon 0,0 0,6 6,0 fill white circle 6,6 6,0' \
+ \( +clone -flip \) -compose Multiply -composite \
+ \( +clone -flop \) -compose Multiply -composite \
+ \) -alpha off -compose CopyOpacity -composite \
+ -colorspace sRGB \
+ -strip \
+ -quality 95 \
+ +dither -colors 128
+
+$(THUMBDIR)/%.png:
+ @\
+ FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ; \
+ FILE2="$@" ; \
+ TMP="$$FILE2".tmp ; \
+ URL="$(URL)$$FILE1" ; \
+ URL2="$(URL)retired/$$FILE1" ; \
+ if [ ! -d $(THUMBDIR) ]; then mkdir -p $(THUMBDIR) ; fi ; \
+ rm -f "$$FILE2" "$$TMP" ; \
+ set +e ; \
+ if [ -f "$$HOME/www/$(BASE)/$$FILE1" ]; then \
+ cp -p "$$HOME/www/$(BASE)/$$FILE1" "$$TMP" ; \
+ else \
+ echo "downloading $$URL..." ; \
+ $(WGET) -O"$$TMP" "$$URL" ; \
+ if [ ! -s "$$TMP" ]; then \
+ echo "downloading $$URL2..." ; \
+ $(WGET) -O"$$TMP" "$$URL2" ; \
+ fi ; \
+ if [ ! -s "$$TMP" ]; then \
+ rm -f "$$TMP" ; \
+ echo "failed: $$URL" ; \
+ exit 1 ; \
+ fi ; \
+ fi ; \
+ rm -f "$$FILE2" ; \
+ convert jpg:- $(CVT) "$$FILE2" < "$$TMP" ; \
+ if [ ! -s "$$FILE2" ]; then \
+ echo "$$FILE2 failed" >&2 ; \
+ rm -f "$$FILE2" "$$TMP" ; \
+ exit 1 ; \
+ else \
+ rm -f "$$TMP" ; \
+ fi
+
+
+check_versions:
+ @\
+ SRC=../utils/version.h ; \
+ V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ; \
+ DIR=build/Release ; \
+ RESULT=0 ; \
+ for S in $$DIR/*.{saver,app} ; do \
+ for P in $$S/Contents/Info.plist ; do \
+ V2=`plutil -convert xml1 -o - "$$P" | \
+ perl -0000 -n -e \
+ 'm@<key>CFBundleVersion</key>\s*<string>(.*?)</string>@si \
+ && print $$1'` ; \
+ if [ "$$V2" != "$$V" ] ; then \
+ echo "Wrong version: $$S ($$V2)" ; \
+ RESULT=1 ; \
+ fi ; \
+ done ; \
+ done ; \
+ if [ "$$RESULT" = 0 ]; then echo "Versions match ($$V2)" ; fi ; \
+ exit $$RESULT
+
+
+check_gc:
+ @\
+ DIR="build/Release" ; \
+ RESULT=0 ; \
+ for S in "$$DIR/"*.saver ; do \
+ SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/.saver$$//'` ; \
+ D="$$S/Contents/MacOS/$$SS" ; \
+ V=`otool -s __DATA __objc_imageinfo "$$D" \
+ | grep ' 00 02 00 '` ; \
+ if [ -z "$$V" ]; then \
+ echo "$$S does not have GC enabled" ; \
+ RESULT=1 ; \
+ fi ; \
+ done ; \
+ \
+ for D in "$$DIR"/webcollage-helper \
+ "$$DIR"/*.saver/Contents/*/webcollage-helper \
+ "$$DIR"/*.app/Contents/*/XScreenSaverUpdater \
+ ; do \
+ V=`otool -s __DATA __objc_imageinfo "$$D" \
+ | grep ' 00 02 00 '` ; \
+ if [ ! -z "$$V" ]; then \
+ echo "$$D has GC enabled" ; \
+ RESULT=1 ; \
+ fi ; \
+ done ; \
+ \
+ if [ "$$RESULT" = 0 ]; then echo "GC enabled" ; fi ; \
+ exit $$RESULT
+
+
+check_coretext:
+ @\
+ DIR="build/Release" ; \
+ RESULT=0 ; \
+ for S in "$$DIR/"*.{saver,app} ; do \
+ SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/[.][a-z]*$$//'` ; \
+ D="$$S/Contents/MacOS/$$SS" ; \
+ FF=`otool -l "$$D" \
+ | fgrep '/CoreText.framework/' \
+ | sed -n 's/^ *name \([^ ]*\).*$$/\1/p'` ; \
+ if [ -z "$$FF" ] ; then \
+ echo "$$S not linked with CoreText" >/dev/null ; \
+ else \
+ OK=`echo "$$FF" | fgrep -v '/ApplicationServices.framework/'` ; \
+ if [ ! -z "$$OK" ]; then \
+ echo "$$S is linked with the wrong CoreText: $$FF" ; \
+ RESULT=1 ; \
+ else \
+ echo "$$S linked right: $$FF" >/dev/null ; \
+ fi ; \
+ fi ; \
+ done ; \
+ if [ "$$RESULT" = 0 ]; then echo "CoreText linked correctly" ; fi ; \
+ exit $$RESULT
+
+
+# Arrrrgh
+ios-function-table.m::
+ @./build-fntable.pl build/Debug-iphonesimulator/XScreenSaver.app $@