-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
102 lines (83 loc) · 4.95 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
# Package metadata
TITLE := Payload Guest
VERSION := 0.98
TITLE_ID := AZIF00003
CONTENT_ID := IV0000-AZIF00003_00-PAYLOADGUEST0000
AUTHINFO := 000000000000000000000000001C004000FF000000000080000000000000000000000000000000000000008000400040000000000000008000000000000000080040FFFF000000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
# Libraries linked into the ELF
LIBS := -lc -lkernel -lc++ -lSceVideoOut -lSceGnmDriver -lSceSysmodule -lSceFreeType -lScePad -lSceUserService -lSceSystemService -lSceLibcInternal
LIBS += -Llibs -lLog
# Directorys to include
INCLUDES := -Iinclude -Iexternal
# Additional compile flags
# ERRORFLAGS and OTHERFLAGS will be included in C and C++ flags
# OTHERCXXFLAGS will only be included in C++ flags
ERRORFLAGS := -Wall -Wextra -Wpedantic -Werror
OTHERFLAGS := -std=c17 -O3 -D_DEFAULT_SOURCE
OTHERCXXFLAGS := -std=c++17
# PKG Asset directories
ASSETS := $(shell find assets -type f -name '*.*')
SCEMODULES := $(shell find sce_module -type f -name '*.*')
SCESYS := $(shell find sce_sys -type f -name '*.*')
# -----------------------------------------------------------------------------
# Do not edit below this line unless you know what you are doing
# -----------------------------------------------------------------------------
TOOLCHAIN := $(OO_PS4_TOOLCHAIN)
ODIR := build
SDIR := src
EXTRAFLAGS := $(INCLUDES) $(ERRORFLAGS) $(OTHERFLAGS)
CFLAGS := --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -c -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include $(EXTRAFLAGS)
CXXFLAGS := $(CFLAGS) -isystem $(TOOLCHAIN)/include/c++/v1 $(OTHERCXXFLAGS)
LDFLAGS := -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x --eh-frame-hdr -L$(TOOLCHAIN)/lib $(LIBS) $(TOOLCHAIN)/lib/crt1.o
CFILES := $(wildcard $(SDIR)/*.c)
CFILES := $(filter-out $(SDIR)/ChainLauncher.c,$(CFILES))
CPPFILES := $(wildcard $(SDIR)/*.cpp)
OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) $(patsubst $(SDIR)/%.cpp, $(ODIR)/%.o, $(CPPFILES))
OBJS := $(filter-out $(ODIR)/eboot.o,$(OBJS))
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CC := clang
CXX := clang++
LD := ld.lld
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang
CXX := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
CDIR := macos
endif
.PHONY: all pkg.gp4 sce_sys/param.sfo eboot.bin guest.elf clean
.DEFAULT := all
all: $(CONTENT_ID).pkg
$(CONTENT_ID).pkg: pkg.gp4
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core pkg_build $< .
pkg.gp4: eboot.bin guest.elf sce_sys/param.sfo $(SCESYS) $(SCEMODULES) $(ASSETS)
$(TOOLCHAIN)/bin/$(CDIR)/create-gp4 -out $@ --content-id=$(CONTENT_ID) --files "$^"
sce_sys/param.sfo: Makefile
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_new $@
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ APP_TYPE --type Integer --maxsize 4 --value 1
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ APP_VER --type Utf8 --maxsize 8 --value '$(VERSION)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ ATTRIBUTE --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ CATEGORY --type Utf8 --maxsize 4 --value 'gde'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ CONTENT_ID --type Utf8 --maxsize 48 --value '$(CONTENT_ID)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ SYSTEM_VER --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ TITLE --type Utf8 --maxsize 128 --value '$(TITLE)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ TITLE_ID --type Utf8 --maxsize 12 --value '$(TITLE_ID)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ VERSION --type Utf8 --maxsize 8 --value '$(VERSION)'
eboot.bin: guest.elf
$(CC) --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -c -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include $(INCLUDES) -std=c99 -O3 -D_DEFAULT_SOURCE $(ERRORFLAGS) -o $(ODIR)/eboot.o $(SDIR)/ChainLauncher.c
$(LD) $(ODIR)/eboot.o -o $(ODIR)/eboot.elf -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x --eh-frame-hdr -L$(TOOLCHAIN)/lib -lc -lkernel -lSceSysmodule -lSceSystemService -Llibs -lLog $(TOOLCHAIN)/lib/crt1.o
$(TOOLCHAIN)/bin/$(CDIR)/create-fself -in=$(ODIR)/eboot.elf -out=$(ODIR)/eboot.oelf --eboot "eboot.bin" --authinfo=$(AUTHINFO)
guest.elf: $(ODIR) $(OBJS)
$(LD) $(OBJS) -o $(ODIR)/guest.elf $(LDFLAGS)
$(TOOLCHAIN)/bin/$(CDIR)/create-fself -in=$(ODIR)/guest.elf -out=$(ODIR)/guest.oelf --eboot "guest.elf" --authinfo=$(AUTHINFO)
$(ODIR)/%.o: $(SDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<
$(ODIR)/%.o: $(SDIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
$(ODIR):
@mkdir -p $@
clean:
rm -rf *.pkg pkg.gp4 sce_sys/param.sfo eboot.bin guest.elf $(ODIR)