forked from FelicityVi/shiromino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (46 loc) · 1.21 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
51
52
53
54
55
56
57
58
59
60
61
# Configurables
BIN_PATH = bin
BIN_NAME = game
ifdef MINGW
CC = i686-w64-mingw32-gcc
endif
CC ?= gcc
SRC_PATH = src
OBJ_PATH = obj
# Do it Do it
INCLUDES =
ifdef MINGW
PKG_CONFIG ?= i686-w64-mingw32-pkg-config
endif
PKG_CONFIG ?= pkg-config
COMPILER_FLAGS = `${PKG_CONFIG} --cflags sdl2` -Wall -Werror -Wno-comment -Wno-unused-variable -Wno-unused-parameter -g
LINK_FLAGS = `${PKG_CONFIG} --libs sdl2` -lSDL2_image -lSDL2_mixer -lm
CFLAGS = $(COMPILER_FLAGS)
ifeq ($(OS), Windows_NT)
CFLAGS += -lmingw32 -lSDL2main
endif
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) $(LINK_FLAGS) -o $(BIN_PATH)/$(BIN_NAME)
ifdef MINGW
cp /usr/i686-w64-mingw32/bin/*.dll .
endif
-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) *.dll