From 699d8370e9336ed8a494bc481a414a7b18bab7a3 Mon Sep 17 00:00:00 2001 From: Egon Rath Date: Thu, 17 Sep 2026 09:01:59 +0200 Subject: [PATCH] Make it compile on Mac OS using clang --- Makefile | 12 +++++++++++- src/abstraction_posix.h | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b0dac49..7b49211 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,17 @@ CC = cc CFLAGS = -std=c99 -pedantic -Wall -Wextra -O2 -D_DEFAULT_SOURCE \ -ffunction-sections -fdata-sections $(shell pkg-config --cflags sdl2) -LDFLAGS = $(shell pkg-config --libs sdl2) -lutil -Wl,--gc-sections -s +LDFLAGS = $(shell pkg-config --libs sdl2) -lutil + +# special handling for Mac OS as it's linker does not support +# the garbage collection of unused sections and stripping with the +# same command line as GCC on Linux and Windows. +UNAME = $(shell uname -s) +ifeq ($(UNAME), Darwin) + LDFLAGS += -dead_strip +else + LDFLAGS += -Wl,--gc-sections -s +endif SRC = src/main.c BIN = RunVT diff --git a/src/abstraction_posix.h b/src/abstraction_posix.h index 70b6681..d7143cb 100644 --- a/src/abstraction_posix.h +++ b/src/abstraction_posix.h @@ -8,7 +8,12 @@ #ifndef RUNVT_ABSTRACTION_POSIX_H #define RUNVT_ABSTRACTION_POSIX_H -#include +#if defined(__APPLE__) + #include +#else + #include +#endif + #include #include #include