Skip to content

Commit 4e48eb0

Browse files
author
Charlie Fenton
committed
Mac wrapper: build Universal M1 / x86_64 binary
1 parent bec1bdd commit 4e48eb0

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

samples/wrapper/BuildMacWrapper.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# Updated 11/16/11 for XCode 4.1 and OS 10.7
2525
# Updated 7/12/12 for Xcode 4.3 and later which are not at a fixed address
2626
# Updated 8/28/20 for compatibility with Xcode 10
27+
# Updated 8/19/22 to build Universal M1 / x86_64 binary
2728
#
2829
## This script requires OS 10.6 or later
2930
#
@@ -81,20 +82,61 @@ echo
8182

8283
export CC="${GCCPATH}";export CPP="${GPPPATH}"
8384
export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,x86_64"
84-
export VARIANTFLAGS="-isysroot ${SDKPATH} -arch x86_64 -DMAC_OS_X_VERSION_MAX_ALLOWED=1070 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -fvisibility=hidden -fvisibility-inlines-hidden"
85+
export VARIANTFLAGS="-isysroot ${SDKPATH} -arch x86_64 -DMAC_OS_X_VERSION_MAX_ALLOWED=101000 -DMAC_OS_X_VERSION_MIN_REQUIRED=101000 -fvisibility=hidden -fvisibility-inlines-hidden"
8586
export SDKROOT="${SDKPATH}"
86-
export MACOSX_DEPLOYMENT_TARGET=10.7
87-
87+
export MACOSX_DEPLOYMENT_TARGET=10.10
8888

8989
rm -f *.o
9090
rm -f wrapper
9191
make -f Makefile_mac clean
9292
make -f Makefile_mac all
9393

94-
if [ $? -ne 0 ]; then exit 1; fi
94+
if [ $? -ne 0 ]; then
95+
rm -f *.o
96+
rm -f wrapper
97+
exit 1
98+
fi
99+
100+
mv -f wrapper wrapper_x86_64
101+
102+
echo
103+
echo "***************************************************"
104+
echo "******* Building arm64 Application *********"
105+
echo "***************************************************"
106+
echo
107+
108+
export CC="${GCCPATH}";export CPP="${GPPPATH}"
109+
export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,arm64"
110+
export VARIANTFLAGS="-isysroot ${SDKPATH} -arch arm64 -DMAC_OS_X_VERSION_MAX_ALLOWED=101000 -DMAC_OS_X_VERSION_MIN_REQUIRED=101000 -fvisibility=hidden -fvisibility-inlines-hidden"
111+
export SDKROOT="${SDKPATH}"
112+
export MACOSX_DEPLOYMENT_TARGET=10.10
113+
114+
rm -f *.o
115+
make -f Makefile_mac clean
116+
make -f Makefile_mac all
117+
118+
if [ $? -ne 0 ]; then
119+
rm -f *.o
120+
rm -f wrapper_x86_64
121+
rm -f wrapper
122+
exit 1
123+
fi
95124

96125
rm -f *.o
97126

127+
mv -f wrapper wrapper_arm64
128+
129+
lipo -create wrapper_x86_64 wrapper_arm64 -output wrapper
130+
if [ $? -ne 0 ]; then
131+
rm -f wrapper_x86_64
132+
rm -f wrapper_arm64
133+
rm -f wrapper
134+
exit 1
135+
fi
136+
137+
rm -f wrapper_x86_64
138+
rm -f wrapper_arm64
139+
98140
echo
99141
echo "***************************************************"
100142
echo "**************** Build Succeeded! *****************"

0 commit comments

Comments
 (0)