Created
June 16, 2024 01:25
-
-
Save zeusdeux/7f8aafca8b78b7931a235fc1ff4601ce to your computer and use it in GitHub Desktop.
Build static universal raylib as libraylib.a on macos (libraylib.a)
This file contains 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/sh | |
set -e | |
function build_raylib_macos { | |
curr_dir="$(basename $(pwd))" | |
if [[ "$curr_dir" != "src" ]]; | |
then | |
echo "Put me in the ./src dir and run me from there." | |
return 1 | |
else | |
if [[ ! -d "build" ]]; | |
then | |
mkdir build | |
echo "Created ./build" | |
fi | |
# this is to make sure to use ranlib and ar that ship macos | |
# and not what you might have installed via binutils package | |
export PATH="/usr/bin:$PATH" | |
which ranlib # should be /usr/bin/ranlib | |
which ar # should be /usr/bin/ar | |
export MACOSX_DEPLOYMENT_TARGET=10.9 | |
export RAYLIB_API_VERSION=`ggrep -Po 'RAYLIB_API_VERSION\s*=\s\K(.*)' Makefile` | |
export RAYLIB_VERSION=`ggrep -Po 'RAYLIB_VERSION\s*=\s\K(.*)' Makefile` | |
rm -f ./build/* | |
make clean | |
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" && mv libraylib.a ./libraylib_x86_64.a | |
make clean | |
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B && mv libraylib.a ./libraylib_arm64.a | |
make clean | |
lipo -create -output ./build/libraylib.a ./libraylib_x86_64.a ./libraylib_arm64.a | |
echo | |
file ./build/libraylib.a | |
echo "If using precompiled binaries, make sure to put the *.dylib in a different folder than libraylib.a" | |
echo "as clang refuses to link if both libraylib.a and libraylib*.dylib are present side by side on disk." | |
return 0 | |
fi | |
} | |
build_raylib_macos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment