From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / OSX / Makefile
1 # XScreenSaver for MacOS X, Copyright (c) 2006-2014 by Jamie Zawinski.
2
3 # We have to use Xcode 5.0.2 in order to build savers that will run on
4 # MacOS 10.6 and 10.7, because that's the latest version of Xcode that
5 # ships with a version of clang that implements "-fobjc-gc".
6 #
7 XCODE_APP = /Applications/Xcode-5.0.2.app
8
9 TARGETS    = All Savers
10 ARCH       = -arch i386 -arch x86_64
11 CERT       = 'Jamie Zawinski'
12 CERT       = 'iPhone Developer: Jamie Zawinski (Y5M82TL69N)'
13 PKGID      = org.jwz.xscreensaver
14 THUMBDIR   = $(HOME)/www/xscreensaver/screenshots/
15 XCODEBUILD = $(XCODE_APP)/Contents/Developer/usr/bin/xcodebuild
16 SETFILE    = $(XCODE_APP)/Contents/Developer/Tools/SetFile
17 SETICON    = /usr/local/bin/seticon
18 # seticon is from osxutils1.7.pkg
19
20 default: release
21 all: debug release
22
23 clean:
24         -rm -rf build
25 #       cd ..; $(XCODEBUILD) -target "$(TARGETS)" clean
26
27 distclean:
28         -rm -f config.status config.cache config.log \
29           *.bak *.rej TAGS *~ "#"*
30         -rm -rf autom4te*.cache
31         -rm -rf build Sparkle.framework
32
33 distdepend:: Sparkle.framework
34 distdepend:: update_plist_version
35
36 debug: distdepend
37         cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug   build
38
39 release:: distdepend
40         cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
41
42 release:: check_versions
43 release:: update_thumbs
44 release:: sign
45
46 Sparkle.framework:
47         unzip ../archive/Sparkle.framework-2013-12-04.zip
48
49 sign:
50         @for f in build/Release/*.app/Contents/*/*.saver \
51                   build/Release/*.{saver,app} ; do \
52           codesign --deep -vfs $(CERT) $$f ; \
53          done
54
55 check_versions:
56         @\
57   SRC=../utils/version.h ;                                              \
58   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;           \
59   DIR=build/Release ;                                                   \
60   RESULT=0 ;                                                            \
61   for S in $$DIR/*.{saver,app} ; do                                     \
62    for P in $$S/Contents/Info.plist ; do                                \
63      V2=`plutil -convert xml1 -o - "$$P" |                              \
64          perl -0000 -n -e                                               \
65         'm@<key>CFBundleVersion</key>\s*<string>(.*?)</string>@si       \
66          && print $$1'` ;                                               \
67      if [ "$$V2" != "$$V" ] ; then                                      \
68        echo "Wrong version: $$S ($$V2)" ;                               \
69        RESULT=1 ;                                                       \
70      fi ;                                                               \
71    done ;                                                               \
72   done ;                                                                \
73   if [ "$$RESULT" = 0 ]; then echo "Versions match ($$V2)" ; fi ;       \
74   exit $$RESULT
75
76
77 check_gc:
78         @\
79   DIR="build/Release" ;                                                 \
80   RESULT=0 ;                                                            \
81   for S in "$$DIR/"*.saver ; do                                         \
82    SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/.saver$$//'` ;              \
83    D="$$S/Contents/MacOS/$$SS" ;                                        \
84    V=`otool -s __DATA __objc_imageinfo "$$D"                            \
85       | grep ' 00 02 00 '` ;                                            \
86    if [ -z "$$V" ]; then                                                \
87      echo "$$S does not have GC enabled" ;                              \
88      RESULT=1 ;                                                         \
89    fi ;                                                                 \
90   done ;                                                                \
91   if [ "$$RESULT" = 0 ]; then echo "GC enabled" ; fi ;                  \
92   exit $$RESULT
93
94
95 check_coretext:
96         @\
97   DIR="build/Release" ;                                                 \
98   RESULT=0 ;                                                            \
99   for S in "$$DIR/"*.{saver,app} ; do                                   \
100    SS=`echo "$$S" | sed -e 's@^.*/@@' -e 's/[.][a-z]*$$//'` ;           \
101    D="$$S/Contents/MacOS/$$SS" ;                                        \
102    FF=`otool -l "$$D"                                                   \
103       | fgrep '/CoreText.framework/'                                    \
104       | sed -n 's/^ *name \([^ ]*\).*$$/\1/p'` ;                        \
105    if [ -z "$$FF" ] ; then                                              \
106      echo "$$S not linked with CoreText" >/dev/null ;                   \
107    else                                                                 \
108      OK=`echo "$$FF" | fgrep -v '/ApplicationServices.framework/'` ;    \
109      if [ ! -z "$$OK" ]; then                                           \
110        echo "$$S is linked with the wrong CoreText: $$FF" ;             \
111        RESULT=1 ;                                                       \
112      else                                                               \
113        echo "$$S linked right: $$FF" >/dev/null ;                       \
114      fi ;                                                               \
115    fi ;                                                                 \
116   done ;                                                                \
117   if [ "$$RESULT" = 0 ]; then echo "CoreText linked correctly" ; fi ;   \
118   exit $$RESULT
119
120
121 update_thumbs::
122         ./update-thumbnail.pl $(THUMBDIR) build/Release/*.saver
123
124
125 # Arrrrgh
126 ios-function-table.m::
127         @./build-fntable.pl build/Debug-iphonesimulator/XScreenSaver.app $@
128
129
130 echo_tarfiles:
131         @echo `find . \
132           \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
133              -o -name 'jwz.*' -o -name 'Screen Savers' \) \
134              -prune \) \
135           -o \( -type f -o -type l \) -print \
136         | sed 's@^\./@@' \
137         | sort`
138
139 update_plist_version:
140         @                                                                     \
141   SRC=../utils/version.h ;                                                    \
142   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
143   T=/tmp/xs.$$$$ ;                                                            \
144   for S in *.plist ; do                                                       \
145     /bin/echo -n "Updating version number in $$S to \"$$V\"... " ;            \
146     KEYS="CFBundleVersion|CFBundleShortVersionString|CFBundleLongVersionString|CFBundleGetInfoString|NSHumanReadableCopyright" ; \
147     perl -0777 -pne                                                           \
148       "s@(<key>($$KEYS)</key>\s*<string>)[^<>]+(</string>)@\$${1}$$V\$${3}@g" \
149       < $$S > $$T ;                                                           \
150     if cmp -s $$S $$T ; then                                                  \
151       echo "unchanged." ;                                                     \
152     else                                                                      \
153       cat $$T > $$S ;                                                         \
154       echo "done." ;                                                          \
155     fi ;                                                                      \
156   done ;                                                                      \
157   rm $$T
158
159
160 updates.xml::
161         ./updates.pl xscreensaver ../README ../archive ~/www/xscreensaver
162         @$(MAKE) test_sig
163
164 test_sig::
165         @                                                                   \
166   U=../utils/version.h ;                                                    \
167   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ;]*\).*/\1/p' < $$U` ;              \
168   BASE="xscreensaver-$$V" ;                                                 \
169   OUTDIR="../archive" ;                                                     \
170   DMG="$$OUTDIR/$$BASE.dmg" ;                                               \
171   SIG=`sed -n 's/^.*dsaSignature="\(.*\)".*/\1/p' updates.xml` ;            \
172   PUB="sparkle_dsa_pub.pem" ;                                               \
173   NN="t.$$$$" ;                                                             \
174   SIGB=/tmp/$$NN.sig ;                                                      \
175   HASH=/tmp/$$NN.hash ;                                                     \
176   rm -f "$$SIGB" "$$HASH" ;                                                 \
177   echo "$$SIG " | base64 -D  > "$$SIGB" ;                                   \
178   set -e ;                                                                  \
179   for OPENSSL in /usr/bin/openssl /opt/local/bin/openssl ; do               \
180     $$OPENSSL dgst -sha1 -binary  < "$$DMG"  > "$$HASH" ;                   \
181     /bin/echo -n "$$OPENSSL     `$$OPENSSL version`:    " ;                 \
182     $$OPENSSL dgst -dss1 -verify "$$PUB" -signature "$$SIGB" "$$HASH" ;     \
183   done ;                                                                    \
184   rm -f "$$SIGB" "$$HASH" ;                                                 \
185
186
187 build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.png ../utils/version.h
188         @\
189   set -e ;                                                              \
190   SRC=../utils/version.h ;                                              \
191   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;           \
192                                                                         \
193   DIST="installer.xml" ;                                                \
194   STAGE="build/Release/pkg_stage" ;                                     \
195   PKG1="$@" ;                                                           \
196   PKG2="$$STAGE/contents.pkg" ;                                         \
197   SCRIPTS="$$STAGE/scripts" ;                                           \
198   RES="$$STAGE/resources" ;                                             \
199                                                                         \
200   set -x ;                                                              \
201   rm -rf "$$STAGE" ;                                                    \
202   mkdir -p "$$SCRIPTS" "$$RES" ;                                        \
203                                                                         \
204   cp -p installer.sh "$$SCRIPTS/preinstall" ;                           \
205   cp -p installer.png "$$RES/background.png" ;                          \
206   cp -p installer.rtf "$$RES/welcome.rtf" ;                             \
207                                                                         \
208   pkgbuild --identifier "$(PKGID)" --version "$$V"                      \
209            --scripts "$$SCRIPTS" --nopayload "$$PKG2" ;                 \
210   codesign -vfs $(CERT) "$$PKG2" ;                                      \
211   codesign -vd "$$PKG2" ;                                               \
212                                                                         \
213   productbuild --distribution "$$DIST" --resources "$$RES"              \
214                --package-path "$$STAGE" --version "$$V" "$$PKG1" ;      \
215   codesign -vfs $(CERT) "$$PKG1" ;                                      \
216   codesign -vd "$$PKG1" ;                                               \
217                                                                         \
218   rm -rf "$$STAGE" ;                                                    \
219
220
221 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
222 dmg:: distdepend
223 dmg:: check_versions check_gc check_coretext
224 dmg:: build/Release/installer.pkg
225 dmg::
226         @                                                                     \
227   set -e ;                                                                    \
228   SRC=../utils/version.h ;                                                    \
229   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
230   TMPDIR="build" ;                                                            \
231   SRC="build/Release" ;                                                       \
232   EXTRAS=../../xdaliclock/OSX/build/Release/*.saver ;                         \
233   BASE="xscreensaver-$$V" ;                                                   \
234   OUTDIR="../archive" ;                                                       \
235   DMG="$$OUTDIR/$$BASE.dmg" ;                                                 \
236   TMPDMG="$$TMPDIR/tmp.dmg" ;                                                 \
237   VOLNAME="XScreenSaver $$V" ;                                                \
238   STAGE="$$TMPDIR/dmg_stage" ;                                                \
239   DST="$$STAGE/Screen Savers" ;                                               \
240   PKG="$$STAGE/Install Everything.pkg" ;                                      \
241   rm -f "$$DMG" ;                                                             \
242   rm -rf "$$STAGE" ;                                                          \
243   echo + mkdir -p "$$DST" ;                                                   \
244          mkdir -p "$$DST" ;                                                   \
245                                                                               \
246   retired=`perl -0 -ne                                                        \
247      's/\\\\\\n//g; m/^RETIRED_EXES\s*=\s*(.*)$$/m && print "$$1\n"'          \
248       ../hacks/Makefile.in ;                                                  \
249       perl -0 -ne                                                             \
250      's/\\\\\\n//g; m/^RETIRED_GL_EXES\s*=\s*(.*)$$/m && print "$$1\n"'       \
251       ../hacks/glx/Makefile.in ;                                              \
252      echo xscreensaver ;                                                      \
253      echo savertester` ;                                                      \
254                                                                               \
255   for f in $$SRC/*.{saver,app} $$EXTRAS ; do                                  \
256    f2=`basename "$$f"` ;                                                      \
257    ok=yes ;                                                                   \
258    ff=`echo $$f | perl -e '$$_=<>; s@^.*/(.*)\..*$$@\L$$1@; print'`;          \
259    for r in $$retired ; do                                                    \
260     if [ "$$ff" = "$$r" ]; then ok=no ; fi ;                                  \
261    done ;                                                                     \
262    DSTNAME="" ;                                                               \
263    if [ "$$f2" = "XScreenSaverUpdater.app" ]; then                            \
264      DSTNAME=".$$f2" ;                                                        \
265    fi ;                                                                       \
266    if [ "$$ok" = yes ]; then                                                  \
267     echo + cp -pR "$$f" "$$DST/$$DSTNAME" ;                                   \
268            cp -pR "$$f" "$$DST/$$DSTNAME" ;                                   \
269    else                                                                       \
270     echo skipping "$$f" ;                                                     \
271    fi ;                                                                       \
272   done ;                                                                      \
273                                                                               \
274   set -x ;                                                                    \
275   cp -p bindist.rtf "$$STAGE/Read Me.rtf" ;                                   \
276   cp -p build/Release/installer.pkg "$$PKG" ;                                 \
277   cp -p bindist-DS_Store "$$STAGE/.DS_Store" ;                                \
278   cp -p bindist.webloc "$$STAGE/Get the iPhone:iPad Version.webloc" ;         \
279   cp -p XScreenSaverDMG.icns "$$STAGE/.VolumeIcon.icns" ;                     \
280   ${SETFILE} -a C "$$STAGE" ;                                                 \
281   ${SETFILE} -a E "$$STAGE"/*.{rtf,pkg,webloc} ;                              \
282   $(SETICON) -d ../../xdaliclock/OSX/daliclockSaver.icns                      \
283                 "$$DST/DaliClock.saver" ;                                     \
284   $(SETICON) -d XScreenSaverFolder.icns "$$DST" ;                             \
285   $(SETICON) -d XScreenSaverWebloc.icns "$$STAGE"/*.webloc ;                  \
286   $(SETICON) -d XScreenSaverPkg.icns "$$STAGE"/*.pkg ;                        \
287   hdiutil makehybrid -quiet -ov -hfs -hfs-volume-name "$$VOLNAME"             \
288     -hfs-openfolder "$$STAGE" "$$STAGE" -o "$$TMPDMG" ;                       \
289   rm -rf "$$STAGE" ;                                                          \
290   hdiutil convert -quiet -ov -format UDBZ -imagekey zlib-level=9              \
291     "$$TMPDMG" -o "$$DMG" ;                                                   \
292   xattr -w com.apple.quarantine "0000;00000000;;" "$$DMG" ;                   \
293   rm -f "$$TMPDMG" ;                                                          \
294   ls -ldhgF "$$DMG"
295
296
297 # When debugging, sometimes I have to reset the preferences for all
298 # the savers.  Also I like FPS to be turned on, and them all to be
299 # pointed at the same image directory.
300 #
301 show_prefs::
302         @cd build/Debug ;                                                     \
303         for f in *.saver ; do                                                 \
304           f=`echo "$$f" | sed 's/\..*//'` ;                                   \
305           echo "########################## $$f" ;                             \
306           defaults -currentHost read org.jwz.xscreensaver."$$f" 2>&- ;        \
307         done ;                                                                \
308         for f in Apple2 Phosphor updater ; do                                 \
309           echo "########################## $$f" ;                             \
310           defaults read org.jwz.xscreensaver."$$f" 2>&- ;                     \
311         done
312
313 reset_prefs::
314         @cd build/Debug ;                                                     \
315         W1='defaults' ;                                                       \
316         W2="$$W1 -currentHost write" ;                                        \
317         img='~/Pictures/Screensaver' ;                                        \
318         for f in *.saver ; do                                                 \
319           name=`echo "$$f" | sed 's/\..*//'` ;                                \
320           echo "########################## $$name" ;                          \
321           domain="org.jwz.xscreensaver" ;                                     \
322           dd="$$domain.$$name" ;                                              \
323           $$W1 -currentHost delete "$$dd" 2>&- ;                              \
324           $$W2 "$$dd" doFPS -bool true ;                                      \
325           if [ -f $$f/Contents/Resources/xscreensaver-text ] ; then           \
326             $$W2 "$$dd" textMode url ;                                        \
327           fi ;                                                                \
328           if [ -f $$f/Contents/Resources/xscreensaver-getimage-file ] ; then  \
329             $$W2 "$$dd" chooseRandomImages -bool true ;                       \
330             $$W2 "$$dd" grabDesktopImages -bool false ;                       \
331             $$W2 "$$dd" imageDirectory "$$img" ;                              \
332           fi ;                                                                \
333           if ( strings "$$f/Contents/MacOS/$$name" |                          \
334                 grep NSOpenGLContext >/dev/null ) ; then                      \
335             $$W2 "$$dd" multiSample -bool true ;                              \
336           fi ;                                                                \
337         done ;                                                                \
338                                                                               \
339         $$W1 delete "$$domain.Apple2" 2>&- ;                                  \
340         $$W1 delete "$$domain.Phosphor" 2>&- ;                                \
341         $$W1 delete "$$domain.updater" 2>&- ;                                 \
342         $$W1 write  "$$domain.updater" SUScheduledCheckIntervalKey 86400;     \
343                                                                               \
344         $$W2 "$$domain.BoxFit" grab -bool true ;                              \
345         $$W2 "$$domain.FlipFlop" textured -bool true ;                        \
346         $$W2 "$$domain.GLSlideshow" titles -bool true ;                       \
347         $$W2 "$$domain.Photopile" titles -bool true ;                         \
348         $$W2 "$$domain.SkyTentacles" mode cel ;                               \
349         $$W2 "$$domain.Sonar" ping                                            \
350           '/etc/hosts,$$HOME/.ssh/known_hosts,$$HOME/.ssh/known_hosts2' ;     \
351         $$W2 "$$domain.XMatrix" matrixFont small ;                            \
352         $$W2 "$$domain.XMatrix" textMode literal ;                            \
353         $$W2 "$$domain.XMatrix" textLiteral "MONKEY BUTTER" ;                 \