-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (43 loc) · 1.52 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
LIBPS4 := libPS4
CC := gcc
AS := gcc
OBJCOPY := objcopy
ODIR := build
SDIR := source
IDIRS := -I$(LIBPS4)/include -I. -Iinclude
LDIRS := -L$(LIBPS4) -L. -Llib
CFLAGS := $(IDIRS) -O2 -std=c11 -ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nostdlib \
-Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small -fpie
SFLAGS := -nostartfiles -nostdlib -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
LFLAGS := $(LDIRS) -Xlinker -T $(LIBPS4)/linker.x -Wl,--build-id=none
CFILES := $(wildcard $(SDIR)/*.c)
SFILES := $(wildcard $(SDIR)/*.s)
OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) \
$(patsubst $(SDIR)/%.s, $(ODIR)/%.o, $(SFILES))
LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin
all: $(TARGET)
$(TARGET): makeGtaPayload requiredClean $(ODIR) $(OBJS)
@echo "Linking $(TARGET)..."
@$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
@$(OBJCOPY) -O binary temp.t $(TARGET)
@rm -f temp.t
@echo "$(TARGET) successfully created!"
$(ODIR)/%.o: $(SDIR)/%.c
@echo "Compiling $<..."
@$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/%.o: $(SDIR)/%.s
@echo "Compiling $<..."
@$(AS) -c -o $@ $< $(SFLAGS)
$(ODIR):
@mkdir -p $@
@echo "Created build directory: $(ODIR)"
.PHONY: makeGtaPayload requiredClean
makeGtaPayload:
@$(MAKE) -C gtaPayload $?
requiredClean:
@rm -f $(TARGET) $(ODIR)/embed.o
clean:
@echo "Cleaning..."
@rm -f $(TARGET) $(ODIR)/*.o
@echo "Clean completed."