-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (101 loc) · 3.04 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
TITLEID := VGLTETRIS
TARGET := ViTetris
TARGETVPK := $(TARGET).vpk
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
VITASDK_DIR := $(PROJECT_ROOT)/sdk
VITASDK_ENV_SCRIPT := $(shell find $(VITASDK_DIR) -maxdepth 1 -type f -executable)
VITA3K := $(shell command -v Vita3K)
VITA3K_DIR := $(shell dirname $(VITA3K) 2>/dev/null)
VITA3K_APP_DIR := $(VITA3K_DIR)/config/ux0/app/$(TITLEID)
ifndef VITASDK
$(error VITASDK is undefined in the environment. Please execute or source $(VITASDK_ENV_SCRIPT))
endif
SOURCE_DIR := src
INCLUDES := include
LIBS := -lvitaGL \
-lvitashark \
-lc \
-lm \
-lmathneon \
-ltaihen_stub \
-lSceAppMgr_stub \
-lSceCommonDialog_stub \
-lSceCtrl_stub \
-lSceDisplay_stub \
-lSceGxm_stub \
-lSceKernelDmacMgr_stub \
-lSceShaccCg_stub \
-lSceShaccCgExt
SOURCE_FILES := $(shell find $(SOURCE_DIR) -type f -name '*.c')
OBJECTS := $(SOURCE_FILES:.c=.o)
HEADERS := $(SOURCE_FILES:.c=.h)
VPK_ASSET_FILES := $(shell find $(PROJECT_ROOT)/sce_sys -type f)
FEATURE_FLAGS :=
ifneq ($(DEBUG),)
FEATURE_FLAGS += -DDEBUG
endif
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
CXX = $(PREFIX)-g++
CFLAGS = -g -Wl,-q -O2 -ftree-vectorize $(FEATURE_FLAGS) -Werror
CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive
ASFLAGS = $(CFLAGS)
SHELL := /bin/bash
# .ONESHELL:
.PHONY: 3k
all: $(TARGETVPK)
debug:
DEBUG=1 $(MAKE) $(TARGETVPK)
echo:
@echo "TITLEID = $(TITLEID)"
@echo "TARGET = $(TARGET)"
@echo "TARGETVPK = $(TARGETVPK)"
@echo "VITA3K_DIR = $(VITA3K_DIR)"
@echo "VITA3K_SDK_DIR = $(VITA3K_SDK_DIR)"
@echo "VITA3K_APP_DIR = $(VITA3K_APP_DIR)"
@echo "LIBS = $(LIBS)"
@echo "SOURCE_FILES = $(SOURCE_FILES)"
@echo "OBJECTS = $(OBJECTS)"
@echo "PREFIX = $(PREFIX)"
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "CFLAGS = $(CFLAGS)"
@echo "CXXFLAGS = $(CXXFLAGS)"
@echo "ASFLAGS = $(ASFLAGS)"
%.o: %.c %.h Makefile
$(CC) $(CFLAGS) -c -o $@ $<
$(TARGET).elf: $(OBJECTS)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
%.velf: %.elf
vita-elf-create $< $@
eboot.bin: $(TARGET).velf
vita-make-fself $< eboot.bin
$(TARGETVPK): eboot.bin $(VPK_ASSET_FILES)
vita-mksfoex -s TITLE_ID=$(TITLEID) "$(TARGET)" param.sfo
vita-pack-vpk \
--sfo=param.sfo \
--eboot=eboot.bin \
--add "sce_sys=sce_sys" \
--add "$(SOURCE_DIR)/graphics/texture=texture" \
--add "$(SOURCE_DIR)/graphics/shader=shader" \
$@
clean:
@rm -rfv *.velf *.elf *.vpk $(OBJECTS) param.sfo eboot.bin
3k: $(TARGETVPK) param.sfo eboot.bin
if [ -z "$(VITA3K)" ]; then \
echo "No executable named Vita3K was found, please add Vita3K directory to \$PATH";\
exit 1;\
fi ;\
$(MAKE) $(TARGETVPK)
if [ -d "$(VITA3K_APP_DIR)" ]; then \
cp -v eboot.bin "$(VITA3K_APP_DIR)/" ;\
cp -v param.sfo "$(VITA3K_APP_DIR)/sce_sys/" ;\
cp -v -r "$(SOURCE_DIR)/graphics/shader" \
"$(SOURCE_DIR)/graphics/texture" \
sce_sys/ \
"$(VITA3K_APP_DIR)/" ;\
Vita3K -B Vulkan --installed-path $(TITLEID) ;\
else \
Vita3K -B Vulkan -- "$(MAKEFILE_DIR)$(TARGETVPK)" ;\
fi