build-scripts: modernized gcc-fat.sh for Big Sur and ARM64. Put these in "clang-fat.sh" and "clang++-fat.sh" in case someone still needs 32-bit x86 support from the old scripts. Fixes #4350.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
diff --git a/build-scripts/clang++-fat.sh b/build-scripts/clang++-fat.sh
new file mode 100755
index 0000000..d337109
--- /dev/null
+++ b/build-scripts/clang++-fat.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# Build Universal binaries on Mac OS X, thanks Ryan!
+#
+# Usage: ./configure CXX="sh clang++-fat.sh" && make && rm -rf arm64 x64
+
+DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
+
+# Intel 64-bit compiler flags (10.6 runtime compatibility)
+CLANG_COMPILE_X64="clang++ -arch x86_64 -mmacosx-version-min=10.6 \
+-I/usr/local/include"
+
+CLANG_LINK_X64="-mmacosx-version-min=10.6"
+
+# ARM 64-bit compiler flags (11.0 runtime compatibility)
+CLANG_COMPILE_ARM64="clang++ -arch arm64 -mmacosx-version-min=11.0 \
+-I/usr/local/include"
+
+CLANG_LINK_ARM64="-mmacosx-version-min=11.0"
+
+
+# Output both Intel and ARM object files
+args="$*"
+compile=yes
+link=yes
+while test x$1 != x; do
+ case $1 in
+ --version) exec clang++ $1;;
+ -v) exec clang++ $1;;
+ -V) exec clang++ $1;;
+ -print-prog-name=*) exec clang++ $1;;
+ -print-search-dirs) exec clang++ $1;;
+ -E) CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
+ CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
+ compile=no; link=no;;
+ -c) link=no;;
+ -o) output=$2;;
+ *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
+ esac
+ shift
+done
+if test x$link = xyes; then
+ CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
+ CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
+fi
+if test x"$output" = x; then
+ if test x$link = xyes; then
+ output=a.out
+ elif test x$compile = xyes; then
+ output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
+ fi
+fi
+
+# Compile ARM 64-bit
+if test x"$output" != x; then
+ dir=arm64/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "arm64/$1" && test "$1" != "$output"; then
+ arm64_args="$arm64_args arm64/$1"
+ else
+ arm64_args="$arm64_args $1"
+ fi
+ shift
+done
+$CLANG_COMPILE_ARM64 $arm64_args || exit $?
+if test x"$output" != x; then
+ cp $output arm64/$output
+fi
+
+# Compile Intel 64-bit
+if test x"$output" != x; then
+ dir=x64/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "x64/$1" && test "$1" != "$output"; then
+ x64_args="$x64_args x64/$1"
+ else
+ x64_args="$x64_args $1"
+ fi
+ shift
+done
+$CLANG_COMPILE_X64 $x64_args || exit $?
+if test x"$output" != x; then
+ cp $output x64/$output
+fi
+
+if test x"$output" != x; then
+ lipo -create -o $output arm64/$output x64/$output
+fi
diff --git a/build-scripts/clang-fat.sh b/build-scripts/clang-fat.sh
new file mode 100755
index 0000000..38c0727
--- /dev/null
+++ b/build-scripts/clang-fat.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Build Universal binaries on Mac OS X, thanks Ryan!
+#
+# Usage: ./configure CC="sh clang-fat.sh" && make && rm -rf arm64 x64
+
+DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
+
+# Intel 64-bit compiler flags (10.6 runtime compatibility)
+CLANG_COMPILE_X64="clang -arch x86_64 -mmacosx-version-min=10.6 \
+-DMAC_OS_X_VERSION_MIN_REQUIRED=1060 \
+-I/usr/local/include"
+
+CLANG_LINK_X64="-mmacosx-version-min=10.6"
+
+# ARM 64-bit compiler flags (11.0 runtime compatibility)
+CLANG_COMPILE_ARM64="clang -arch arm64 -mmacosx-version-min=11.0 \
+-I/usr/local/include"
+
+CLANG_LINK_ARM64="-mmacosx-version-min=11.0"
+
+
+# Output both Intel and ARM object files
+args="$*"
+compile=yes
+link=yes
+while test x$1 != x; do
+ case $1 in
+ --version) exec clang $1;;
+ -v) exec clang $1;;
+ -V) exec clang $1;;
+ -print-prog-name=*) exec clang $1;;
+ -print-search-dirs) exec clang $1;;
+ -E) CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
+ CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
+ compile=no; link=no;;
+ -c) link=no;;
+ -o) output=$2;;
+ *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
+ esac
+ shift
+done
+if test x$link = xyes; then
+ CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
+ CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
+fi
+if test x"$output" = x; then
+ if test x$link = xyes; then
+ output=a.out
+ elif test x$compile = xyes; then
+ output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
+ fi
+fi
+
+# Compile Intel 64-bit
+if test x"$output" != x; then
+ dir=x64/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "x64/$1" && test "$1" != "$output"; then
+ x64_args="$x64_args x64/$1"
+ else
+ x64_args="$x64_args $1"
+ fi
+ shift
+done
+$CLANG_COMPILE_X64 $x64_args || exit $?
+if test x"$output" != x; then
+ cp $output x64/$output
+fi
+
+# Compile ARM 64-bit
+if test x"$output" != x; then
+ dir=arm64/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "arm64/$1" && test "$1" != "$output"; then
+ arm64_args="$arm64_args arm64/$1"
+ else
+ arm64_args="$arm64_args $1"
+ fi
+ shift
+done
+$CLANG_COMPILE_ARM64 $arm64_args || exit $?
+if test x"$output" != x; then
+ cp $output arm64/$output
+fi
+
+
+if test x"$output" != x; then
+ lipo -create -o $output arm64/$output x64/$output
+fi
+