-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
82 lines (61 loc) · 1.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
.SUFFIXES:
ifeq ($(strip $(PSL1GHT)),)
$(error "PSL1GHT must be set in the environment.")
endif
include $(PSL1GHT)/Makefile.base
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCE := source
INCLUDE := include
DATA := data
LIBS := -lio -lnet -lsysmodule
APPID := FTPD00001
CONTENTID := UP0001-$(APPID)_00-0000000000000000
SFOXML := pkg/package.xml
ICON_PNG := pkg/icon.png
CFLAGS += -g -O2 -Wall --std=gnu99
CXXFLAGS += -g -O2 -Wall
ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export BUILDDIR := $(CURDIR)/$(BUILD)
export DEPSDIR := $(BUILDDIR)
CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c)))
CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))
export OFILES := $(CFILES:.c=.o) \
$(CXXFILES:.cpp=.o) \
$(SFILES:.S=.o)
export BINFILES := $(BINFILES:.bin=.bin.h)
export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \
-I$(CURDIR)/$(BUILD)
.PHONY: $(BUILD) clean
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
clean:
@echo Clean...
@rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a $(OUTPUT).pkg
pkg: $(BUILD)
@echo Creating PKG...
@mkdir -p $(BUILD)/pkg
@mkdir -p $(BUILD)/pkg/USRDIR
@cp $(ICON_PNG) $(BUILD)/pkg/ICON0.PNG
@$(FSELF) -n $(BUILD)/$(TARGET).elf $(BUILD)/pkg/USRDIR/EBOOT.BIN
@$(SFO) -f $(SFOXML) $(BUILD)/pkg/PARAM.SFO
@$(PKG) --contentid $(CONTENTID) $(BUILD)/pkg/ $(OUTPUT).pkg
run: $(BUILD)
@$(PS3LOADAPP) $(OUTPUT).self
restart: $(BUILD)
@expect restart
@sleep 1
@$(PS3LOADAPP) $(OUTPUT).self
else
DEPENDS := $(OFILES:.o=.d)
$(OUTPUT).self: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
$(OFILES): $(BINFILES)
-include $(DEPENDS)
endif