diff --git a/src/Makefile b/src/Makefile index 81926eba..c0b9df7f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -296,7 +296,8 @@ ifeq "$(shell uname -s)" "Darwin" APPNAME := VeraCrypt export VC_OSX_TARGET ?= 12 - export VC_OSX_SDK ?= $(VC_OSX_TARGET) + # use the output of the command "xcrun --show-sdk-version" to set the SDK version if not set + export VC_OSX_SDK ?= $(shell xcrun --show-sdk-version) #check to see if XCode 3 path exists.Otherwise, use XCode 4 path VC_OSX_SDK_PATH := /Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk @@ -316,29 +317,41 @@ ifeq "$(shell uname -s)" "Darwin" C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_MACOSX -mmacosx-version-min=$(VC_OSX_TARGET) -isysroot $(VC_OSX_SDK_PATH) LFLAGS += -mmacosx-version-min=$(VC_OSX_TARGET) -Wl,-syslibroot $(VC_OSX_SDK_PATH) + #Xcode 15 linker emits a warning "no platform load command found" when linking object files generated by yasm + # To suppress this warning, we need to use -Wl,-ld_classic flag in order to use the old ld64 linker + # https://mjtsai.com/blog/2024/03/15/xcode-15-no-platform-load-command-found/ + # Check Xcode version for using specific linker flag + XCODE_VERSION := $(shell xcodebuild -version 2>/dev/null | grep 'Xcode' | sed -E 's/Xcode ([0-9]+).*/\1/') + ifneq ($(XCODE_VERSION),) + ifeq "$(shell expr $(XCODE_VERSION) \>= 15)" "1" + LFLAGS += -Wl,-ld_classic + endif + else + $(error Xcode not found, please check your installation) + endif + WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH) - ifeq "$(CPU_ARCH)" "x64" - CPU_ARCH = x86 - endif - - ifeq "$(CPU_ARCH)" "arm64" - CPU_ARCH = arm64 + + # Set x86 assembly flags (-msse2, -mssse3, -msse4.1) + # Apply flags if SIMD_SUPPORTED is 1 or if not in local development build (we are creating universal binary in this case) + ifneq "$(LOCAL_DEVELOPMENT_BUILD)" "true" + SIMD_SUPPORTED = 1 endif - ifneq "$(CPU_ARCH)" "arm64" - CFLAGS += -msse2 - CXXFLAGS += -msse2 - endif + ifeq "$(SIMD_SUPPORTED)" "1" + CFLAGS += -msse2 + CXXFLAGS += -msse2 - ifeq "$(origin SSSE3)" "command line" - CFLAGS += -mssse3 - CXXFLAGS += -mssse3 - endif + ifeq "$(origin SSSE3)" "command line" + CFLAGS += -mssse3 + CXXFLAGS += -mssse3 + endif - ifeq "$(origin SSE41)" "command line" - CFLAGS += -mssse3 -msse4.1 - CXXFLAGS += -mssse3 -msse4.1 + ifeq "$(origin SSE41)" "command line" + CFLAGS += -mssse3 -msse4.1 + CXXFLAGS += -mssse3 -msse4.1 + endif endif AS ?= $(BASE_DIR)/Build/Tools/MacOSX/yasm @@ -347,52 +360,38 @@ ifeq "$(shell uname -s)" "Darwin" ifeq "$(TC_BUILD_CONFIG)" "Release" - export DISABLE_PRECOMPILED_HEADERS := 1 + export DISABLE_PRECOMPILED_HEADERS := 1 - S := $(C_CXX_FLAGS) - C_CXX_FLAGS = $(subst -MMD,,$(S)) + C_CXX_FLAGS := $(subst -MMD,,$(C_CXX_FLAGS)) -gfull + LFLAGS += -Wl,-dead_strip - # only build local arch in development builds - ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true" - ifeq "$(CPU_ARCH)" "arm64" - C_CXX_FLAGS += -gfull -arch $(CPU_ARCH) - LFLAGS += -Wl,-dead_strip -arch $(CPU_ARCH) + # Initialize architecture flag + ARCH_FLAG := -arch x86_64 + + # Set architecture flags based on build type and CPU architecture + ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true" + ifeq "$(CPU_ARCH)" "arm64" + ARCH_FLAG := -arch arm64 + endif + WX_CONFIGURE_FLAGS += --disable-universal_binary + else + # Legacy build settings + ifdef VC_LEGACY_BUILD + ARCH_FLAG += -arch i386 + WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64 else - C_CXX_FLAGS += -gfull -arch x86_64 - LFLAGS += -Wl,-dead_strip -arch x86_64 - endif - else - # leave previous logic as is - C_CXX_FLAGS += -gfull -arch x86_64 - LFLAGS += -Wl,-dead_strip -arch x86_64 - endif - - WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-svg - - #----- Legacy build: we build both 32-bit and 64-bit ---- - ifdef VC_LEGACY_BUILD - C_CXX_FLAGS += -arch i386 - LFLAGS += -arch i386 - WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64 - else - CXXFLAGS += -std=c++11 - ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true" - ifeq "$(CPU_ARCH)" "arm64" - C_CXX_FLAGS += -arch arm64 - LFLAGS += -arch arm64 - else - C_CXX_FLAGS += -arch x86_64 - LFLAGS += -arch x86_64 - endif - WX_CONFIGURE_FLAGS += --disable-universal_binary - else - # leave previous logic as is - C_CXX_FLAGS += -arch arm64 - LFLAGS += -arch arm64 + CXXFLAGS += -std=c++11 + # Non-development build defaults to universal binary for arm64 and x86_64 + ARCH_FLAG += -arch arm64 WX_CONFIGURE_FLAGS += --enable-universal_binary=arm64,x86_64 endif endif + # Apply architecture flags + C_CXX_FLAGS += $(ARCH_FLAG) + LFLAGS += $(ARCH_FLAG) + + WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-svg WXCONFIG_CFLAGS += -gfull WXCONFIG_CXXFLAGS += -gfull