From http://www.jwz.org/xscreensaver/xscreensaver-5.26.tar.gz
[xscreensaver] / OSX / Makefile
1 # XScreenSaver for MacOS X, Copyright (c) 2006-2013 by Jamie Zawinski.
2
3 XCODEBUILD = /usr/bin/xcodebuild
4 TARGETS    = -target "All Savers"
5 ARCH       = -arch i386 -arch x86_64
6 CERT       = 'Jamie Zawinski'
7 CERT       = 'iPhone Developer: Jamie Zawinski (Y5M82TL69N)'
8 THUMBDIR   = $(HOME)/www/xscreensaver/screenshots/
9 PKGID      = org.jwz.xscreensaver
10 SETFILE    = /Applications/Xcode.app/Contents/Developer/Tools/SetFile
11 SETICON    = /usr/local/bin/seticon
12
13 default: release
14 all: debug release
15
16 clean:
17         -rm -rf build
18 #       cd ..; $(XCODEBUILD) $(TARGETS) clean
19
20 distclean:
21         -rm -f config.status config.cache config.log \
22           *.bak *.rej TAGS *~ "#"*
23         -rm -rf autom4te*.cache
24         -rm -rf build Sparkle.framework
25
26 distdepend:: Sparkle.framework
27 distdepend:: update_plist_version
28
29 debug: distdepend
30         cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Debug   build
31
32 release:: distdepend
33         cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Release build
34
35 release:: check_versions
36 release:: update_thumbs
37 release:: sign
38
39 Sparkle.framework:
40         unzip ../archive/Sparkle.framework-2013-12-04.zip
41
42 sign:
43         @for f in build/Release/*.app/Contents/*/*.saver \
44                   build/Release/*.{saver,app} ; do \
45           codesign --deep -vfs $(CERT) $$f ; \
46          done
47
48 check_versions:
49         @\
50   SRC=../utils/version.h ;                                              \
51   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;           \
52   DIR=build/Release ;                                                   \
53   RESULT=0 ;                                                            \
54   for S in $$DIR/*.{saver,app} ; do                                     \
55    for P in $$S/Contents/Info.plist ; do                                \
56      V2=`plutil -convert xml1 -o - "$$P" |                              \
57          perl -0000 -n -e                                               \
58         'm@<key>CFBundleVersion</key>\s*<string>(.*?)</string>@si       \
59          && print $$1'` ;                                               \
60      if [ "$$V2" != "$$V" ] ; then                                      \
61        echo "Wrong version: $$S ($$V2)" ;                               \
62        RESULT=1 ;                                                       \
63      fi ;                                                               \
64    done ;                                                               \
65   done ;                                                                \
66   if [ "$$RESULT" = 0 ]; then echo "Versions match ($$V2)" ; fi ;       \
67   exit $$RESULT
68
69 update_thumbs::
70         ./update-thumbnail.pl $(THUMBDIR) build/Release/*.saver
71
72
73 # Arrrrgh
74 ios-function-table.m::
75         @./build-fntable.pl build/Debug-iphonesimulator/XScreenSaver.app $@
76
77
78 echo_tarfiles:
79         @echo `find . \
80           \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
81              -o -name 'jwz.*' -o -name 'Screen Savers' \) \
82              -prune \) \
83           -o \( -type f -o -type l \) -print \
84         | sed 's@^\./@@' \
85         | sort`
86
87 update_plist_version:
88         @                                                                     \
89   SRC=../utils/version.h ;                                                    \
90   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
91   T=/tmp/xs.$$$$ ;                                                            \
92   for S in *.plist ; do                                                       \
93     /bin/echo -n "Updating version number in $$S to \"$$V\"... " ;            \
94     KEYS="CFBundleVersion|CFBundleShortVersionString|CFBundleLongVersionString|CFBundleGetInfoString|NSHumanReadableCopyright" ; \
95     perl -0777 -pne                                                           \
96       "s@(<key>($$KEYS)</key>\s*<string>)[^<>]+(</string>)@\$${1}$$V\$${3}@g" \
97       < $$S > $$T ;                                                           \
98     if cmp -s $$S $$T ; then                                                  \
99       echo "unchanged." ;                                                     \
100     else                                                                      \
101       cat $$T > $$S ;                                                         \
102       echo "done." ;                                                          \
103     fi ;                                                                      \
104   done ;                                                                      \
105   rm $$T
106
107
108 updates.xml::
109         ./updates.pl xscreensaver ../README ../archive ~/www/xscreensaver
110         @$(MAKE) test_sig
111
112 test_sig::
113         @                                                                   \
114   U=../utils/version.h ;                                                    \
115   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ;]*\).*/\1/p' < $$U` ;              \
116   BASE="xscreensaver-$$V" ;                                                 \
117   OUTDIR="../archive" ;                                                     \
118   DMG="$$OUTDIR/$$BASE.dmg" ;                                               \
119   SIG=`sed -n 's/^.*dsaSignature="\(.*\)".*/\1/p' updates.xml` ;            \
120   PUB="sparkle_dsa_pub.pem" ;                                               \
121   NN="t.$$$$" ;                                                             \
122   SIGB=/tmp/$$NN.sig ;                                                      \
123   HASH=/tmp/$$NN.hash ;                                                     \
124   rm -f "$$SIGB" "$$HASH" ;                                                 \
125   echo "$$SIG " | base64 -D  > "$$SIGB" ;                                   \
126   set -e ;                                                                  \
127   for OPENSSL in /usr/bin/openssl /opt/local/bin/openssl ; do               \
128     $$OPENSSL dgst -sha1 -binary  < "$$DMG"  > "$$HASH" ;                   \
129     /bin/echo -n "$$OPENSSL     `$$OPENSSL version`:    " ;                 \
130     $$OPENSSL dgst -dss1 -verify "$$PUB" -signature "$$SIGB" "$$HASH" ;     \
131   done ;                                                                    \
132   rm -f "$$SIGB" "$$HASH" ;                                                 \
133
134
135 build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.png ../utils/version.h
136         @\
137   set -e ;                                                              \
138   SRC=../utils/version.h ;                                              \
139   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;           \
140                                                                         \
141   DIST="installer.xml" ;                                                \
142   STAGE="build/Release/pkg_stage" ;                                     \
143   PKG1="$@" ;                                                           \
144   PKG2="$$STAGE/contents.pkg" ;                                         \
145   SCRIPTS="$$STAGE/scripts" ;                                           \
146   RES="$$STAGE/resources" ;                                             \
147                                                                         \
148   set -x ;                                                              \
149   rm -rf "$$STAGE" ;                                                    \
150   mkdir -p "$$SCRIPTS" "$$RES" ;                                        \
151                                                                         \
152   cp -p installer.sh "$$SCRIPTS/preinstall" ;                           \
153   cp -p installer.png "$$RES/background.png" ;                          \
154   cp -p installer.rtf "$$RES/welcome.rtf" ;                             \
155                                                                         \
156   pkgbuild --identifier "$(PKGID)" --version "$$V"                      \
157            --scripts "$$SCRIPTS" --nopayload "$$PKG2" ;                 \
158   codesign -vfs $(CERT) "$$PKG2" ;                                      \
159   codesign -vd "$$PKG2" ;                                               \
160                                                                         \
161   productbuild --distribution "$$DIST" --resources "$$RES"              \
162                --package-path "$$STAGE" --version "$$V" "$$PKG1" ;      \
163   codesign -vfs $(CERT) "$$PKG1" ;                                      \
164   codesign -vd "$$PKG1" ;                                               \
165                                                                         \
166   rm -rf "$$STAGE" ;                                                    \
167
168
169 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
170 dmg:: distdepend check_versions build/Release/installer.pkg
171         @                                                                     \
172   set -e ;                                                                    \
173   SRC=../utils/version.h ;                                                    \
174   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
175   TMPDIR="build" ;                                                            \
176   SRC="build/Release" ;                                                       \
177   EXTRAS=../../xdaliclock/OSX/build/Release/*.saver ;                         \
178   BASE="xscreensaver-$$V" ;                                                   \
179   OUTDIR="../archive" ;                                                       \
180   DMG="$$OUTDIR/$$BASE.dmg" ;                                                 \
181   TMPDMG="$$TMPDIR/tmp.dmg" ;                                                 \
182   VOLNAME="XScreenSaver $$V" ;                                                \
183   STAGE="$$TMPDIR/dmg_stage" ;                                                \
184   DST="$$STAGE/Screen Savers" ;                                               \
185   PKG="$$STAGE/Install Everything.pkg" ;                                      \
186   rm -f "$$DMG" ;                                                             \
187   rm -rf "$$STAGE" ;                                                          \
188   echo + mkdir -p "$$DST" ;                                                   \
189          mkdir -p "$$DST" ;                                                   \
190                                                                               \
191   retired=`perl -0 -ne                                                        \
192      's/\\\\\\n//g; m/^RETIRED_EXES\s*=\s*(.*)$$/m && print "$$1\n"'          \
193       ../hacks/Makefile.in ;                                                  \
194       perl -0 -ne                                                             \
195      's/\\\\\\n//g; m/^RETIRED_GL_EXES\s*=\s*(.*)$$/m && print "$$1\n"'       \
196       ../hacks/glx/Makefile.in ;                                              \
197      echo xscreensaver ;                                                      \
198      echo savertester` ;                                                      \
199                                                                               \
200   for f in $$SRC/*.{saver,app} $$EXTRAS ; do                                  \
201    ok=yes ;                                                                   \
202    ff=`echo $$f | perl -e '$$_=<>; s@^.*/(.*)\..*$$@\L$$1@; print'`;          \
203    for r in $$retired ; do                                                    \
204     if [ "$$ff" = "$$r" ]; then ok=no ; fi ;                                  \
205    done ;                                                                     \
206    if [ "$$ok" = yes ]; then                                                  \
207     echo + cp -pR "$$f" "$$DST/" ;                                            \
208            cp -pR "$$f" "$$DST/" ;                                            \
209    else                                                                       \
210     echo skipping "$$f" ;                                                     \
211    fi ;                                                                       \
212   done ;                                                                      \
213   set -x ;                                                                    \
214   cp -p bindist.rtf "$$STAGE/Read Me.rtf" ;                                   \
215   cp -p build/Release/installer.pkg "$$PKG" ;                                 \
216   cp -p bindist-DS_Store "$$STAGE/.DS_Store" ;                                \
217   cp -p bindist.webloc "$$STAGE/Get the iPhone:iPad Version.webloc" ;         \
218   cp -p XScreenSaverDMG.icns "$$STAGE/.VolumeIcon.icns" ;                     \
219   ${SETFILE} -a C "$$STAGE" ;                                                 \
220   ${SETFILE} -a E "$$STAGE"/*.{rtf,pkg,webloc} ;                              \
221   $(SETICON) -d ../../xdaliclock/OSX/daliclockSaver.icns                      \
222                 "$$DST/DaliClock.saver" ;                                     \
223   $(SETICON) -d XScreenSaverFolder.icns "$$DST" ;                             \
224   $(SETICON) -d XScreenSaverWebloc.icns "$$STAGE"/*.webloc ;                  \
225   $(SETICON) -d XScreenSaverPkg.icns "$$STAGE"/*.pkg ;                        \
226   hdiutil makehybrid -quiet -ov -hfs -hfs-volume-name "$$VOLNAME"             \
227     -hfs-openfolder "$$STAGE" "$$STAGE" -o "$$TMPDMG" ;                       \
228   rm -rf "$$STAGE" ;                                                          \
229   hdiutil convert -quiet -ov -format UDBZ -imagekey zlib-level=9              \
230     "$$TMPDMG" -o "$$DMG" ;                                                   \
231   xattr -w com.apple.quarantine "0000;00000000;;" "$$DMG" ;                   \
232   rm -f "$$TMPDMG" ;                                                          \
233   ls -ldhgF "$$DMG"