Merge pull request #466 from joshuataylor/feature/macos-arm64

Check if the user is on ARM64, add target to CFLAGS/LDFLAGS
This commit is contained in:
Wolfgang Hommel
2024-03-18 19:26:16 +01:00
committed by GitHub
2 changed files with 34 additions and 0 deletions

View File

@@ -33,4 +33,23 @@ distclean:
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C test distclean
macarm64:
$(MAKE) $(SELECTOR) -C src clean
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C src all
# $(MAKE) $(SELECTOR) -C test all
# $(MAKE) $(SELECTOR) -C test distclean
$(MAKE) $(SELECTOR) -C src install
$(MAKE) $(SELECTOR) -C man install
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/share/doc/faketime/"
$(INSTALL) -m0644 README "${DESTDIR}${PREFIX}/share/doc/faketime/README"
$(INSTALL) -m0644 NEWS "${DESTDIR}${PREFIX}/share/doc/faketime/NEWS"
macarm64full:
$(MAKE) $(SELECTOR) -C src clean
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C src all
$(MAKE) $(SELECTOR) -C test all
# $(MAKE) $(SELECTOR) -C test distclean
.PHONY: all test install uninstall clean distclean

View File

@@ -58,6 +58,21 @@ PREFIX ?= /usr/local
CFLAGS += -DFAKE_SLEEP -DFAKE_INTERNAL_CALLS -DPREFIX='"'${PREFIX}'"' $(FAKETIME_COMPILE_CFLAGS) -DMACOS_DYLD_INTERPOSE -DFAKE_SETTIME
LIB_LDFLAGS += -dynamiclib -current_version 0.9.10 -compatibility_version 0.7
# ARM64 MacOS (M1/M2/M3/Apple Silicon/etc) processors require a target set as their current version, or they
# will receive the following error:
# dyld[6675]: terminating because inserted dylib '/usr/local/lib/faketime/libfaketime.1.dylib' could not be loaded: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/faketime/libfaketime.1.dylib' (no such file), '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e'))
# dyld[6675]: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/faketime/libfaketime.1.dylib' (no such file), '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e'))
# Outputs `arm64` on ARM64
OS := $(shell uname -m)
# Outputs a number, eg 14.4 for MacOS Sonoma 14.4
MACOS_PRODUCT_VERSION := $(shell sw_vers --productVersion | cut -d. -f1,2)
# Check if arm64 is in OS, if so, add the target
ifeq ($(OS),arm64)
CFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
LIB_LDFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
endif
SONAME = 1
LIBS = libfaketime.${SONAME}.dylib
BINS = faketime