-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.psp.inc
232 lines (188 loc) · 5.79 KB
/
Makefile.psp.inc
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
SUPPORT = $(HOME)/Dropbox/EDA/repo/lib/PSP
SRC += $(SUPPORT)/exit_callback.c
# Define all object files.
OBJS = $(SRC:.c=.o) $(ASRC:.S=.o) $(CXXSRC:.cpp=.o)
# Define all listing and map files.
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst)
MAPS = $(TARGET).map
INCDIR =
COPTS = -O2 -G0 -Wall -I$(SUPPORT) $(CINCS)
CFLAGS = -Wa,-adhlns=$(<:.c=.lst) $(CEXTRA) $(COPTS)
CXXFLAGS = -Wa,-adhlns=$(<:.cpp=.lst) $(CXXEXTRA) $(COPTS) -fno-exceptions -fno-rtti
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst) $(COPTS)
BUILD_PRX = 1
LIBDIR = ./
LIBS = -lm
LDFLAGS =
PSP_EBOOT = EBOOT.PBP
EXTRA_TARGETS = $(PSP_EBOOT)
PSP_EBOOT_TITLE = $(TARGET)
PSPSDK = $(shell psp-config --pspsdk-path)
# PSP Software Development Kit - http://www.pspdev.org
# -----------------------------------------------------------------------
# Licensed under the BSD license, see LICENSE in PSPSDK root for details.
#
# build.mak - Base makefile for projects using PSPSDK.
#
# Copyright (c) 2005 Marcus R. Brown <[email protected]>
# Copyright (c) 2005 James Forshaw <[email protected]>
# Copyright (c) 2005 John Kelley <[email protected]>
#
# $Id: build.mak 2333 2007-10-31 19:37:40Z tyranid $
# Note: The PSPSDK make variable must be defined before this file is included.
ifeq ($(PSPSDK),)
PSPSDK = $(shell psp-config --pspsdk-path)
endif
CC = psp-gcc
CXX = psp-g++
AS = psp-gcc
LD = psp-gcc
AR = psp-ar
RANLIB = psp-ranlib
STRIP = psp-strip
MKSFO = mksfo
PACK_PBP = pack-pbp
FIXUP = psp-fixup-imports
# Add in PSPSDK includes and libraries.
INCDIR += $(PSPSDK)/include
LIBDIR += $(PSPSDK)/lib
COPTS += $(addprefix -I,$(INCDIR))
ifeq ($(PSP_LARGE_MEMORY),1)
MKSFO = mksfoex -d MEMSIZE=1
endif
ifeq ($(PSP_FW_VERSION),)
PSP_FW_VERSION=150
endif
COPTS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
ifeq ($(BUILD_PRX),1)
LDFLAGS += $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx
EXTRA_CLEAN += $(TARGET).elf
# Setup default exports if needed
ifdef PRX_EXPORTS
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
EXTRA_CLEAN += $(EXPORT_OBJ)
else
EXPORT_OBJ=$(PSPSDK)/lib/prxexports.o
endif
else
LDFLAGS += $(addprefix -L,$(LIBDIR))
endif
# Library selection. By default we link with Newlib's libc. Allow the
# user to link with PSPSDK's libc if USE_PSPSDK_LIBC is set to 1.
ifeq ($(USE_KERNEL_LIBC),1)
# Use the PSP's kernel libc
PSPSDK_LIBC_LIB =
COPTS += -I$(PSPSDK)/include/libc
else
ifeq ($(USE_PSPSDK_LIBC),1)
# Use the pspsdk libc
PSPSDK_LIBC_LIB = -lpsplibc
COPTS += -I$(PSPSDK)/include/libc
else
# Use newlib (urgh)
PSPSDK_LIBC_LIB = -lc
endif
endif
# Link with following default libraries. Other libraries should be specified in the $(LIBS) variable.
# TODO: This library list needs to be generated at configure time.
#
ifeq ($(USE_KERNEL_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay_driver -lpspctrl_driver -lpspsdk
LIBS += $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspkernel
else
ifeq ($(USE_USER_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS += $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
-lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
-lpspuser
else
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS += $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
-lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
-lpspuser -lpspkernel
endif
endif
# Define the overridable parameters for EBOOT.PBP
ifndef PSP_EBOOT_TITLE
PSP_EBOOT_TITLE = $(TARGET)
endif
ifndef PSP_EBOOT_SFO
PSP_EBOOT_SFO = PARAM.SFO
endif
ifndef PSP_EBOOT_ICON
PSP_EBOOT_ICON = NULL
endif
ifndef PSP_EBOOT_ICON1
PSP_EBOOT_ICON1 = NULL
endif
ifndef PSP_EBOOT_UNKPNG
PSP_EBOOT_UNKPNG = NULL
endif
ifndef PSP_EBOOT_PIC1
PSP_EBOOT_PIC1 = NULL
endif
ifndef PSP_EBOOT_SND0
PSP_EBOOT_SND0 = NULL
endif
ifndef PSP_EBOOT_PSAR
PSP_EBOOT_PSAR = NULL
endif
ifndef PSP_EBOOT
PSP_EBOOT = EBOOT.PBP
endif
ifeq ($(BUILD_PRX),1)
ifneq ($(TARGET_LIB),)
$(error TARGET_LIB should not be defined when building a prx)
else
FINAL_TARGET = $(TARGET).prx
endif
else
ifneq ($(TARGET_LIB),)
FINAL_TARGET = $(TARGET_LIB)
else
FINAL_TARGET = $(TARGET).elf
endif
endif
all: $(EXTRA_TARGETS) $(FINAL_TARGET)
kxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
mkdir -p "$(TARGET)"
$(STRIP) $(TARGET).elf -o $(TARGET)/$(PSP_EBOOT)
mkdir -p "$(TARGET)%"
$(PACK_PBP) "$(TARGET)%/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)
SCEkxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
mkdir -p "__SCE__$(TARGET)"
$(STRIP) $(TARGET).elf -o __SCE__$(TARGET)/$(PSP_EBOOT)
mkdir -p "%__SCE__$(TARGET)"
$(PACK_PBP) "%__SCE__$(TARGET)/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)
$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
$(LINK.c) $^ $(LIBS) -o $@
$(FIXUP) $@
$(TARGET_LIB): $(OBJS)
$(AR) cru $@ $(OBJS)
$(RANLIB) $@
$(PSP_EBOOT_SFO):
$(MKSFO) '$(PSP_EBOOT_TITLE)' $@
ifeq ($(BUILD_PRX),1)
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) $(TARGET).prx $(PSP_EBOOT_PSAR)
else
$(PSP_EBOOT): $(TARGET).elf $(PSP_EBOOT_SFO)
$(STRIP) $(TARGET).elf -o $(TARGET)_strip.elf
$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) $(TARGET)_strip.elf $(PSP_EBOOT_PSAR)
-rm -f $(TARGET)_strip.elf
endif
%.prx: %.elf
psp-prxgen $< $@
%.c: %.exp
psp-build-exports -b $< > $@
clean:
-rm -f $(FINAL_TARGET) $(EXTRA_CLEAN) $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) $(EXTRA_TARGETS) $(LST)
rebuild: clean all