b2354dfae06aa02bd678650327890dcfb45a85c1
[xscreensaver] / OSX / Makefile
1 # XScreenSaver for MacOS X, Copyright (c) 2006-2012 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
10 default: release
11 all: debug release
12
13 clean:
14         -rm -rf build
15 #       cd ..; $(XCODEBUILD) -target $(TARGETS) clean
16
17 distclean:
18         -rm -f config.status config.cache config.log \
19           *.bak *.rej TAGS *~ "#"*
20         -rm -rf autom4te*.cache
21         -rm -rf build
22
23 distdepend:: update_plist_version
24
25 debug: distdepend
26         cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Debug   build
27
28 release:: distdepend
29         cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Release build
30
31 release:: check_versions
32 release:: update_thumbs
33 release:: sign
34
35 sign:
36         @for f in build/Release/*.{saver,app} ; do \
37           codesign -vfs $(CERT) $$f ; \
38          done
39
40 check_versions:
41         @\
42   SRC=../utils/version.h ;                                              \
43   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;           \
44   DIR=build/Release ;                                                   \
45   RESULT=0 ;                                                            \
46   for S in $$DIR/*.{saver,app} ; do                                     \
47    for P in $$S/Contents/Info.plist ; do                                \
48      V2=`perl -0000 -n -e                                               \
49         'm@<key>CFBundleVersion</key>\s*<string>(.*?)</string>@si       \
50          && print $$1' < $$P` ;                                         \
51      if [ "$$V2" != "$$V" ] ; then                                      \
52        echo "Wrong version: $$S ($$V2)" ;                               \
53        RESULT=1 ;                                                       \
54      fi ;                                                               \
55    done ;                                                               \
56   done ;                                                                \
57   if [ "$$RESULT" = 0 ]; then echo "Versions match ($$V2)" ; fi ;       \
58   exit $$RESULT
59
60 update_thumbs::
61         ./update-thumbnail.pl $(THUMBDIR) build/Release/*.saver
62
63
64 # Arrrrgh
65 ios_function_tables.h::
66         @./build-fntable.pl build/Debug-iphoneos/XScreenSaver.app $@
67
68
69 echo_tarfiles:
70         @echo `find . \
71           \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
72              -o -name 'jwz.*' \) \
73              -prune \) \
74           -o -type f -print \
75         | sed 's@^\./@@' \
76         | sort`
77
78 update_plist_version:
79         @                                                                     \
80   SRC=../utils/version.h ;                                                    \
81   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
82   T=/tmp/xs.$$$$ ;                                                            \
83   for S in XScreenSaver.plist SaverRunner.plist iSaverRunner.plist ; do       \
84     /bin/echo -n "Updating version number in $$S to \"$$V\"... " ;            \
85     KEYS="CFBundleVersion|CFBundleShortVersionString" ;                       \
86     perl -0777 -pne                                                           \
87       "s@(<key>($$KEYS)</key>\s*<string>)[^<>]+(</string>)@\$${1}$$V\$${3}@g" \
88       < $$S > $$T ;                                                           \
89     if cmp -s $$S $$T ; then                                                  \
90       echo "unchanged." ;                                                     \
91     else                                                                      \
92       cat $$T > $$S ;                                                         \
93       echo "done." ;                                                          \
94     fi ;                                                                      \
95   done ;                                                                      \
96   rm $$T
97
98
99 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
100 dmg:: distdepend check_versions
101         @                                                                     \
102   set -e ;                                                                    \
103   SRC=../utils/version.h ;                                                    \
104   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' $$SRC` ;                 \
105   TMPDIR="build" ;                                                            \
106   SRC="build/Release" ;                                                       \
107   EXTRAS=../../xdaliclock/OSX/build/Release/*.saver ;                         \
108   BASE="xscreensaver-$$V" ;                                                   \
109   OUTDIR="../archive" ;                                                       \
110   DMG="$$OUTDIR/$$BASE.dmg" ;                                                 \
111   TMPDMG="$$TMPDIR/tmp.dmg" ;                                                 \
112   VOLNAME="XScreenSaver $$V" ;                                                \
113   STAGE="$$TMPDIR/dmg_stage" ;                                                \
114   rm -f "$$DMG" ;                                                             \
115   rm -rf "$$STAGE" ;                                                          \
116   echo + mkdir "$$STAGE" ;                                                    \
117          mkdir "$$STAGE" ;                                                    \
118                                                                               \
119   retired=`perl -0 -ne                                                        \
120      's/\\\\\\n//g; m/^RETIRED_EXES\s*=\s*(.*)$$/m && print "$$1\n"'          \
121       ../hacks/Makefile.in ;                                                  \
122       perl -0 -ne                                                             \
123      's/\\\\\\n//g; m/^RETIRED_GL_EXES\s*=\s*(.*)$$/m && print "$$1\n"'       \
124       ../hacks/glx/Makefile.in ;                                              \
125      echo xscreensaver ;                                                      \
126      echo savertester` ;                                                      \
127                                                                               \
128   for f in $$SRC/*.{saver,app} $$EXTRAS ; do                                  \
129    ok=yes ;                                                                   \
130    ff=`echo $$f | perl -e '$$_=<>; s@^.*/(.*)\..*$$@\L$$1@; print'`;          \
131    for r in $$retired ; do                                                    \
132     if [ "$$ff" = "$$r" ]; then ok=no ; fi ;                                  \
133    done ;                                                                     \
134    if [ "$$ok" = yes ]; then                                                  \
135     echo + cp -pr "$$f" "$$STAGE/" ;                                          \
136            cp -pr "$$f" "$$STAGE/" ;                                          \
137    else                                                                       \
138     echo skipping "$$f" ;                                                     \
139    fi ;                                                                       \
140   done ;                                                                      \
141   set -x ;                                                                    \
142   cp -p bindist.rtf "$$STAGE/ READ ME.rtf" ;                                  \
143   cp -p bindist-DS_Store "$$STAGE/.DS_Store" ;                                \
144   cp -p XScreenSaverDMG.icns "$$STAGE/.VolumeIcon.icns" ;                     \
145   /Developer/Tools/SetFile -a C "$$STAGE" ;                                   \
146   /Developer/Tools/SetFile -a E "$$STAGE/ READ ME.rtf" ;                      \
147   seticon -d ../../xdaliclock/OSX/daliclockSaver.icns $$STAGE/DaliClock.saver;\
148   hdiutil makehybrid -quiet -ov -hfs -hfs-volume-name "$$VOLNAME"             \
149     -hfs-openfolder "$$STAGE" "$$STAGE" -o "$$TMPDMG" ;                       \
150   rm -rf "$$STAGE" ;                                                          \
151   hdiutil convert -quiet -ov -format UDBZ -imagekey zlib-level=9              \
152     "$$TMPDMG" -o "$$DMG" ;                                                   \
153   rm -f "$$TMPDMG" ;                                                          \
154   ls -ldhgF "$$DMG"
155
156 # Adding this is cute:
157 #    hdiutil internet-enable -yes -quiet "$$DMG"
158 # but means that nobody will ever see the display settings I used!
159 # When finder copies the .dmg to a folder, it doesn't preserve them.