-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (32 loc) · 918 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
38
39
40
41
42
43
# Compiler
CC = gcc
# Compiler flags
CFLAGS = -Wall -Wextra -g
# SDL2 flags and libraries
SDL_FLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs) -lSDL2_gfx
# Directories
SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build
# Sources and Objects
SOURCES = $(wildcard $(SRC_DIR)/**/*.c $(SRC_DIR)/*.c)
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Target executable
TARGET = $(BUILD_DIR)/pacman_game
# Build the target by default
all: $(TARGET)
# Link the object files into the target
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -o $@ $(CFLAGS) $(SDL_LIBS)
# Compile the source files into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) -c $< -o $@ -I$(INCLUDE_DIR) $(CFLAGS) $(SDL_FLAGS)
# Clean up
clean:
rm -rf $(BUILD_DIR)
# Run the game and redirect all output to debug-log.txt
run: $(TARGET)
./$(TARGET) > debug-log.txt 2>&1
.PHONY: all clean run