-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (28 loc) · 904 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
# Change accordingly
GBDK_PATH=./lib/gbdk/bin/lcc
INCLUDE_PATH=./include
SRC_PATH=./src
OBJ_PATH=./obj
BIN_PATH=./bin
INCLUDE_FILES=$(wildcard $(INCLUDE_PATH)/*.h)
SRC_FILES=$(wildcard $(SRC_PATH)/*.c $(INCLUDE_PATH)/*.c)
OBJ_FILES=$(patsubst %.c, $(OBJ_PATH)/%.o, $(notdir $(SRC_FILES)))
FLAGS=-I$(INCLUDE_PATH)
TARGET=$(BIN_PATH)/game.gb
# by default, also intermediate results are wiped out
all: directories $(TARGET) clean
$(TARGET): $(OBJ_FILES)
$(GBDK_PATH) $(FLAGS) -o $(TARGET) $(OBJ_FILES)
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(INCLUDE_FILES)
$(GBDK_PATH) $(FLAGS) -c $< -o $@
# create obj directory if it doesn't exist
$(OBJ_PATH):
mkdir -p $(OBJ_PATH)
$(BIN_PATH):
mkdir -p $(BIN_PATH)
.PHONY directories: ${OBJ_PATH} ${BIN_PATH}
# delete intermediate files created for the compilation process
.PHONY clean:
rm -f $(OBJ_PATH)/*
rm -f *.asm *.lst *.ihx *.sym *.gb
rm -f bin/*.ihx