From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / OSX / Makefile
index 5467023424cbeda9f3bddd11157abd0946d2241e..492bc69ced2dcaeba56fef2f885f18ce8bd6a773 100644 (file)
@@ -1,28 +1,29 @@
-# XScreenSaver for MacOS X, Copyright (c) 2006-2014 by Jamie Zawinski.
+# XScreenSaver for MacOS X, Copyright (c) 2006-2015 by Jamie Zawinski.
 
-# 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.app
+
+# To build savers that will run on MacOS 10.6 and 10.7, Xcode 5.0.2 must
+# be used (as that's the latest version of Xcode that ships with a version
+# of clang that implements "-fobjc-gc").  However, Xcode 5.0.2 will not
+# launch on MacOS 10.11 or later.
 #
-XCODE_APP = /Applications/Xcode-5.0.2.app
+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)'
+ARCH       = -arch i386 -arch x86_64 ONLY_ACTIVE_ARCH=NO
+CERT      = 'Developer ID Installer: Jamie Zawinski (4627ATJELP)'
 PKGID     = org.jwz.xscreensaver
-THUMBDIR   = $(HOME)/www/xscreensaver/screenshots/
+THUMBDIR   = build/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
+SETICON    = ./seticon.pl
 
 default: release
 all: debug release
 
 clean:
        -rm -rf build
-#      cd ..; $(XCODEBUILD) -target "$(TARGETS)" clean
+#      $(XCODEBUILD) -target "$(TARGETS)" clean
 
 distclean:
        -rm -f config.status config.cache config.log \
@@ -34,23 +35,72 @@ distdepend:: Sparkle.framework
 distdepend:: update_plist_version
 
 debug: distdepend
-       cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug   build
+       $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Debug   build
 
 release:: distdepend
-       cd ..; $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
+       $(XCODEBUILD) $(ARCH) -target "$(TARGETS)" -configuration Release build
 
 release:: check_versions
-release:: update_thumbs
-release:: sign
 
 Sparkle.framework:
        unzip ../archive/Sparkle.framework-2013-12-04.zip
 
-sign:
-       @for f in build/Release/*.app/Contents/*/*.saver \
-                 build/Release/*.{saver,app} ; do \
-         codesign --deep -vfs $(CERT) $$f ; \
-        done
+# Download and resize images from jwz.org.
+# This saves us having to include 4MB of images in the tar file
+# that will only be used by a vast minority of people building
+# from source.
+# update-info-plist.pl runs this as needed.
+# Might be better to do this with curl, since that is installed by default.
+
+BASE = xscreensaver/screenshots/
+URL = https://www.jwz.org/$(BASE)
+WGET = wget -q -U xscreensaver-build-osx
+CVT  = -thumbnail '200x150^' -gravity center -extent 200x150 \
+     \( +clone  -alpha extract \
+        -draw 'fill black polygon 0,0 0,6 6,0 fill white circle 6,6 6,0' \
+        \( +clone -flip \) -compose Multiply -composite \
+        \( +clone -flop \) -compose Multiply -composite \
+     \) -alpha off -compose CopyOpacity -composite \
+    -colorspace sRGB \
+    -strip \
+    -quality 95 \
+    +dither -colors 128
+
+$(THUMBDIR)/%.png:
+       @\
+       FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ;      \
+       FILE2="$@" ;                                                    \
+       TMP="$$FILE2".tmp ;                                             \
+       URL="$(URL)$$FILE1" ;                                           \
+       URL2="$(URL)retired/$$FILE1" ;                                  \
+       if [ ! -d $(THUMBDIR) ]; then mkdir -p $(THUMBDIR) ; fi ;       \
+       rm -f "$$FILE2" "$$TMP" ;                                       \
+       set +e ;                                                        \
+       if [ -f "$$HOME/www/$(BASE)/$$FILE1" ]; then                    \
+         cp -p "$$HOME/www/$(BASE)/$$FILE1" "$$TMP" ;                  \
+       else                                                            \
+         echo "downloading $$URL..." ;                                 \
+         $(WGET) -O"$$TMP" "$$URL" ;                                   \
+         if [ ! -s "$$TMP" ]; then                                     \
+           echo "downloading $$URL2..." ;                              \
+           $(WGET) -O"$$TMP" "$$URL2" ;                                \
+         fi ;                                                          \
+         if [ ! -s "$$TMP" ]; then                                     \
+           rm -f "$$TMP" ;                                             \
+           echo "failed: $$URL" ;                                      \
+           exit 1 ;                                                    \
+         fi ;                                                          \
+       fi ;                                                            \
+       rm -f "$$FILE2" ;                                               \
+       convert jpg:- $(CVT) "$$FILE2" < "$$TMP" ;                      \
+       if [ ! -s "$$FILE2" ]; then                                     \
+         echo "$$FILE2 failed" >&2 ;                                   \
+         rm -f "$$FILE2" "$$TMP" ;                                     \
+         exit 1 ;                                                      \
+       else                                                            \
+         rm -f "$$TMP" ;                                               \
+       fi
+
 
 check_versions:
        @\
@@ -88,6 +138,19 @@ check_gc:
      RESULT=1 ;                                                                \
    fi ;                                                                        \
   done ;                                                               \
+                                                                       \
+  for D in "$$DIR"/webcollage-helper                                   \
+          "$$DIR"/*.saver/Contents/*/webcollage-helper                 \
+          "$$DIR"/*.app/Contents/*/XScreenSaverUpdater                 \
+   ; do                                                                        \
+   V=`otool -s __DATA __objc_imageinfo "$$D"                           \
+      | grep ' 00 02 00 '` ;                                           \
+   if [ ! -z "$$V" ]; then                                             \
+     echo "$$D has GC enabled" ;                                       \
+     RESULT=1 ;                                                                \
+   fi ;                                                                        \
+  done ;                                                               \
+                                                                       \
   if [ "$$RESULT" = 0 ]; then echo "GC enabled" ; fi ;                 \
   exit $$RESULT
 
