Added build helper script for MacOS X.

This commit is contained in:
LoRd_MuldeR 2022-12-06 01:58:51 +01:00
parent e48efa984a
commit c6ecc3c813
3 changed files with 42 additions and 9 deletions

View File

@ -1,3 +1,8 @@
UNAME := $(strip $(shell uname))
ifeq ($(UNAME),)
$(error Operating system could not be detected!)
endif
DUMPMACHINE := $(strip $(shell $(CC) -dumpmachine))
ifeq ($(DUMPMACHINE),)
$(error C compiler could not be detected!)
@ -20,16 +25,21 @@ else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
XCFLAGS += -march=pentiumpro -mtune=intel
endif
ifeq ($(firstword $(filter %-mingw32 %-windows-gnu %-cygwin,$(DUMPMACHINE))),)
DLL_LDFLAGS = -shared
DLL_SUFFIX := .so
else
ifneq ($(firstword $(filter %-mingw32 %-windows-gnu %-cygwin,$(DUMPMACHINE))),)
DLL_LDFLAGS = -shared -Wl,--out-implib,$@.a
EXE_SUFFIX := .exe
DLL_SUFFIX := .dll
ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
XLDFLAGS += -Wl,--large-address-aware
endif
else
ifneq ($(findstring -apple-darwin,$(DUMPMACHINE)),)
DLL_LDFLAGS = -dynamiclib
DLL_SUFFIX := .dylib
else
DLL_LDFLAGS = -shared
DLL_SUFFIX := .so
endif
endif
ifneq ($(STATIC),)
@ -45,8 +55,12 @@ ifneq ($(STRIP),)
DLL_LDFLAGS += -Wl,--strip-all
endif
ifneq ($(firstword $(filter MINGW32_NT-% MINGW64_NT-% CYGWIN_NT-%,$(shell uname))),)
ifneq ($(firstword $(filter MINGW32_NT-% MINGW64_NT-% CYGWIN_NT-%,$(UNAME))),)
ENV_LDPATH := PATH
else
ifneq ($(firstword $(UNAME)),Darwin)
ENV_LDPATH := LD_LIBRARY_PATH
else
ENV_LDPATH := DYLD_LIBRARY_PATH
endif
endif

View File

@ -14,8 +14,8 @@ cp -rfv "libhashset/include/"*.h "out/include"
case "${mode}" in
gnu)
for target in i686 x86_64 aarch64; do
compiler="${target}-linux-gnu-gcc"
for cpu in i686 x86_64 aarch64; do
compiler="${cpu}-linux-gnu-gcc"
target="$("${compiler}" -dumpmachine)"
echo -e "--------------------------------\n${target}\n--------------------------------"
make CC="${compiler}" STRIP=1
@ -29,8 +29,8 @@ case "${mode}" in
done
;;
musl)
for target in i686 x86_64 arm64; do
compiler="/usr/local/musl/${target}/bin/musl-gcc"
for cpu in i686 x86_64 arm64; do
compiler="/usr/local/musl/${cpu}/bin/musl-gcc"
target="$("${compiler}" -dumpmachine | sed 's/-gnu/-musl/i')"
echo -e "--------------------------------\n${target}\n--------------------------------"
make CC="${compiler}" STATIC=1 STRIP=1

19
etc/utils/build-macos.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/zsh
set -e
cd -- "${0:a:h}/../../"
mkdir -pv "out/include"
cp -rfv "libhashset/include/"*.h "out/include"
for cpu in x86_64 aarch64; do
target="${cpu}-apple-darwin"
echo -e "--------------------------------\n${target}\n--------------------------------"
make CC="cc -target ${target}"
mkdir -pv "out/lib/${target}" "out/bin/${target}"
cp -rv "libhashset/lib/"* "out/lib/${target}"
for i in example test; do
for j in hash-set hash-map; do
cp -fv "${i}/${j}/bin/${i}-${j}" "out/bin/${target}"
done
done
done