summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:43:38 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:43:38 +1000
commit54354e32c6498cc7f8839ab4deb1208d37216cc5 (patch)
tree7759597b971ba59d6af841a5bed793c229dd4c2b /Makefile
parentbe8ab99b38c25e899008582d68e891150b328a4d (diff)
Begin simplifying project structure and removing examples
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 48 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..311e873
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
+CC := clang
+INCLUDES := -I./include -Ideps/glfw-3.3.8/include/GLFW
+CFLAGS := -Wall -Wextra -O2 $(INCLUDES)
+LDFLAGS := -lglfw3
+
+# Directories
+SRC_DIR := new_src
+BUILD_DIR := build
+OBJ_DIR := $(BUILD_DIR)/objs
+SHADER_DIR := assets/shaders
+SHADER_OUT_DIR := $(BUILD_DIR)/shaders
+
+# Source files
+SRCS := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/**/*.c)
+OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))
+
+# Library outputs
+STATIC_LIB := $(BUILD_DIR)/libceleritas.a
+SHARED_LIB := $(BUILD_DIR)/libceleritas.so
+
+## Makefile notes
+# $@ - target of current rule
+# $^ - prerequisites of current rule separated by spaces
+# $< - first prerequisite file only
+
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
+ @mkdir -p $(OBJ_DIR)
+ $(CC) $(CFLAGS) -c $< -o $@
+
+$(SHARED_LIB): $(OBJS)
+ @mkdir -p $(BUILD_DIR)
+ $(CC) -shared -o $@ $^ $(LDFLAGS)
+
+$(STATIC_LIB): $(OBJS)
+ @mkdir -p $(BUILD_DIR)
+ ar rcs $@ $^
+
+shared: $(SHARED_LIB)
+
+static: $(STATIC_LIB)
+
+.PHONY: all
+all: shared static
+
+
+.PHONY: clean
+clean:
+ rm -rf $(BUILD_DIR)