@@ -118,22 +181,20 @@ check_coretext:
   exit $$RESULT
 
 
-update_thumbs::
-       ./update-thumbnail.pl $(THUMBDIR) build/Release/*.saver
-
-
 # Arrrrgh
 ios-function-table.m::
        @./build-fntable.pl build/Debug-iphonesimulator/XScreenSaver.app $@
 
 
 echo_tarfiles:
-       @echo `find . \
-         \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
-            -o -name 'jwz.*' -o -name 'Screen Savers' \) \
-            -prune \) \
-         -o \( -type f -o -type l \) -print \
-       | sed 's@^\./@@' \
+       @echo `( find .                                                 \
+         \( \( -name '.??*' -o -name build -o -name CVS -o -name '*~*' \
+            -o -name 'jwz.*' -o -name 'Screen Savers'                  \
+             -o -name xscreensaver.xcodeproj \)                                \
+            -prune \)                                                  \
+         -o \( -type f -o -type l \) -print ;                          \
+         echo xscreensaver.xcodeproj/project.pbxproj )                 \
+       | sed 's@^\./@@'                                                \
        | sort`
 
 update_plist_version:
@@ -192,8 +253,9 @@ build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.
                                                                        \
   DIST="installer.xml" ;                                               \
   STAGE="build/Release/pkg_stage" ;                                    \
-  PKG1="$@" ;                                                          \
-  PKG2="$$STAGE/contents.pkg" ;                                                \
+  FINAL="$@" ;                                                         \
+  UNSIGNED="$$STAGE/contents.pkg" ;                                    \
+  PRODUCT="$$STAGE/product_unsigned.pkg" ;                             \
   SCRIPTS="$$STAGE/scripts" ;                                          \
   RES="$$STAGE/resources" ;                                            \
                                                                        \
@@ -206,21 +268,21 @@ build/Release/installer.pkg: installer.rtf installer.xml installer.sh installer.
   cp -p installer.rtf "$$RES/welcome.rtf" ;                            \
                                                                        \
   pkgbuild --identifier "$(PKGID)" --version "$$V"                     \
-          --scripts "$$SCRIPTS" --nopayload "$$PKG2" ;                 \
-  codesign -vfs $(CERT) "$$PKG2" ;                                     \
-  codesign -vd "$$PKG2" ;                                              \
+          --scripts "$$SCRIPTS" --nopayload "$$UNSIGNED" ;             \
                                                                        \
   productbuild --distribution "$$DIST" --resources "$$RES"             \
-              --package-path "$$STAGE" --version "$$V" "$$PKG1" ;      \
-  codesign -vfs $(CERT) "$$PKG1" ;                                     \
-  codesign -vd "$$PKG1" ;                                              \
+              --package-path "$$STAGE" --version "$$V" "$$PRODUCT" ;   \
+                                                                       \
+  productsign --sign $(CERT) "$$PRODUCT" "$$FINAL" ;                   \
+  spctl --assess --verbose=4 --type install "$$FINAL" ;                        \
                                                                        \
   rm -rf "$$STAGE" ;                                                   \
 
 
 # -format UDBZ saves 4% (~1.2 MB) over UDZO.
 dmg:: distdepend
-dmg:: check_versions check_gc check_coretext
+dmg:: check_versions check_coretext
+#dmg:: check_gc
 dmg:: build/Release/installer.pkg
 dmg::
        @                                                                     \
@@ -259,13 +321,14 @@ dmg::
    for r in $$retired ; do                                                   \
     if [ "$$ff" = "$$r" ]; then ok=no ; fi ;                                 \
    done ;                                                                    \
-   DSTNAME="" ;                                                                      \
+   if [ "$$ff" = testx11 ]; then ok=no ; fi ;                                \
    if [ "$$f2" = "XScreenSaverUpdater.app" ]; then                           \
-     DSTNAME=".$$f2" ;                                                       \
-   fi ;                                                                              \
-   if [ "$$ok" = yes ]; then                                                 \
-    echo + cp -pR "$$f" "$$DST/$$DSTNAME" ;                                  \
-           cp -pR "$$f" "$$DST/$$DSTNAME" ;                                  \
+    DST_HACK="XScreenSaver.updater" ;                                        \
+    echo + tar ... "$$DST/$$DST_HACK" ;                                              \
+    ( cd $$SRC ; tar -czf - "$$f2" ) > "$$DST/$$DST_HACK" ;                  \
+   elif [ "$$ok" = yes ]; then                                               \
+    echo + cp -pR "$$f" "$$DST/" ;                                           \
+           cp -pR "$$f" "$$DST/" ;                                           \
    else                                                                              \
     echo skipping "$$f" ;                                                    \
    fi ;                                                                              \
@@ -275,18 +338,31 @@ dmg::
   cp -p bindist.rtf "$$STAGE/Read Me.rtf" ;                                  \
   cp -p build/Release/installer.pkg "$$PKG" ;                                \
   cp -p bindist-DS_Store "$$STAGE/.DS_Store" ;                               \
-  cp -p bindist.webloc "$$STAGE/Get the iPhone:iPad Version.webloc" ;        \
+  cp -p bindist.webloc "$$STAGE/" ;                                          \
   cp -p XScreenSaverDMG.icns "$$STAGE/.VolumeIcon.icns" ;                    \
   ${SETFILE} -a C "$$STAGE" ;                                                \
   ${SETFILE} -a E "$$STAGE"/*.{rtf,pkg,webloc} ;                             \
   $(SETICON) -d ../../xdaliclock/OSX/daliclockSaver.icns                     \
                "$$DST/DaliClock.saver" ;                                     \
   $(SETICON) -d XScreenSaverFolder.icns "$$DST" ;                            \
+  $(SETICON) -d XScreenSaver.icns "$$DST"/*.saver ;                          \
+  $(SETICON) -d SaverRunner.icns "$$DST"/*.app ;                             \
   $(SETICON) -d XScreenSaverWebloc.icns "$$STAGE"/*.webloc ;                 \
   $(SETICON) -d XScreenSaverPkg.icns "$$STAGE"/*.pkg ;                       \
+  mv "$$STAGE/bindist.webloc" "$$STAGE/Get the iPhone:iPad Version.webloc" ;  \
+                                                                             \
+  set +x ;                                                                   \
+  echo "Checking signatures..." ;                                            \
+  spctl --assess --type install "$$PKG" ;                                    \
+  spctl --assess --type execute "$$SRC/XScreenSaverUpdater.app" ;            \
+  spctl --assess --type execute "$$DST/"*.app ;                                      \
+  spctl --assess --type install "$$DST/"*.saver ;                            \
+  set -x ;                                                                   \
+                                                                             \
   hdiutil makehybrid -quiet -ov -hfs -hfs-volume-name "$$VOLNAME"            \
     -hfs-openfolder "$$STAGE" "$$STAGE" -o "$$TMPDMG" ;                              \
   rm -rf "$$STAGE" ;                                                         \
+                                                                             \
   hdiutil convert -quiet -ov -format UDBZ -imagekey zlib-level=9             \
     "$$TMPDMG" -o "$$DMG" ;                                                  \
   xattr -w com.apple.quarantine "0000;00000000;;" "$$DMG" ;                  \
@@ -351,3 +427,8 @@ reset_prefs::
        $$W2 "$$domain.XMatrix" matrixFont small ;                            \
        $$W2 "$$domain.XMatrix" textMode literal ;                            \
        $$W2 "$$domain.XMatrix" textLiteral "MONKEY BUTTER" ;                 \
+
+# defaults -currentHost write org.jwz.xscreensaver.FontGlide debugMetrics -bool true
+# defaults -currentHost write org.jwz.xscreensaver.StarWars debug -bool true
+# defaults -currentHost write org.jwz.xscreensaver.StarWars textMode file
+# defaults -currentHost write org.jwz.xscreensaver.StarWars textFile ~/src/xscreensaver/hacks/glx/zalgo.txt