-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rules.make
executable file
·79 lines (61 loc) · 2.75 KB
/
Rules.make
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
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004.
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
IOP_CC_VERSION := $(shell $(IOP_CC) -dumpversion)
ASFLAGS_TARGET = -mcpu=r3000
ifeq ($(IOP_CC_VERSION),3.2.2)
CFLAGS_TARGET = -miop
ASFLAGS_TARGET = -march=r3000
LDFLAGS_TARGET = -miop
endif
ifeq ($(IOP_CC_VERSION),3.2.3)
CFLAGS_TARGET = -miop
ASFLAGS_TARGET = -march=r3000
LDFLAGS_TARGET = -miop
endif
IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/common/include -Iinclude
IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -D_IOP -c $(IOP_INCS) $(IOP_CFLAGS)
IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS)
IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS)
# Additional C compiler flags for GCC >=v5.3.0
# -msoft-float is to "remind" GCC/Binutils that the soft-float ABI is to be used. This is due to a bug, which
# results in the ABI not being passed correctly to binutils and iop-as defaults to the hard-float ABI instead.
# -mno-explicit-relocs is required to work around the fact that GCC is now known to
# output multiple LO relocs after one HI reloc (which the IOP kernel cannot deal with).
# -fno-toplevel-reorder (for IOP import and export tables only) disables toplevel reordering by GCC v4.2 and later.
# Without it, the import and export tables can be broken apart by GCC's optimizations.
ifneq ($(IOP_CC_VERSION),3.2.2)
ifneq ($(IOP_CC_VERSION),3.2.3)
IOP_CFLAGS += -msoft-float -mno-explicit-relocs
IOP_IETABLE_CFLAGS := -fno-toplevel-reorder
endif
endif
# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB
$(IOP_OBJS_DIR)%.o : $(IOP_SRC_DIR)%.c
$(IOP_CC) $(IOP_CFLAGS) $< -o $@
$(IOP_OBJS_DIR)%.o : $(IOP_SRC_DIR)%.s
$(IOP_AS) $(IOP_ASFLAGS) $< -o $@
# A rule to build imports.lst.
$(IOP_OBJS_DIR)%.o : $(IOP_SRC_DIR)%.lst
echo "#include \"irx_imports.h\"" > $(IOP_OBJS_DIR)build-imports.c
cat $< >> $(IOP_OBJS_DIR)build-imports.c
$(IOP_CC) $(IOP_CFLAGS) $(IOP_IETABLE_CFLAGS) -I$(IOP_SRC_DIR) $(IOP_OBJS_DIR)build-imports.c -o $@
-rm -f $(IOP_OBJS_DIR)build-imports.c
# A rule to build exports.tab.
$(IOP_OBJS_DIR)%.o : $(IOP_SRC_DIR)%.tab
echo "#include \"irx.h\"" > $(IOP_OBJS_DIR)build-exports.c
cat $< >> $(IOP_OBJS_DIR)build-exports.c
$(IOP_CC) $(IOP_CFLAGS) $(IOP_IETABLE_CFLAGS) -I$(IOP_SRC_DIR) $(IOP_OBJS_DIR)build-exports.c -o $@
-rm -f $(IOP_OBJS_DIR)build-exports.c
$(IOP_OBJS_DIR):
mkdir $(IOP_OBJS_DIR)
$(IOP_BIN_DIR):
mkdir $(IOP_BIN_DIR)
$(IOP_BIN) : $(IOP_OBJS)
$(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS)
$(IOP_LIB) : $(IOP_OBJS)
$(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS)