-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (29 loc) · 788 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Compiler and flags
CC = g++
CFLAGS = -Iinclude
LDFLAGS = -lglfw -ldl -lGL -lm
# Source files
SRC_DIR = src
INCLUDE_DIR = include
GLAD_SRC = $(SRC_DIR)/glad.c
MAIN_SRC = $(SRC_DIR)/main.cpp
# Output files
OBJ_DIR = obj
GLAD_OBJ = $(OBJ_DIR)/glad.o
MAIN_EXEC = engine
# Phony targets
.PHONY: all clean
# Rule to build the project
all: $(MAIN_EXEC)
# Ensure object directory exists before compiling
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
# Compile glad.c to glad.o
$(GLAD_OBJ): $(GLAD_SRC) | $(OBJ_DIR)
$(CC) -c $(GLAD_SRC) -o $(GLAD_OBJ) $(CFLAGS)
# Build the executable by linking glad.o and main.cpp
$(MAIN_EXEC): $(MAIN_SRC) $(GLAD_OBJ)
$(CC) $(MAIN_SRC) $(GLAD_OBJ) -o $(MAIN_EXEC) $(CFLAGS) $(LDFLAGS)
# Clean up object files and executable
clean:
rm -rf $(OBJ_DIR) $(MAIN_EXEC)