forked from ElAngel378/GBDASH
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
79 lines (63 loc) · 1.65 KB
/
makefile
File metadata and controls
79 lines (63 loc) · 1.65 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Shell detection and commands
ifeq ($(OS),Windows_NT)
ifneq ($(findstring sh,$(SHELL)),)
IS_BASH = true
else
IS_BASH = false
endif
else
IS_BASH = true
endif
ifeq ($(IS_BASH),true)
CLEAR = clear
MKDIR_P = mkdir -p
RM_RF = rm -rf
else
CLEAR = cls
MKDIR_P = mkdir
RM_RF = rmdir /S /Q
endif
# Directories
SRC_DIR := src
MUSIC_DIR := $(SRC_DIR)/music
INC_DIR := include
BUILD_DIR := build
BUILD_MUSIC_DIR := $(BUILD_DIR)/music
# Tools and flags
CC := lcc
CFLAGS := -I$(INC_DIR) -I$(SRC_DIR) -c -debug
ROM_TITLE := GB_DASH
LDFLAGS := \
-I$(INC_DIR) \
-I$(SRC_DIR) \
-Wl-lhugedriver/gbdk/hUGEDriver.lib \
-Wl-yt19 -Wl-yo8 -debug
# Sources and objects
SRC_SOURCES := $(wildcard $(SRC_DIR)/*.c)
MUSIC_SOURCES := $(wildcard $(MUSIC_DIR)/*.c)
SOURCES := $(SRC_SOURCES) $(MUSIC_SOURCES)
SRC_OBJECTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC_SOURCES))
MUSIC_OBJECTS := $(patsubst $(MUSIC_DIR)/%.c,$(BUILD_MUSIC_DIR)/%.o,$(MUSIC_SOURCES))
OBJECTS := $(SRC_OBJECTS) $(MUSIC_OBJECTS)
TARGET := $(BUILD_DIR)/game.gb
# Default rule
all: run_processtotxt prebuild $(TARGET)
# Run processtotxt.py before build
run_processtotxt:
@python processtotxt.py
# Link final binary
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^
# Compile each .c to .o
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $<
$(BUILD_MUSIC_DIR)/%.o: $(MUSIC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $<
# Ensure build directories exist
$(BUILD_DIR):
$(MKDIR_P) $(BUILD_DIR)
$(MKDIR_P) $(BUILD_MUSIC_DIR)
# Clean build files
clean:
$(RM_RF) $(BUILD_DIR)
.PHONY: all clean prebuild run_processtotxt