-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.pc
150 lines (128 loc) · 2.83 KB
/
Makefile.pc
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Constants
PKGCONFIG = pkg-config
FILENAME = funkin
CFLAGS =
LDFLAGS =
# Default options
GL = MODERN
# Win32
ifeq ($(OS),Windows_NT)
WINDOWS ?= 1
endif
ifeq ($(WINDOWS),1)
CFLAGS += -DPSXF_WIN32 -mwindows
endif
# Options
ifeq ($(STDMEM), 1)
CFLAGS += -DPSXF_STDMEM
endif
ifeq ($(GL), MODERN)
CFLAGS += -DPSXF_GL=PSXF_GL_MODERN
endif
ifeq ($(GL), LEGACY)
CFLAGS += -DPSXF_GL=PSXF_GL_LEGACY
endif
ifeq ($(GL), ES)
CFLAGS += -DPSXF_GL=PSXF_GL_ES
endif
ifeq ($(NETWORK), 1)
CFLAGS += -DPSXF_NETWORK
ifeq ($(WINDOWS),1)
LIBS += -lws2_32
endif
endif
# Release and debug
ifeq ($(RELEASE), 1)
CFLAGS += -O3 -Wall -Wextra -pedantic -DPSXF_PC -DNDEBUG
LDFLAGS += -s -flto
else
CFLAGS += -Og -ggdb3 -Wall -Wextra -pedantic -DPSXF_DEBUG -DPSXF_PC
endif
# Link GLFW
CFLAGS += $(shell $(PKGCONFIG) --cflags glfw3)
ifeq ($(STATIC), 1)
LDFLAGS += -static
LIBS += $(shell $(PKGCONFIG) --libs glfw3 --static)
else
LIBS += $(shell $(PKGCONFIG) --libs glfw3)
endif
ifeq ($(GL), ES)
# Link GLESv2
CFLAGS += $(shell $(PKGCONFIG) --cflags glesv2)
ifeq ($(STATIC), 1)
LIBS += $(shell $(PKGCONFIG) --libs glesv2 --static)
else
LIBS += $(shell $(PKGCONFIG) --libs glesv2)
endif
endif
# Link miniaudio dependencies
LIBS += -lm -lpthread
ifneq ($(WINDOWS),1)
LIBS += -ldl
endif
# Other CXX flags
CFLAGS += -MMD -MP -MF $@.d
# Sources to compile
SOURCES = main \
mutil \
random \
archive \
font \
trans \
loadscr \
menu \
stage \
pc/psx \
pc/io \
pc/gfx \
pc/audio \
pc/pad \
pc/timer \
pc/movie \
stage/beach \
stage/park \
stage/week1 \
stage/week2 \
stage/week3 \
stage/school \
animation \
character \
character/bf \
character/bfmenu \
character/steven \
character/spinel \
character/mordecai \
character/spook \
character/pico \
character/bfc \
character/finn \
character/jake \
character/bubble \
object \
object/combo \
object/splash
ifneq ($(GL), ES)
# Link glad
SOURCES += pc/glad/glad
endif
ifeq ($(NETWORK), 1)
# Compile networking
SOURCES += pc/network
endif
# What to compile
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
DEPENDENCIES = $(addprefix obj/$(FILENAME)/, $(addsuffix .o.d, $(SOURCES)))
# Compilation
all: bin/$(FILENAME)
bin/$(FILENAME): $(OBJECTS)
@mkdir -p $(@D)
@echo Linking...
@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
obj/$(FILENAME)/%.o: src/%.c
@mkdir -p $(@D)
@echo Compiling $<
@$(CC) $(CFLAGS) $< -o $@ -c
include $(wildcard $(DEPENDENCIES))
# Remove all our compiled objects
clean:
@rm -rf obj