generated from anna-singleton/sdl2-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
35 lines (25 loc) · 830 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
# this makefile is a stripped down version of this one:
# https://makefiletutorial.com/#makefile-cookbook
TARGET_EXEC := game
CC := gcc
BUILD_DIR := ./build
SRC_DIRS := ./src
CFLAGS := -O3
LINKERFLAGS := -lm -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer
# Find all the C files we want to compile
# Note the single quotes around the * expressions. Make will incorrectly expand these otherwise.
SRCS := $(shell find $(SRC_DIRS) -name '*.c')
# String substitution for every C file.
# As an example, hello.cpp turns into ./build/hello.cpp.o
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
# The final build step.
$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) $(LINKERFLAGS) -o game
# Build step for C source
$(BUILD_DIR)/%.c.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(LINKERFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -r $(BUILD_DIR)
rm game