aboutsummaryrefslogtreecommitdiff
path: root/port/vita/rules.mk
blob: be8ad8a14bbf91e8c08ccd19bf412a6af2b72b22 (plain)
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
TITLE   := picow
TITLEID := PICO00008

# Some magic flags:
# - `-mcpu=cortext-a9`: specifically target the PS Vita CPU which may
#   help with some optimizations (instead of generic `armv7`).
# - `-Wl,-q`: make the ELF file relocatable which is required for the
#   executable to run (otherwise it crashes on startup).
# - `-Wl,--defsym=__sce_headroom=0x10000`: add some extra space for
#   the code segment, otherwise linking fails sporadically.
# - `-lScePower_stub`: link in the power management library to allow us
#   to overclock the PS Vita for performance
CFLAGS  += -mcpu=cortex-a9
LDFLAGS += -Wl,-q -Wl,--defsym=__sce_headroom=0x10000 -lScePower_stub

PATCH ?= patch
OBJ   := $(filter-out $(OUT)/system/pico8.o,$(OBJ)) \
         $(OUT)/port/vita/system/pico8.o

port: $(TARGET)/picow.vpk

$(TARGET)/picow.vpk: $(TARGET)/eboot.bin $(TARGET)/param.sfo
	vita-pack-vpk -s $(TARGET)/param.sfo -b $(TARGET)/eboot.bin $@

$(TARGET)/eboot.bin: $(TARGET)/picow.velf
	vita-make-fself -s $(TARGET)/picow.velf $@

$(TARGET)/param.sfo:
	vita-mksfoex -s TITLE_ID=$(TITLEID) "PICO-w" $@

$(TARGET)/picow.velf: $(TARGET)/picow.elf
	vita-elf-create $(TARGET)/picow.elf $@

$(TARGET)/picow.elf: $(OBJ) $(OUT)/port/vita/src/vita.o
	@ echo "CC\t$@"
	@ $(CC) $^ -o $@ $(LDFLAGS)

$(OUT)/port/vita/src/vita.o: port/vita/src/vita.c
	@ echo "CC\t$@"
	@ mkdir -p $(dir $@)
	@ $(CC) $(CFLAGS) -c $< -o $@

$(OUT)/port/vita/system/pico8.c: $(SYSTEM)/pico8.c port/vita/src/pico8.patch
	@ echo "PATCH\t$@"
	@ mkdir -p $(dir $@)
	@ $(PATCH) -s -o $@.tmp $(SYSTEM)/pico8.c < port/vita/src/pico8.patch
	@ mv $@.tmp $@

$(OUT)/port/vita/system/pico8.o: $(OUT)/port/vita/system/pico8.c \
                                 $(SYSTEM)/pico8.h $(SYSTEM)/wasm-rt.h
	@ echo "CC\t$@"
	@ $(CC) $(CFLAGS) -O3 -Wno-unused -Wno-unused-parameter -c $< -o $@