Seems over-complicated to use SDK-specific subdirectories.
[dcpomatic.git] / platform / osx / make_dmg.sh
index a77fba23901a667ee3cda31f7b92d194a2345020..9ba05ac96485846a00ecb7e303f6264a12f7edf3 100644 (file)
@@ -1,9 +1,8 @@
 #!/bin/bash
 #
-SYNTAX="make_dmg.sh <environment> <builddir> <type> <apple-id> <apple-password>"
-# where <type> is arm-intel-64, intel-32-64 or arm64
+SYNTAX="make_dmg.sh <environment> <builddir> <apple-id> <apple-password>"
 #
-# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist arm-intel-64 foo@bar.net opensesame
+# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist foo@bar.net opensesame
 
 # Don't set -e here as egrep (used a few times) returns 1 if no matches
 # were found.
@@ -14,15 +13,8 @@ version=`git describe --tags --abbrev=0 | sed -e "s/v//"`
 DMG_SIZE=256
 ENV=$1
 ROOT=$2
-TYPE=$3
-APPLE_ID=$4
-APPLE_PASSWORD=$5
-
-if [ "$TYPE" != "arm-intel-64" -a "$TYPE" != "intel-32-64" -a "$TYPE" != "arm64" ]; then
-    echo $SYNTAX
-    echo "where <type> is arm-intel-64, intel-32-64 or arm64"
-    exit 1
-fi
+APPLE_ID=$3
+APPLE_PASSWORD=$4
 
 # This is our work area for making up the .dmgs
 mkdir -p build/platform/osx
@@ -35,117 +27,47 @@ cat <<EOF > entitlements.plist
 <dict>
   <key>com.apple.security.cs.disable-library-validation</key>
   <true/>
+  <key>com.apple.security.cs.allow-dyld-environment-variables</key>
+  <true/>
 </dict>
 </plist>
 EOF
 
 function copy {
-    case $TYPE in
-       arm-intel-64)
-           for f in $1/arm64/$2; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$3/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
-                   mkdir -p "$3"
-                   lipo -create $f $g -output "$3/`basename $f`"
-               fi
-           done
-           ;;
-       intel-32-64)
-           for f in $1/i386/$2; do
+       for f in $1/arm64/$2; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$3/`basename $f`"
+                       ln -s $(readlink $f) "$3/`basename $f`"
                else
-                   g=`echo $f | sed -e "s/\/i386\//\/x86_64\//g"`
-                   mkdir -p "$3"
-                   lipo -create $f $g -output "$3/`basename $f`"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$3"
+                       lipo -create $f $g -output "$3/`basename $f`"
                fi
-           done
-           ;;
-       arm64)
-           if [ -h $1/$2 ]; then
-               ln -s $(readlink $1/$2) "$3/`basename $f`"
-            else
-               cp $1/$2 "$3"
-           fi
-           ;;
-    esac
+       done
 }
 
 function copy_lib_root {
-    case $TYPE in
-       arm-intel-64)
-           for f in $ROOT/arm64/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
-               fi
-           done
-           ;;
-       intel-32-64)
-           for f in $ROOT/intel-32-64/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/i386\//\/x86_64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
-               fi
-           done
-           ;;
-       arm64)
-           for f in $ROOT/lib/$1*.dylib; do
+       for f in $ROOT/arm64/lib/$1*.dylib; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
+                       ln -s $(readlink $f) "$2/`basename $f`"
                else
-                   mkdir -p "$2"
-                   cp $f "$2"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$2"
+                       lipo -create $f $g -output "$2/`basename $f`"
                fi
-           done
-           ;;
-    esac
+       done
     to_relink="$to_relink|$1"
 }
 
 function copy_lib_env {
-    case $TYPE in
-       arm-intel-64)
-           for f in $ENV/arm64/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
-               fi
-           done
-           ;;
-       intel-32-64)
-           for f in $ENV/i386/lib/$1*.dylib; do
+       for f in $ENV/arm64/lib/$1*.dylib; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
+                       ln -s $(readlink $f) "$2/`basename $f`"
                else
-                   g=`echo $f | sed -e "s/\/i386\//\/x86_64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$2"
+                       lipo -create $f $g -output "$2/`basename $f`"
                fi
-           done
-           ;;
-       arm64)
-           for f in $ENV/arm64/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   mkdir -p "$2"
-                   cp $f "$2"
-               fi
-           done
-           ;;
-    esac
+       done
     to_relink="$to_relink|$1"
 }
 
@@ -224,17 +146,7 @@ function copy_libs {
 # @param #1 directory to copy to
 function copy_resources {
     local dest="$1"
-    case $TYPE in
-        arm-intel-64)
-           local prefix=$ROOT/x86_64
-           ;;
-       intel-32-64)
-           local prefix=$ROOT/x86_64
-           ;;
-       arm64)
-           local prefix=$ROOT
-           ;;
-    esac
+       local prefix=$ROOT/x86_64
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic_small.png "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2.icns "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_kdm.icns "$dest"
@@ -308,19 +220,13 @@ function relink_relative {
     local linkers=("$@")
 
     for obj in "${linkers[@]}"; do
-       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
+       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
        changes=""
        for dep in $deps; do
            base=`basename $dep`
-           if [ "$TYPE" == "universal" ]; then
-               # $dep will be a path within x86_64/; make i386 and arm64 paths too
-               dep_i386=`echo $dep | sed -e "s/\/x86_64\//\/i386\//g"`
-               changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep_i386 @executable_path/../Frameworks/$base"
+               # $dep will be a path within x86_64; make arm64 path too
                dep_arm64=`echo $dep | sed -e "s/\/x86_64\//\/arm64\//g"`
                changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep_arm64 @executable_path/../Frameworks/$base"
-           else
-               changes="$changes -change $dep @executable_path/../Frameworks/$base"
-           fi
        done
        if test "x$changes" != "x"; then
            install_name_tool $changes -id `basename "$obj"` "$obj"
@@ -337,11 +243,11 @@ function relink_absolute {
     local linkers=("$@")
 
     for obj in "${linkers[@]}"; do
-       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
-       for dep in $deps; do
-           base=`basename $dep`
-            install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
-       done
+               deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
+               for dep in $deps; do
+                       base=`basename $dep`
+                       install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
+               done
     done
 }
 
@@ -478,19 +384,7 @@ function setup {
     copy_resources "$approot/Resources"
 }
 
-case $TYPE in
-    arm-intel-64)
-       # copy() writes the universal binary to arm64
-       prefix=$ROOT/arm64
-       ;;
-    intel-32-64)
-       # copy() writes the universal binary to i386
-       prefix=$ROOT/i386
-       ;;
-    arm64)
-       prefix=$ROOT
-       ;;
-esac
+prefix=$ROOT/arm64
 
 # DCP-o-matic main
 setup "DCP-o-matic 2.app"