blob: cc240008025625df7b7ad9a2dcce6abbdc93c94d (
plain)
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
|
#1-0----------------------------------------------------------------------------
DS2SDKPATH :=/opt/ds2sdk
#The name final target
TARGET := CATSFC
#The directory where object files & intermediate files will be placed
BUILD := build
#1-1----------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#-------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
$(MAKE) -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
rm -fr $(BUILD) $(OUTPUT).plg
#---------------------------------------------------------------------------------
#1-1----------------------------------------------------------------------------
else
#-------------------------------------------------------------------------------
# CROSS :=#
CROSS := /opt/mipsel-4.1.2-nopic/bin/
CC = $(CROSS)mipsel-linux-gcc
AR = $(CROSS)mipsel-linux-ar rcsv
LD = $(CROSS)mipsel-linux-ld
OBJCOPY = $(CROSS)mipsel-linux-objcopy
NM = $(CROSS)mipsel-linux-nm
OBJDUMP = $(CROSS)mipsel-linux-objdump
TOPDIR = ./..
SFCDIR = $(TOPDIR)/source
FS_DIR = $(DS2SDKPATH)/libsrc/fs
CONSOLE_DIR = $(DS2SDKPATH)/libsrc/console
KEY_DIR = $(DS2SDKPATH)/libsrc/key
ZLIB_DIR = $(DS2SDKPATH)/libsrc/zlib
SRC :=
SSRC :=
LIBS := $(DS2SDKPATH)/lib/libds2b.a -lc -lm -lgcc
EXTLIBS := $(DS2SDKPATH)/lib/libds2a.a
INC := -I$(DS2SDKPATH)/include -I$(FS_DIR) -I$(CONSOLE_DIR) -I$(KEY_DIR) -I$(ZLIB_DIR)
CFLAGS := -mips32 -Os -mno-abicalls -fno-pic -fno-builtin \
-fno-exceptions -fno-function-sections -mlong-calls\
-fomit-frame-pointer -msoft-float -G 4
LINKS := $(DS2SDKPATH)/specs/link.xn
STARTS := $(DS2SDKPATH)/specs/start.S
STARTO := start.o
include $(SFCDIR)/sfc.mk
OBJS := $(addsuffix .o , $(basename $(notdir $(SRC))))
SOBJS := $(addsuffix .o , $(basename $(notdir $(SSRC))))
# OBJS := $(SRC:.c=.o)
# SOBJS := $(SSRC:.S=.o)
APP := sfc.elf
all: $(APP)
@echo $(INC)
$(OBJCOPY) -x -O binary $(APP) sfc.dat
$(DS2SDKPATH)/tools/makeplug sfc.dat $(OUTPUT).plg
# but also, if you want to debug even more
# $(OBJDUMP) -d $(APP) > sfc.dump
# $(NM) $(APP) | sort > sfc.sym
# $(OBJDUMP) -h $(APP) > sfc.map
$(APP): depend $(SOBJS) $(OBJS) $(STARTO) $(LINKS) $(EXTLIBS)
$(CC) -nostdlib -static -T $(LINKS) -o $@ $(STARTO) $(SOBJS) $(OBJS) $(EXTLIBS) $(LIBS)
$(EXTLIBS):
make -C $(DS2SDKPATH)/source/
$(STARTO):
$(CC) $(CFLAGS) $(INC) -o $@ -c $(STARTS)
.c.o:
$(CC) $(CFLAGS) $(INC) -o $@ -c $<
.cpp.o:
$(CC) $(CFLAGS) $(INC) -fno-rtti -o $@ -c $<
.S.o:
$(CC) $(CFLAGS) $(INC) -D_ASSEMBLER_ -D__ASSEMBLY__ -o $@ -c $<
clean:
rm -fr *.o $(OBJS) $(OTHER) *.bin *.sym *.map *.dump *.lib
rm depend
# depend: Makefile $(OBJS:.o=.c) $(SOBJS:.o=.S)
Makefile: depend
touch $@
depend: $(SSRC) $(SRC)
$(CC) -MM $(CFLAGS) $(INC) $(SSRC) $(SRC) > $@
-include depend
#1-1----------------------------------------------------------------------------
endif
#-------------------------------------------------------------------------------
|