Skip to content

Commit

Permalink
build.sh: facilitate fat binary builds on MacOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Sep 13, 2024
1 parent 415d4f0 commit d82c533
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh -e
#!/bin/sh
set -e
#
# The script allows to override 'CC', 'CFLAGS' and 'flavour' at command
# line, as well as specify additional compiler flags. For example to
Expand Down Expand Up @@ -43,6 +44,13 @@ while [ "x$1" != "x" ]; do
-shared) shared=1;;
-dll) shared=1; dll=".dll";;
-m*) CFLAGS="$CFLAGS $1";;
-target|-arch)
if expr "$CFLAGS" : ".*-arch " >/dev/null; then
cflags="$cflags $1 $2"
else
CFLAGS="$CFLAGS $1 $2"
fi
shift;;
-*target*) CFLAGS="$CFLAGS $1";;
-*) cflags="$cflags $1";;
*=*) eval "$1";;
Expand Down Expand Up @@ -76,9 +84,11 @@ if [ -z "${CROSS_COMPILE}${AR}" ] && echo ${predefs} | grep -q clang; then
env PATH="$search_dirs:$PATH" which llvm-ar > /dev/null 2>&1; then
PATH="$search_dirs:$PATH"
AR=llvm-ar
RANLIB=llvm-ranlib
fi
fi
AR=${AR:-${CROSS_COMPILE}ar}
RANLIB=${RANLIB:-${CROSS_COMPILE}ranlib}

if echo ${predefs} | grep -q x86_64; then
if (grep -q -e '^flags.*\badx\b' /proc/cpuinfo) 2>/dev/null; then
Expand All @@ -101,6 +111,7 @@ trap '[ $? -ne 0 ] && rm -f libblst.a; rm -f *.o ${TMPDIR}/*.blst.$$' 0
(set -x; ${CC} ${CFLAGS} -c ${TOP}/src/server.c)
(set -x; ${CC} ${CFLAGS} -c ${TOP}/build/assembly.S)
(set -x; ${AR} rc libblst.a *.o)
which ${RANLIB} > /dev/null 2>&1 && (set -x; ${RANLIB} libblst.a)

if [ $shared ]; then
case $flavour in
Expand Down

0 comments on commit d82c533

Please sign in to comment.