Created
April 13, 2021 15:21
-
-
Save kategray/bba69bb679dd1bfcd521af80dd87536b to your computer and use it in GitHub Desktop.
Build universal (x86_64 + arm64) x264 libraries on an intel x86 Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# build-universal.sh | |
# | |
# Compile a universal x264 binary on OS X (intel). | |
# | |
# Requires nasm. Install with homebrew: 'brew install nasm' | |
# | |
CONFIGURE_OPTS='--enable-shared --enable-static' | |
X86_64_TARGET='-target x86_64-apple-macos10.12' | |
X86_64_HOST='x86_64-apple-darwin10' | |
ARM64_TARGET='--target=arm64-apple-macos' | |
ARM64_HOST='arm64-apple-darwin20.3.0' | |
LIB_DIR='/usr/local/lib' | |
OUTPUT_FILES='libx264.a libx264.dylib' | |
rm -rf x86_64 arm64 | |
# Compile x86_64 first | |
make clean && ./configure ${CONFIGURE_OPTS} --host="${X86_64_HOST}" --extra-cflags="${X86_64_TARGET}" && make && DESTDIR=x86_64/ make install | |
# Compile arm64 | |
make clean && ./configure ${CONFIGURE_OPTS} --host="${ARM64_HOST}" --extra-cflags="${ARM64_TARGET}" --extra-asflags="${ARM64_TARGET}" --extra-ldflags="${ARM64_TARGET}" && make && DESTDIR=arm64/ make install | |
# Create a universal binary | |
rm -r universal/ | |
mkdir -p universal/${LIB_DIR} | |
echo "Output Files Placed in universal/" | |
for FILE in ${OUTPUT_FILES}; do | |
echo ${FILE} | |
lipo -create -output universal/${LIB_DIR}/${FILE} x86_64/${LIB_DIR}/${FILE} arm64/${LIB_DIR}/${FILE} | |
lipo -archs universal/${LIB_DIR}/${FILE} | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment