-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
323 lines (269 loc) · 7.97 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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
define HEADER
__________ _________________ ____________________.____
\______ \/ _____/\_____ \ \______ \______ \ |
| ___/\_____ \ / ____/ | | _/| | _/ |
| | / \/ \ | | \| | \ |___
|____| /_______ /\_______ \ |______ /|______ /_______ \\
\/ \/ \/ \/ \/
PlayStation2 Basic BootLoader - By El_isra
endef
export HEADER
# ---{BUILD CFG}--- #
HAS_EMBED_IRX = 1 # whether to embed or not non vital IRX (wich will be loaded from memcard files)
DEBUG ?= 0
PSX ?= 0 # PSX DESR support
HDD ?= 0 #wether to add internal HDD support
MX4SIO ?= 0
PROHBIT_DVD_0100 ?= 0 # prohibit the DVD Players v1.00 and v1.01 from being booted.
XCDVD_READKEY ?= 0 # Enable the newer sceCdReadKey checks, which are only supported by a newer CDVDMAN module.
UDPTTY ?= 0 # printf over UDP
PPCTTY ?= 0 # printf over PowerPC UART
PRINTF ?= NONE
HOMEBREW_IRX ?= 0 # if we need homebrew SIO2MAN, MCMAN, MCSERV & PADMAN embedded, else, builtin console drivers are used
FILEXIO_NEED ?= 0 # if we need filexio and imanx loaded for other features (HDD, mx4sio, etc)
DEV9_NEED ?= 0 # if we need DEV9 loaded for other features (HDD, UDPTTY, etc)
# Related to binary size reduction (it disables some features, please be sure you won't disable something you need)
KERNEL_NOPATCH = 1
NEWLIB_NANO = 1
DUMMY_TIMEZONE = 1
# ---{ VERSIONING }--- #
VERSION = 1
SUBVERSION = 2
PATCHLEVEL = 0
STATUS = Beta
# ---{ EXECUTABLES }--- #
BINDIR ?= bin/
BASENAME ?= PS2BBL
EE_BIN = $(BINDIR)$(BASENAME).ELF
EE_BIN_STRIPPED = $(BINDIR)stripped_$(BASENAME).ELF
EE_BIN_PACKED = $(BINDIR)COMPRESSED_$(BASENAME).ELF
KELFTYPE ?= MC
EE_BIN_ENCRYPTED = $(BINDIR)$(BASENAME)_$(KELFTYPE).KELF
# ---{ OBJECTS & STUFF }--- #
EE_OBJS_DIR = obj/
EE_SRC_DIR = src/
EE_ASM_DIR = asm/
EE_OBJS = main.o \
util.o elf.o timer.o ps2.o ps1.o dvdplayer.o \
modelname.o libcdvd_add.o OSDHistory.o OSDInit.o OSDConfig.o \
$(EMBEDDED_STUFF) \
$(IOP_OBJS)
EMBEDDED_STUFF = icon_sys_A.o icon_sys_J.o icon_sys_C.o
EE_CFLAGS = -Wall
EE_CFLAGS += -fdata-sections -ffunction-sections -DREPORT_FATAL_ERRORS
EE_LDFLAGS += -L$(PS2SDK)/ports/lib
EE_LDFLAGS += -Wl,--gc-sections -Wno-sign-compare
EE_LIBS += -ldebug -lmc -lpatches
EE_INCS += -Iinclude -I$(PS2SDK)/ports/include
EE_CFLAGS += -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DPATCHLEVEL=\"$(PATCHLEVEL)\" -DSTATUS=\"$(STATUS)\"
# ---{ CONDITIONS }--- #
ifneq ($(VERBOSE), 1)
.SILENT:
endif
ifeq ($(MX4SIO), 1)
HOMEBREW_IRX = 1
FILEXIO_NEED = 1
EE_OBJS += mx4sio_bd_irx.o
EE_CFLAGS += -DMX4SIO
ifeq ($(USE_ROM_SIO2MAN), 1)
$(error MX4SIO needs Homebrew SIO2MAN to work)
endif
endif
ifeq ($(HOMEBREW_IRX), 1)
$(info --- enforcing usage of homebrew IRX modules)
USE_ROM_PADMAN = 0
USE_ROM_MCMAN = 0
USE_ROM_SIO2MAN = 0
else
$(info --- using BOOT-ROM drivers)
USE_ROM_PADMAN = 1
USE_ROM_MCMAN = 1
USE_ROM_SIO2MAN = 1
endif
ifeq ($(PSX), 1)
$(info --- building with PSX-DESR support)
BASENAME = PSXBBL
EE_CFLAGS += -DPSX=1
EE_OBJS += scmd_add.o ioprp.o
EE_LIBS += -lxcdvd -liopreboot
else
EE_LIBS += -lcdvd
endif
ifeq ($(DEBUG), 1)
$(info --- debugging enabled)
EE_CFLAGS += -DDEBUG -O0 -g
EE_LIBS += -lelf-loader
else
EE_CFLAGS += -Os
EE_LDFLAGS += -s
EE_LIBS += -lelf-loader-nocolour
endif
ifeq ($(USE_ROM_PADMAN), 1)
EE_CFLAGS += -DUSE_ROM_PADMAN
EE_LIBS += -lpad
EE_OBJS += pad.o
else
EE_OBJS += pad.o padman_irx.o
EE_LIBS += -lpadx
endif
ifeq ($(USE_ROM_MCMAN), 1)
EE_CFLAGS += -DUSE_ROM_MCMAN
else
EE_OBJS += mcman_irx.o mcserv_irx.o
endif
ifeq ($(USE_ROM_SIO2MAN), 1)
EE_CFLAGS += -DUSE_ROM_SIO2MAN
else
EE_OBJS += sio2man_irx.o
endif
ifneq ($(HAS_EMBED_IRX), 1)
$(info --- USB drivers will be embedded)
EE_OBJS += usbd_irx.o bdm_irx.o bdmfs_fatfs_irx.o usbmass_bd_irx.o
EE_CFLAGS += -DHAS_EMBEDDED_IRX
endif
ifeq ($(HDD), 1)
$(info --- compiling with HDD support)
EE_LIBS += -lpoweroff
EE_OBJS += ps2fs_irx.o ps2hdd_irx.o ps2atad_irx.o poweroff_irx.o
EE_CFLAGS += -DHDD
FILEXIO_NEED = 1
DEV9_NEED = 1
KELFTYPE = HDD
endif
ifeq ($(UDPTTY), 1)
$(info --- UDPTTY enabled)
EE_CFLAGS += -DUDPTTY
EE_OBJS += udptty_irx.o ps2ip_irx.o netman_irx.o smap_irx.o
DEV9_NEED = 1
ifneq ($(PRINTF), EE_SIO) # only enable common printf if EE_SIO is disabled. this allows separating EE and IOP printf
PRINTF = PRINTF
endif
else ifeq ($(PPCTTY), 1)
$(info --- PPCTTY enabled)
EE_CFLAGS += -DPPCTTY
EE_OBJS += ppctty_irx.o
ifneq ($(PRINTF), EE_SIO) # only enable common printf if EE_SIO is disabled. this allows separating EE and IOP printf
PRINTF = PRINTF
endif
endif
ifeq ($(FILEXIO_NEED), 1)
$(info --- FILEXIO will be included)
EE_CFLAGS += -DFILEXIO
EE_LIBS += -lfileXio
EE_OBJS += filexio_irx.o iomanx_irx.o
endif
ifeq ($(DUMMY_TIMEZONE), 1)
EE_CFLAGS += -DDUMMY_TIMEZONE
endif
ifeq ($(DEV9_NEED), 1)
EE_CFLAGS += -DDEV9
EE_OBJS += ps2dev9_irx.o
endif
ifdef COMMIT_HASH
EE_CFLAGS += -DCOMMIT_HASH=\"$(COMMIT_HASH)\"
else
EE_CFLAGS += -DCOMMIT_HASH=\"$(shell git rev-parse --short HEAD)\"
endif
ifeq ($(DUMMY_LIBC_INIT), 1)
EE_CFLAGS += -DDUMMY_LIBC_INIT
endif
ifeq ($(KERNEL_NOPATCH), 1)
EE_CFLAGS += -DKERNEL_NOPATCH
endif
ifeq ($(PRINTF), NONE)
else ifeq ($(PRINTF), SCR)
$(info --- SCR Printf enabled)
EE_CFLAGS += -DSCR_PRINT
else ifeq ($(PRINTF), EE_SIO)
$(info --- EESIO Printf enabled)
EE_CFLAGS += -DEE_SIO_DEBUG
EE_LIBS += -lsiocookie
EE_OBJS += sioprintf.o
else ifeq ($(PRINTF), PRINTF)
$(info --- Common Printf enabled)
EE_CFLAGS += -DCOMMON_PRINTF
else ifneq ($(PRINTF),)
$(warning UNKNOWN PRINTF REQUESTED: '$(PRINTF)')
endif
ifeq ($(XCDVD_READKEY),1)
EE_CFLAGS += -DXCDVD_READKEY=1
endif
ifeq ($(PROHBIT_DVD_0100),1)
EE_CFLAGS += -DPROHBIT_DVD_0100=1
endif
# ---{ RECIPES }--- #
.PHONY: greeting debug all clean kelf packed release
all: $(EE_BIN)
ifeq (DEBUG, 1)
$(MAKE) greeting
endif
rebuild: clean packed
packed: $(EE_BIN_PACKED)
greeting:
@echo built PS2BBL PSX=$(PSX), LOCAL_IRX=$(HAS_EMBED_IRX), DEBUG=$(DEBUG)
@echo PROHBIT_DVD_0100=$(PROHBIT_DVD_0100), XCDVD_READKEY=$(XCDVD_READKEY)
@echo KERNEL_NOPATCH=$(KERNEL_NOPATCH), NEWLIB_NANO=$(NEWLIB_NANO)
@echo binaries dispatched to $(BINDIR)
@echo printf=$(PRINTF)
@echo $(EE_OBJS)
release: clean $(EE_BIN_PACKED)
@rm -f $(EE_BIN_STRIPPED)
@echo "$$HEADER"
clean:
@rm -rf $(EE_BIN) $(EE_BIN_STRIPPED) $(EE_BIN_ENCRYPTED) $(EE_BIN_PACKED)
@rm -rf $(EE_OBJS_DIR) $(EE_ASM_DIR)
$(EE_BIN_STRIPPED): $(EE_BIN)
@echo " -- Stripping"
$(EE_STRIP) -o $@ $<
$(EE_BIN_PACKED): $(EE_BIN_STRIPPED)
@echo " -- Compressing"
ifneq ($(DEBUG),1)
ps2-packer $< $@
else
ps2-packer -v $< $@
endif
$(EE_BIN_ENCRYPTED): $(EE_BIN_PACKED)
@echo " -- Encrypting ($(KELFTYPE))"
ifeq ($(KELFTYPE), MC)
thirdparty/kelftool_dnasload.exe encrypt dnasload $< $@
else ifeq ($(KELFTYPE), HDD)
thirdparty/kelftool_dnasload.exe encrypt fhdb $< $@
else
$(error UNKNOWN KELF TYPE: '$(KELFTYPE)')
endif
# move OBJ to folder and search source on src/, borrowed from OPL makefile
EE_OBJS := $(EE_OBJS:%=$(EE_OBJS_DIR)%) # remap all EE_OBJ to obj subdir
$(EE_OBJS_DIR):
@mkdir -p $@
$(EE_ASM_DIR):
@mkdir -p $@
$(BINDIR):
@mkdir -p $@
vpath %.c $(EE_ASM_DIR)
$(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.c | $(EE_OBJS_DIR)
ifneq ($(VERBOSE),1)
@echo " - $@"
endif
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
$(EE_OBJS_DIR)%.o: $(EE_ASM_DIR)%.c | $(EE_OBJS_DIR)
ifneq ($(VERBOSE),1)
@echo " - $@"
endif
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
$(EE_OBJS_DIR)%.o: $(EE_ASM_DIR)%.s | $(EE_OBJS_DIR)
ifneq ($(VERBOSE),1)
@echo " - $@"
endif
$(EE_AS) $(EE_ASFLAGS) $< -o $@
#
analize:
$(MAKE) rebuild DEBUG=1
python3 thirdparty/elf-size-analize.py $(EE_BIN) -R -t mips64r5900el-ps2-elf-
celan: clean # a repetitive typo when quicktyping
kelf: $(EE_BIN_ENCRYPTED) # alias of KELF creation
banner:
@echo "$$HEADER"
# Include makefiles
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
include embed.make