From 8ce117f0b3fd4ceeb1d7058dde8793e4421ec076 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sat, 5 Oct 2024 17:44:50 +1000 Subject: trying to get rust bindgen working --- Makefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0fbc7f2..7c50323 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,16 @@ INCLUDES := -I./include -Ideps/glfw-3.3.8/include/GLFW CFLAGS := -Wall -Wextra -O2 $(INCLUDES) LDFLAGS := -lglfw +# Detect OS +UNAME_S := $(shell uname -s) + # Directories SRC_DIR := src BUILD_DIR := build OBJ_DIR := $(BUILD_DIR)/objs SHADER_DIR := assets/shaders SHADER_OUT_DIR := $(BUILD_DIR)/shaders +EXAMPLES_DIR := examples # Source files SRCS := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/**/*.c) @@ -16,7 +20,14 @@ OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS)) # Library outputs STATIC_LIB := $(BUILD_DIR)/libceleritas.a -SHARED_LIB := $(BUILD_DIR)/libceleritas.so +ifeq ($(UNAME_S),Darwin) + SHARED_LIB := $(BUILD_DIR)/libceleritas.dylib + SHARED_FLAGS := -dynamiclib + LDFLAGS += -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework AppKit +else + SHARED_LIB := $(BUILD_DIR)/libceleritas.so + SHARED_FLAGS := -shared +endif ## Makefile notes # $@ - target of current rule @@ -29,7 +40,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SHARED_LIB): $(OBJS) @mkdir -p $(BUILD_DIR) - $(CC) -shared -o $@ $^ $(LDFLAGS) + $(CC) $(SHARED_FLAGS) -o $@ $^ $(LDFLAGS) $(STATIC_LIB): $(OBJS) @mkdir -p $(BUILD_DIR) @@ -42,6 +53,12 @@ static: $(STATIC_LIB) .PHONY: all all: shared static +.PHONY: triangle +triangle: build/triangle.bin + +build/triangle.bin: $(EXAMPLES_DIR)/triangle.c $(STATIC_LIB) + @mkdir -p $(BUILD_DIR) + $(CC) $(CFLAGS) $< -o $@ -L$(BUILD_DIR) -lceleritas $(LDFLAGS) .PHONY: clean clean: -- cgit v1.2.3-70-g09d2