forked from FelicityVi/shiromino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (37 loc) · 1 KB
/
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
44
45
46
47
48
49
50
# Configurables
BIN_PATH = bin
BIN_NAME = game
CC ?= gcc
SRC_PATH = src
OBJ_PATH = obj
# Do it Do it
INCLUDES =
COMPILER_FLAGS = -Wall -Werror -Wno-comment -Wno-misleading-indentation -Wno-unused-variable -Wno-unused-parameter -g
LINK_FLAGS = -lSDL2 -lSDL2_image -lSDL2_mixer -lm
CFLAGS = $(COMPILER_FLAGS)
ifeq ($(OS), Windows_NT)
CFLAGS += -lmingw32 -lSDL2main
endif
CFLAGS += $(LINK_FLAGS)
SRC = $(wildcard $(SRC_PATH)/*.c)
# SRC = $(shell find $(SRC_PATH) -name '*.c' -printf '%T@\t%p\n' | sort -k 1nr | cut -f2-)
OBJ = $(SRC:$(SRC_PATH)/%.c=$(OBJ_PATH)/%.o)
DEP = $(OBJ:.o=.d)
.PHONY: all
all: dirs game
@$(RM) $(BIN_NAME)
@ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)
game : $(OBJ)
$(CC) $(OBJ) $(CFLAGS) -o $(BIN_PATH)/$(BIN_NAME)
-include $(DEPS)
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c
@echo "Compiling: $< -> $@"
$(CC) $(CFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
.PHONY: dirs
dirs:
@mkdir -p $(dir $(OBJ))
@mkdir -p $(BIN_PATH)
.PHONY: clean
clean:
@$(RM) -r $(OBJ_PATH)
@$(RM) -f $(BIN_PATH)/$(BIN_NAME)