Skip to content

Commit

Permalink
Makefile: macos fixup: generate proper symbols on debug with LTO, sep…
Browse files Browse the repository at this point in the history
…arate options from serenity
  • Loading branch information
n30f0x committed Oct 31, 2024
1 parent 0bce89b commit bda868e
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ else
override BIN_EXT :=
ifeq ($(OS),darwin)
override LIB_EXT := .dylib
ifdef USE_EXPERIMENTAL_SHIT
override LDFLAGS := -lobjc -framework Cocoa
endif
else
override LIB_EXT := .so
endif
Expand Down Expand Up @@ -211,8 +208,23 @@ ifneq (,$(findstring linux,$(OS))$(findstring bsd,$(OS))$(findstring sunos,$(OS)
USE_X11 ?= 1
endif

ifneq (,$(findstring darwin,$(OS))$(findstring serenity,$(OS)))
# Enable SDL2 on Darwin, Serenity by default
ifneq (,$(findstring darwin,$(OS)))
# Enable SDL2 on Darwin by default
USE_SDL ?= 2
ifeq ($(USE_ISOLATION),1)
# Foundation/Cocoa runtime
override LDFLAGS += -lobjc -framework Cocoa
endif
ifneq (,1 $(filter$(LTO_SUPPORTED,$(filter 1,$(USE_DEBUG)$(USE_DEBUG_FULL)))))
# Generate symbols with lto on debug on darwin>=15.x
override LDFLAGS += -Wl,-object_path_lto,$(BUILDDIR)/obj/lto
# Generate dSYM symbol bundle explicitly on debug on darwin>=15.x
override CFLAGS += -dsym-dir $(BUILDDIR)/$(BINARY).dSYM
endif
endif

ifneq (,$(findstring serenity,$(OS)))
# Enable SDL2 on Serenity by default
USE_SDL ?= 2
endif

Expand Down Expand Up @@ -561,7 +573,10 @@ endif
# Sign binaries on MacOS host
ifneq (,$(if $(findstring darwin,$(OS)),$(shell which codesign $(NULL_STDERR))))
ENTITLEMENTS = $(SRCDIR)/bindings/macos_codesign/rvvm.entitlements
override CODESIGN = plutil $(ENTITLEMENTS) && codesign -s - -o library,runtime --timestamp --verbose=4 --verify --strict --entitlements $(ENTITLEMENTS) $@ && spctl --assess --verbose=4 --type execute $@
override ENT = $(info $(WHITE)[$(GREEN)ENT$(WHITE)] $(shell plutil $(ENTITLEMENTS))$(RESET))
# override CODESIGN = $(info $(WHITE)[$(GREEN)CODESIGN$(WHITE)] $(shell codesign -s - -o runtime,library --timestamp --preserve-metadata=entitlements,requirements,flags,runtime --entitlements $(ENTITLEMENTS) $@)$(RESET))
override CODESIGN = codesign -s - -o runtime,library --timestamp --preserve-metadata=entitlements,requirements,flags,runtime --entitlements $(ENTITLEMENTS) $@
override VERIFY = $(info $(WHITE)[$(GREEN)VERIFY$(WHITE)] $(shell spctl --assess --verbose=4 --type execute $@) $(RESET))
endif

#
Expand Down Expand Up @@ -592,13 +607,17 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp Makefile
$(BINARY): $(OBJS)
$(info $(WHITE)[$(GREEN)LD$(WHITE)] $@ $(RESET))
@$(CC_LD) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@
# @$(CODESIGN)
@$(ENT)
@$(CODESIGN)
@$(VERIFY)

# Shared library
$(SHARED): $(LIB_OBJS)
$(info $(WHITE)[$(GREEN)LD$(WHITE)] $@ $(RESET))
@$(CC_LD) $(CFLAGS) $(LIB_OBJS) $(LDFLAGS) -shared -o $@
# @$(CODESIGN)
@$(ENT)
@$(CODESIGN)
@$(VERIFY)

# Static library
$(STATIC): $(LIB_OBJS)
Expand Down

0 comments on commit bda868e

Please sign in to comment.