1 # XScreenSaver for MacOS X, Copyright (c) 2006-2015 by Jamie Zawinski.
3 XCODE_APP = /Applications/Xcode.app
5 # To build savers that will run on MacOS 10.6 and 10.7, Xcode 5.0.2 must
6 # be used (as that's the latest version of Xcode that ships with a version
7 # of clang that implements "-fobjc-gc"). However, Xcode 5.0.2 will not
8 # launch on MacOS 10.11 or later.
10 # XCODE_APP = /Applications/Xcode-5.0.2.app
13 ARCH = -arch i386 -arch x86_64 ONLY_ACTIVE_ARCH=NO
14 CERT = 'Developer ID Installer: Jamie Zawinski (4627ATJELP)'
15 PKGID = org.jwz.xscreensaver
16 THUMBDIR = build/screenshots
17 XCODEBUILD = $(XCODE_APP)/Contents/Developer/usr/bin/xcodebuild
18 SETFILE = $(XCODE_APP)/Contents/Developer/Tools/SetFile
19 SETICON = ./seticon.pl
26 # $(XCODEBUILD) -target "$(TARGETS)" clean
29 -rm -f config.status config.cache config.log \
30 *.bak *.rej TAGS *~ "#"*
31 -rm -rf autom4te*.cache
32 -rm -rf build Sparkle.framework
34 distdepend:: Sparkle.framework
35 distdepend:: update_plist_version
38 $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug build
41 $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
43 release:: check_versions
46 unzip ../archive/Sparkle.framework-2013-12-04.zip
48 # Download and resize images from jwz.org.
49 # This saves us having to include 4MB of images in the tar file
50 # that will only be used by a vast minority of people building
52 # update-info-plist.pl runs this as needed.
53 # Might be better to do this with curl, since that is installed by default.
55 URL = https://www.jwz.org/xscreensaver/screenshots/
56 WGET = wget -q -U xscreensaver-build-osx
57 CVT = -thumbnail '200x150^' -gravity center -extent 200x150 \
58 \( +clone -alpha extract \
59 -draw 'fill black polygon 0,0 0,6 6,0 fill white circle 6,6 6,0' \
60 \( +clone -flip \) -compose Multiply -composite \
61 \( +clone -flop \) -compose Multiply -composite \
62 \) -alpha off -compose CopyOpacity -composite \
70 FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ; \
73 URL="$(URL)$$FILE1" ; \
74 URL2="$(URL)retired/$$FILE1" ; \
75 if [ ! -d $(THUMBDIR) ]; then mkdir -p $(THUMBDIR) ; fi ; \
76 rm -f "$$FILE2" "$$TMP" ; \
78 echo "downloading $$URL..." ; \
79 $(WGET) -O"$$TMP" "$$URL" ; \
80 if [ ! -s "$$TMP" ]; then \
81 echo "downloading $$URL2..." ; \
82 $(WGET) -O"$$TMP" "$$URL2" ; \
84 if [ ! -s "$$TMP" ]; then \
86 echo "failed: $$URL" ; \
90 convert jpg:- $(CVT) "$$FILE2" < "$$TMP" ; \
91 if [ ! -s "$$FILE2" ]; then \
92 echo "$$FILE2 failed" >&2 ; \
93 rm -f "$$FILE2" "$$TMP" ; \
102 SRC=../utils/version.h ; \
103 V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ; \
104 DIR=build/Release ; \
106 for S in $$DIR/*.{saver,app} ; do \
107 for P in $$S/Contents/Info.plist ; do \
108 V2=`plutil -convert xml1 -o - "$$P" | \
110 'm@<key>CFBundleVersion</key>\s*<string>(.*?)</string>@si \
112 if [ "$$V2" != "$$V" ] ; then \
113 echo "Wrong version: $$S ($$V2)" ; \
118 if [ "$$RESULT" = 0 ]; then echo "Versions match ($$V2)" ; fi ; \
124 DIR="build/Release" ; \
126 for S in "$$DIR/"*.saver ; do \
127 SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/.saver$$//'` ; \
128 D="$$S/Contents/MacOS/$$SS" ; \
129 V=`otool -s __DATA __objc_imageinfo "$$D" \
130 | grep ' 00 02 00 '` ; \
131 if [ -z "$$V" ]; then \
132 echo "$$S does not have GC enabled" ; \
137 for D in "$$DIR"/webcollage-helper \
138 "$$DIR"/*.saver/Contents/*/webcollage-helper \
139 "$$DIR"/*.app/Contents/*/XScreenSaverUpdater \
141 V=`otool -s __DATA __objc_imageinfo "$$D" \
142 | grep ' 00 02 00 '` ; \
143 if [ ! -z "$$V" ]; then \
144 echo "$$D has GC enabled" ; \
149 if [ "$$RESULT" = 0 ]; then echo "GC enabled" ; fi ; \
155 DIR="build/Release" ; \
157 for S in "$$DIR/"*.{saver,app} ; do \
158 SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/[.][a-z]*$$//'` ; \
159 D="$$S/Contents/MacOS/$$SS" ; \
161 | fgrep '/CoreText.framework/' \
162 | sed -n 's/^ *name \([^ ]*\).*$$/\1/p'` ; \
163 if [ -z "$$FF" ] ; then \
164 echo "$$S not linked with CoreText" >/dev/null ; \
166 OK=`echo "$$FF" | fgrep -v '/ApplicationServices.framework/'` ; \
167 if [ ! -z "$$OK" ]; then \
168 echo "$$S is linked with the wrong CoreText: $$FF" ; \
171 echo "$$S linked right: $$FF" >/dev/null ; \
175 if [ "$$RESULT" = 0 ]; then echo "CoreText linked correctly" ; fi ; \
180 ios-function-table.m::
181 @./build-fntable.pl build/Debug-iphonesimulator/XScreenSaver.app $@
186 \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
187 -o -name 'jwz.*' -o -name 'Screen Savers' \
188 -o -name xscreensaver.xcodeproj \) \
190 -o \( -type f -o -type l \) -print ; \
191 echo xscreensaver.xcodeproj/project.pbxproj ) \
195 update_plist_version:
197 SRC=../utils/version.h ; \
198 V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ; \
200 for S in *.plist ; do \
201 /bin/echo -n "Updating version number in $$S to \"$$V\"... " ; \
202 KEYS="CFBundleVersion|CFBundleShortVersionString|CFBundleLongVersionString|CFBundleGetInfoString|NSHumanReadableCopyright" ; \
204 "s@(<key>($$KEYS)</key>\s*<string>)[^<>]+(</string>)@\$${1}$$V\$${3}@g" \
206 if cmp -s $$S $$T ; then \
207 echo "unchanged." ; \
217 ./updates.pl xscreensaver ../README ../archive ~/www/xscreensaver
222 U=../utils/version.h ; \
223 V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ;]*\).*/\1/p' < $$U` ; \
224 BASE="xscreensaver-$$V" ; \
225 OUTDIR="../archive" ; \
226 DMG="$$OUTDIR/$$BASE.dmg" ; \
227 SIG=`sed -n 's/^.*dsaSignature="\(.*\)".*/\1/p' updates.xml` ; \
228 PUB="sparkle_dsa_pub.pem" ; \
230 SIGB=/tmp/$$NN.sig ; \
231 HASH=/tmp/$$NN.hash ; \
232 rm -f "$$SIGB" "$$HASH" ; \
233 echo "$$SIG " | base64 -D > "$$SIGB" ; \
235 for OPENSSL in /usr/bin/openssl /opt/local/bin/openssl ; do \
236 $$OPENSSL dgst -sha1 -binary < "$$DMG" > "$$HASH" ; \
237 /bin/echo -n "$$OPENSSL `$$OPENSSL version`: " ; \
238 $$OPENSSL dgst -dss1 -verify "$$PUB" -signature "$$SIGB" "$$HASH" ; \
240 rm -f "$$SIGB" "$$HASH" ; \
243 build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.png ../utils/version.h
246 SRC=../utils/version.h ; \
247 V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ; \
249 DIST="installer.xml" ; \
250 STAGE="build/Release/pkg_stage" ; \
252 UNSIGNED="$$STAGE/contents.pkg" ; \
253 PRODUCT="$$STAGE/product_unsigned.pkg" ; \
254 SCRIPTS="$$STAGE/scripts" ; \
255 RES="$$STAGE/resources" ; \
259 mkdir -p "$$SCRIPTS" "$$RES" ; \
261 cp -p installer.sh "$$SCRIPTS/preinstall" ; \
262 cp -p installer.png "$$RES/background.png" ; \
263 cp -p installer.rtf "$$RES/welcome.rtf" ; \
265 pkgbuild --identifier "$(PKGID)" --version "$$V" \
266 --scripts "$$SCRIPTS" --nopayload "$$UNSIGNED" ; \
268 productbuild --distribution "$$DIST" --resources "$$RES" \
269 --package-path "$$STAGE" --version "$$V" "$$PRODUCT" ; \
271 productsign --sign $(CERT) "$$PRODUCT" "$$FINAL" ; \
272 spctl --assess --verbose=4 --type install "$$FINAL" ; \
277 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
279 dmg:: check_versions check_coretext
281 dmg:: build/Release/installer.pkg
285 SRC=../utils/version.h ; \
286 V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ; \
288 SRC="build/Release" ; \
289 EXTRAS=../../xdaliclock/OSX/build/Release/*.saver ; \
290 BASE="xscreensaver-$$V" ; \
291 OUTDIR="../archive" ; \
292 DMG="$$OUTDIR/$$BASE.dmg" ; \
293 TMPDMG="$$TMPDIR/tmp.dmg" ; \
294 VOLNAME="XScreenSaver $$V" ; \
295 STAGE="$$TMPDIR/dmg_stage" ; \
296 DST="$$STAGE/Screen Savers" ; \
297 PKG="$$STAGE/Install Everything.pkg" ; \
300 echo + mkdir -p "$$DST" ; \
303 retired=`perl -0 -ne \
304 's/\\\\\\n//g; m/^RETIRED_EXES\s*=\s*(.*)$$/m && print "$$1\n"' \
305 ../hacks/Makefile.in ; \
307 's/\\\\\\n//g; m/^RETIRED_GL_EXES\s*=\s*(.*)$$/m && print "$$1\n"' \
308 ../hacks/glx/Makefile.in ; \
309 echo xscreensaver ; \
310 echo savertester` ; \
312 for f in $$SRC/*.{saver,app} $$EXTRAS ; do \
313 f2=`basename "$$f"` ; \
315 ff=`echo $$f | perl -e '$$_=<>; s@^.*/(.*)\..*$$@\L$$1@; print'`; \
316 for r in $$retired ; do \
317 if [ "$$ff" = "$$r" ]; then ok=no ; fi ; \
319 if [ "$$ff" = testx11 ]; then ok=no ; fi ; \
320 if [ "$$f2" = "XScreenSaverUpdater.app" ]; then \
321 DST_HACK="XScreenSaver.updater" ; \
322 echo + tar ... "$$DST/$$DST_HACK" ; \
323 ( cd $$SRC ; tar -czf - "$$f2" ) > "$$DST/$$DST_HACK" ; \
324 elif [ "$$ok" = yes ]; then \
325 echo + cp -pR "$$f" "$$DST/" ; \
326 cp -pR "$$f" "$$DST/" ; \
328 echo skipping "$$f" ; \
333 cp -p bindist.rtf "$$STAGE/Read Me.rtf" ; \
334 cp -p build/Release/installer.pkg "$$PKG" ; \
335 cp -p bindist-DS_Store "$$STAGE/.DS_Store" ; \
336 cp -p bindist.webloc "$$STAGE/" ; \
337 cp -p XScreenSaverDMG.icns "$$STAGE/.VolumeIcon.icns" ; \
338 ${SETFILE} -a C "$$STAGE" ; \
339 ${SETFILE} -a E "$$STAGE"/*.{rtf,pkg,webloc} ; \
340 $(SETICON) -d ../../xdaliclock/OSX/daliclockSaver.icns \
341 "$$DST/DaliClock.saver" ; \
342 $(SETICON) -d XScreenSaverFolder.icns "$$DST" ; \
343 $(SETICON) -d XScreenSaver.icns "$$DST"/*.saver ; \
344 $(SETICON) -d SaverRunner.icns "$$DST"/*.app ; \
345 $(SETICON) -d XScreenSaverWebloc.icns "$$STAGE"/*.webloc ; \
346 $(SETICON) -d XScreenSaverPkg.icns "$$STAGE"/*.pkg ; \
347 mv "$$STAGE/bindist.webloc" "$$STAGE/Get the iPhone:iPad Version.webloc" ; \
350 echo "Checking signatures..." ; \
351 spctl --assess --type install "$$PKG" ; \
352 spctl --assess --type execute "$$SRC/XScreenSaverUpdater.app" ; \
353 spctl --assess --type execute "$$DST/"*.app ; \
354 spctl --assess --type install "$$DST/"*.saver ; \
357 hdiutil makehybrid -quiet -ov -hfs -hfs-volume-name "$$VOLNAME" \
358 -hfs-openfolder "$$STAGE" "$$STAGE" -o "$$TMPDMG" ; \
361 hdiutil convert -quiet -ov -format UDBZ -imagekey zlib-level=9 \
362 "$$TMPDMG" -o "$$DMG" ; \
363 xattr -w com.apple.quarantine "0000;00000000;;" "$$DMG" ; \
368 # When debugging, sometimes I have to reset the preferences for all
369 # the savers. Also I like FPS to be turned on, and them all to be
370 # pointed at the same image directory.
374 for f in *.saver ; do \
375 f=`echo "$$f" | sed 's/\..*//'` ; \
376 echo "########################## $$f" ; \
377 defaults -currentHost read org.jwz.xscreensaver."$$f" 2>&- ; \
379 for f in Apple2 Phosphor updater ; do \
380 echo "########################## $$f" ; \
381 defaults read org.jwz.xscreensaver."$$f" 2>&- ; \
387 W2="$$W1 -currentHost write" ; \
388 img='~/Pictures/Screensaver' ; \
389 for f in *.saver ; do \
390 name=`echo "$$f" | sed 's/\..*//'` ; \
391 echo "########################## $$name" ; \
392 domain="org.jwz.xscreensaver" ; \
393 dd="$$domain.$$name" ; \
394 $$W1 -currentHost delete "$$dd" 2>&- ; \
395 $$W2 "$$dd" doFPS -bool true ; \
396 if [ -f $$f/Contents/Resources/xscreensaver-text ] ; then \
397 $$W2 "$$dd" textMode url ; \
399 if [ -f $$f/Contents/Resources/xscreensaver-getimage-file ] ; then \
400 $$W2 "$$dd" chooseRandomImages -bool true ; \
401 $$W2 "$$dd" grabDesktopImages -bool false ; \
402 $$W2 "$$dd" imageDirectory "$$img" ; \
404 if ( strings "$$f/Contents/MacOS/$$name" | \
405 grep NSOpenGLContext >/dev/null ) ; then \
406 $$W2 "$$dd" multiSample -bool true ; \
410 $$W1 delete "$$domain.Apple2" 2>&- ; \
411 $$W1 delete "$$domain.Phosphor" 2>&- ; \
412 $$W1 delete "$$domain.updater" 2>&- ; \
413 $$W1 write "$$domain.updater" SUScheduledCheckIntervalKey 86400; \
415 $$W2 "$$domain.BoxFit" grab -bool true ; \
416 $$W2 "$$domain.FlipFlop" textured -bool true ; \
417 $$W2 "$$domain.GLSlideshow" titles -bool true ; \
418 $$W2 "$$domain.Photopile" titles -bool true ; \
419 $$W2 "$$domain.SkyTentacles" mode cel ; \
420 $$W2 "$$domain.Sonar" ping \
421 '/etc/hosts,$$HOME/.ssh/known_hosts,$$HOME/.ssh/known_hosts2' ; \
422 $$W2 "$$domain.XMatrix" matrixFont small ; \
423 $$W2 "$$domain.XMatrix" textMode literal ; \
424 $$W2 "$$domain.XMatrix" textLiteral "MONKEY BUTTER" ; \
426 # defaults -currentHost write org.jwz.xscreensaver.FontGlide debugMetrics -bool true
427 # defaults -currentHost write org.jwz.xscreensaver.StarWars debug -bool true
428 # defaults -currentHost write org.jwz.xscreensaver.StarWars textMode file
429 # defaults -currentHost write org.jwz.xscreensaver.StarWars textFile ~/src/xscreensaver/hacks/glx/zalgo.txt