summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile21
1 files changed, 19 insertions, 2 deletions
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: