-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
67 lines (54 loc) · 2.23 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
TOOLCHAIN := $(OO_PS4_TOOLCHAIN)
PROJNAME := $(shell basename $(CURDIR))
#$(notdir $(shell pwd))
INTDIR := $(CURDIR)/build
SRCDIR := $(CURDIR)/source
SQLDIR := $(SRCDIR)/sqlite
UISRCDIR := $(SRCDIR)/ui
# Libraries linked into the ELF.
LIBS := -lc -lkernel -lc++ -lSceVideoOut -lSceUserService -lScePad
# Compiler options. You likely won't need to touch these.
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CC := clang++
LD := ld.lld
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
CDIR := macos
endif
ODIR := $(INTDIR)
SDIR := $(SRCDIR)
IDIRS := -I$(TOOLCHAIN)/include -I$(TOOLCHAIN)/include/c++/v1
LDIRS := -L$(TOOLCHAIN)/lib
## this is annoying at best, why i was using -Xclang, need some frontend opts like cpu/tune/avx2/bmi
CFLAGS := -cc1 -O2 -triple x86_64-pc-freebsd-elf -munwind-tables $(IDIRS) -fuse-init-array -debug-info-kind=limited -debugger-tuning=gdb -emit-obj -D_OO_
LFLAGS := -O2 -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x --eh-frame-hdr $(LDIRS) $(LIBS) $(TOOLCHAIN)/lib/crt1.o
CFILES := $(wildcard $(SDIR)/*.c)
CPPFILES := $(wildcard $(SDIR)/*.cpp)
UISRCFILES := $(wildcard $(UISRCDIR)/*.cpp)
SQLFILES := $(wildcard $(SQLDIR)/*.c)
OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) $(patsubst $(SDIR)/%.cpp, $(ODIR)/%.o, $(CPPFILES)) $(patsubst $(SQLDIR)/%.c, $(ODIR)/%.o, $(SQLFILES)) $(patsubst $(UISRCDIR)/%.cpp, $(ODIR)/%.o, $(UISRCFILES))
TARGET = eboot.bin
# Create the intermediate directory incase it doesn't already exist.
_unused := $(shell mkdir -p $(INTDIR))
# Make rules
$(TARGET): $(ODIR) $(OBJS)
$(LD) $(ODIR)/*.o -o $(ODIR)/$(PROJNAME).elf $(LFLAGS)
$(TOOLCHAIN)/bin/$(CDIR)/create-eboot -in=$(ODIR)/$(PROJNAME).elf -out=$(ODIR)/$(PROJNAME).oelf --paid 0x3800000000000011
$(ODIR)/%.o: $(SDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<
$(ODIR)/%.o: $(SDIR)/%.cpp
$(CC) $(CFLAGS) -o $@ $<
$(ODIR)/%.o: $(UISRCDIR)/%.cpp
$(CC) $(CFLAGS) -o $@ $<
$(ODIR)/%.o: $(SQLDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<
$(ODIR):
@mkdir $@
.PHONY: clean
clean:
echo "project name $(PROJNAME), sql dir $(SQLDIR) ;; files $(SQLFILES)"
rm -f $(TARGET) $(ODIR)/*