forked from HACKERCHANNEL/PSL1GHT
-
Notifications
You must be signed in to change notification settings - Fork 64
/
base_rules
96 lines (77 loc) · 3.16 KB
/
base_rules
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
ifeq ($(strip $(PS3DEV)),)
ifeq ($(strip $(DEVKITPS3)),)
export PS3DEV := /usr/local/ps3dev
else
export PS3DEV := $(DEVKITPS3)
endif
endif
# Allow for 'make VERBOSE=1' to see the recepie executions
ifndef VERBOSE
VERB := @
endif
#dont' auto-delete elf & self files
.PRECIOUS: %.elf %.self
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
export AS := $(PREFIX)as
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export LD ?= $(PREFIX)gcc
export STRIP := $(PREFIX)strip
export OBJCOPY := $(PREFIX)objcopy
#use dependencies when user has defined a place to put them into
ifneq (,$(DEPSDIR))
DEPSOPT = -MMD -MP -MF $(DEPSDIR)/$*.d
endif
UNAME := $(shell uname -s)
ISVC=$(or $(VCBUILDHELPER_COMMAND),$(MSBUILDEXTENSIONSPATH32),$(MSBUILDEXTENSIONSPATH))
ifneq (,$(ISVC))
ERROR_FILTER := 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/g'
endif
ifneq (,$(findstring MINGW,$(UNAME)))
POSTFIX := .exe
endif
ifneq (,$(findstring CYGWIN,$(UNAME)))
POSTFIX := .exe
endif
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
$(VERB) echo $(notdir $@)
$(VERB) rm -f $@
$(VERB) $(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.elf: $(OFILES)
$(VERB) echo linking ... $(notdir $@)
$(VERB) $(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
%.o: %.cpp
$(VERB) echo $(notdir $<)
$(VERB) $(CXX) $(DEPSOPT) $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.c
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.m
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) $(OBJCFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.s
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.S
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
$(VERB) bin2s -a 64 $< | $(AS) -o $(@)
$(VERB) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
$(VERB) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
$(VERB) echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef