From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / OSX / Makefile
index a4dff53c5f88313bfddf43d7acb84ce5a2d09a70..5467023424cbeda9f3bddd11157abd0946d2241e 100644 (file)
@@ -1,21 +1,28 @@
-# XScreenSaver for MacOS X, Copyright (c) 2006-2013 by Jamie Zawinski.
+# XScreenSaver for MacOS X, Copyright (c) 2006-2014 by Jamie Zawinski.
 
-XCODEBUILD = /usr/bin/xcodebuild
-TARGETS    = -target "All Savers"
+# We have to use Xcode 5.0.2 in order to build savers that will run on
+# MacOS 10.6 and 10.7, because that's the latest version of Xcode that
+# ships with a version of clang that implements "-fobjc-gc".
+#
+XCODE_APP = /Applications/Xcode-5.0.2.app
+
+TARGETS    = All Savers
 ARCH       = -arch i386 -arch x86_64
 CERT       = 'Jamie Zawinski'
 CERT       = 'iPhone Developer: Jamie Zawinski (Y5M82TL69N)'
-THUMBDIR   = $(HOME)/www/xscreensaver/screenshots/
 PKGID     = org.jwz.xscreensaver
-SETFILE    = /Applications/Xcode.app/Contents/Developer/Tools/SetFile
+THUMBDIR   = $(HOME)/www/xscreensaver/screenshots/
+XCODEBUILD = $(XCODE_APP)/Contents/Developer/usr/bin/xcodebuild
+SETFILE    = $(XCODE_APP)/Contents/Developer/Tools/SetFile
 SETICON    = /usr/local/bin/seticon
+# seticon is from osxutils1.7.pkg
 
 default: release
 all: debug release
 
 clean:
        -rm -rf build
-#      cd ..; $(XCODEBUILD) $(TARGETS) clean
+#      cd ..; $(XCODEBUILD) -target "$(TARGETS)" clean
 
 distclean:
        -rm -f config.status config.cache config.log \
@@ -27,10 +34,10 @@ distdepend:: Sparkle.framework
 distdepend:: update_plist_version
 
 debug: distdepend
-       cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Debug   build
+       cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug   build
 
 release:: distdepend
-       cd ..; $(XCODEBUILD) $(ARCH) $(TARGETS) -configuration Release build
+       cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
 
 release:: check_versions
 release:: update_thumbs
@@ -66,6 +73,51 @@ check_versions:
   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 ;                                                               \
+  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
+
+
 update_thumbs::
        ./update-thumbnail.pl $(THUMBDIR) build/Release/*.saver
 
@@ -111,10 +163,11 @@ updates.xml::
 
 test_sig::
        @                                                                   \
-  U=../version.h ;                                                         \
+  U=../utils/version.h ;                                                   \
   V=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ;]*\).*/\1/p' < $$U` ;             \
-  V=`echo $$V | sed 's/\.//g'` ;                                           \
-  ZIP="../archive/DaliClock-$$V.dmg" ;                                     \
+  BASE="xscreensaver-$$V" ;                                                \
+  OUTDIR="../archive" ;                                                            \
+  DMG="$$OUTDIR/$$BASE.dmg" ;                                              \
   SIG=`sed -n 's/^.*dsaSignature="\(.*\)".*/\1/p' updates.xml` ;           \
   PUB="sparkle_dsa_pub.pem" ;                                              \
   NN="t.$$$$" ;                                                                    \
@@ -124,7 +177,7 @@ test_sig::
   echo "$$SIG " | base64 -D  > "$$SIGB" ;                                  \
   set -e ;                                                                 \
   for OPENSSL in /usr/bin/openssl /opt/local/bin/openssl ; do              \
-    $$OPENSSL dgst -sha1 -binary  < "$$ZIP"  > "$$HASH" ;                  \
+    $$OPENSSL dgst -sha1 -binary  < "$$DMG"  > "$$HASH" ;                  \
     /bin/echo -n "$$OPENSSL    `$$OPENSSL version`:    " ;                 \
     $$OPENSSL dgst -dss1 -verify "$$PUB" -signature "$$SIGB" "$$HASH" ;            \
   done ;                                                                   \
@@ -166,7 +219,10 @@ build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.
 
 
 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
-dmg:: distdepend check_versions build/Release/installer.pkg
+dmg:: distdepend
+dmg:: check_versions check_gc check_coretext
+dmg:: build/Release/installer.pkg
+dmg::
        @                                                                     \
   set -e ;                                                                   \
   SRC=../utils/version.h ;                                                   \
@@ -197,18 +253,24 @@ dmg:: distdepend check_versions build/Release/installer.pkg
      echo savertester` ;                                                     \
                                                                              \
   for f in $$SRC/*.{saver,app} $$EXTRAS ; do                                 \
+   f2=`basename "$$f"` ;                                                     \
    ok=yes ;                                                                  \
    ff=`echo $$f | perl -e '$$_=<>; s@^.*/(.*)\..*$$@\L$$1@; print'`;         \
    for r in $$retired ; do                                                   \
     if [ "$$ff" = "$$r" ]; then ok=no ; fi ;                                 \
    done ;                                                                    \
+   DSTNAME="" ;                                                                      \
+   if [ "$$f2" = "XScreenSaverUpdater.app" ]; then                           \
+     DSTNAME=".$$f2" ;                                                       \
+   fi ;                                                                              \
    if [ "$$ok" = yes ]; then                                                 \
-    echo + cp -pR "$$f" "$$DST/" ;                                           \
-           cp -pR "$$f" "$$DST/" ;                                           \
+    echo + cp -pR "$$f" "$$DST/$$DSTNAME" ;                                  \
+           cp -pR "$$f" "$$DST/$$DSTNAME" ;                                  \
    else                                                                              \
     echo skipping "$$f" ;                                                    \
    fi ;                                                                              \
   done ;                                                                     \
+                                                                             \
   set -x ;                                                                   \
   cp -p bindist.rtf "$$STAGE/Read Me.rtf" ;                                  \
   cp -p build/Release/installer.pkg "$$PKG" ;                                \
@@ -230,3 +292,62 @@ dmg:: distdepend check_versions build/Release/installer.pkg
   xattr -w com.apple.quarantine "0000;00000000;;" "$$DMG" ;                  \
   rm -f "$$TMPDMG" ;                                                         \
   ls -ldhgF "$$DMG"
+
+
+# When debugging, sometimes I have to reset the preferences for all
+# the savers.  Also I like FPS to be turned on, and them all to be
+# pointed at the same image directory.
+#
+show_prefs::
+       @cd build/Debug ;                                                     \
+       for f in *.saver ; do                                                 \
+         f=`echo "$$f" | sed 's/\..*//'` ;                                   \
+         echo "########################## $$f" ;                             \
+         defaults -currentHost read org.jwz.xscreensaver."$$f" 2>&- ;        \
+       done ;                                                                \
+       for f in Apple2 Phosphor updater ; do                                 \
+         echo "########################## $$f" ;                             \
+         defaults read org.jwz.xscreensaver."$$f" 2>&- ;                     \
+       done
+
+reset_prefs::
+       @cd build/Debug ;                                                     \
+       W1='defaults' ;                                                       \
+       W2="$$W1 -currentHost write" ;                                        \
+       img='~/Pictures/Screensaver' ;                                        \
+       for f in *.saver ; do                                                 \
+         name=`echo "$$f" | sed 's/\..*//'` ;                                \
+         echo "########################## $$name" ;                          \
+         domain="org.jwz.xscreensaver" ;                                     \
+         dd="$$domain.$$name" ;                                              \
+         $$W1 -currentHost delete "$$dd" 2>&- ;                              \
+         $$W2 "$$dd" doFPS -bool true ;                                      \
+         if [ -f $$f/Contents/Resources/xscreensaver-text ] ; then           \
+           $$W2 "$$dd" textMode url ;                                        \
+         fi ;                                                                \
+         if [ -f $$f/Contents/Resources/xscreensaver-getimage-file ] ; then  \
+           $$W2 "$$dd" chooseRandomImages -bool true ;                       \
+           $$W2 "$$dd" grabDesktopImages -bool false ;                       \
+           $$W2 "$$dd" imageDirectory "$$img" ;                              \
+         fi ;                                                                \
+         if ( strings "$$f/Contents/MacOS/$$name" |                          \
+               grep NSOpenGLContext >/dev/null ) ; then                      \
+           $$W2 "$$dd" multiSample -bool true ;                              \
+         fi ;                                                                \
+       done ;                                                                \
+                                                                             \
+       $$W1 delete "$$domain.Apple2" 2>&- ;                                  \
+       $$W1 delete "$$domain.Phosphor" 2>&- ;                                \
+       $$W1 delete "$$domain.updater" 2>&- ;                                 \
+       $$W1 write  "$$domain.updater" SUScheduledCheckIntervalKey 86400;     \
+                                                                             \
+       $$W2 "$$domain.BoxFit" grab -bool true ;                              \
+       $$W2 "$$domain.FlipFlop" textured -bool true ;                        \
+       $$W2 "$$domain.GLSlideshow" titles -bool true ;                       \
+       $$W2 "$$domain.Photopile" titles -bool true ;                         \
+       $$W2 "$$domain.SkyTentacles" mode cel ;                               \
+       $$W2 "$$domain.Sonar" ping                                            \
+         '/etc/hosts,$$HOME/.ssh/known_hosts,$$HOME/.ssh/known_hosts2' ;     \
+       $$W2 "$$domain.XMatrix" matrixFont small ;                            \
+       $$W2 "$$domain.XMatrix" textMode literal ;                            \
+       $$W2 "$$domain.XMatrix" textLiteral "MONKEY BUTTER" ;                 \