From 3e1aea0243f54e0b68baa3b19ac19f3d965484e0 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:49:11 +1100 Subject: start on metal backend --- Makefile | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9689dae..67b79a4 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,7 @@ CFLAGS := -Wall -Wextra -O2 $(INCLUDES) LDFLAGS := -lglfw # Detect OS -ifeq ($(OS),Windows_NT) - DETECTED_OS := Windows -else - DETECTED_OS := $(shell uname -s) -endif +UNAME_S := $(shell uname -s) # Directories SRC_DIR := src @@ -22,17 +18,14 @@ EXAMPLES_DIR := examples SRCS := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/**/*.c) OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS)) -# Add Metal backend written in Objective C only on Mac platform -ifeq ($(DETECTED_OS),Darwin) - SRCS += $(SRC_DIR)/backend_mtl.m -endif - # Library outputs STATIC_LIB := $(BUILD_DIR)/libceleritas.a ifeq ($(UNAME_S),Darwin) SHARED_LIB := $(BUILD_DIR)/libceleritas.dylib SHARED_FLAGS := -dynamiclib - LDFLAGS += -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework AppKit + LDFLAGS += -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework AppKit -framework QuartzCore -framework Metal -framework MetalKit + SRCS += $(SRC_DIR)/backend_mtl.m + OBJS += $(OBJ_DIR)/backend_mtl.o else SHARED_LIB := $(BUILD_DIR)/libceleritas.so SHARED_FLAGS := -shared @@ -47,6 +40,11 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c @mkdir -p $(OBJ_DIR) $(CC) $(CFLAGS) -c $< -o $@ +# Objective C +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.m + @mkdir -p $(OBJ_DIR) + $(CC) $(CFLAGS) -c $< -o $@ + $(SHARED_LIB): $(OBJS) @mkdir -p $(BUILD_DIR) $(CC) $(SHARED_FLAGS) -o $@ $^ $(LDFLAGS) @@ -63,11 +61,10 @@ static: $(STATIC_LIB) all: shared static .PHONY: triangle -triangle: build/triangle.bin - -build/triangle.bin: $(EXAMPLES_DIR)/triangle.c $(STATIC_LIB) +triangle: $(EXAMPLES_DIR)/triangle.c $(SHARED_LIB) @mkdir -p $(BUILD_DIR) - $(CC) $(CFLAGS) $< -o $@ -L$(BUILD_DIR) -lceleritas $(LDFLAGS) + $(CC) $(CFLAGS) $(EXAMPLES_DIR)/triangle.c -L$(BUILD_DIR) -lceleritas $(LDFLAGS) + MTL_DEBUG_LAYER=1 build/triangle.bin .PHONY: clean clean: -- cgit v1.2.3-70-g09d2