-
Notifications
You must be signed in to change notification settings - Fork 95
/
common.mk
60 lines (45 loc) · 1.3 KB
/
common.mk
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
AR = $(PREFIX)ar
AS = $(PREFIX)as
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
LD = $(PREFIX)ld
OBJCOPY = $(PREFIX)objcopy
RANLIB = $(PREFIX)ranlib
STRIP = $(PREFIX)strip
BIN2S = $(DEVKITPRO)/tools/bin/bin2s
ifeq ($(NOMAPFILE),)
LDFLAGS += -Wl,-Map,$(TARGET).map
endif
ifneq ($(LDSCRIPT),)
LDFLAGS += -Wl,-T$(LDSCRIPT)
endif
DEPDIR = .deps
all: $(TARGET)
$(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
endif
%.o: %.c
@echo " COMPILE $<"
@mkdir -p $(DEPDIR)
@$(CC) $(CFLAGS) $(DEFINES) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c $< -o $@
%.o: %.s
@echo " ASSEMBLE $<"
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
%.o: %.S
@echo " ASSEMBLE $<"
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
clean:
rm -rf $(DEPDIR)
rm -f $(TARGET) $(TARGET).map $(OBJS)
define bin2o
@echo " BIN2S $(notdir $<)"
@$(BIN2S) -a 32 $< | $(AS) -o $(@)
@echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
@echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
@echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef
-include $(DEPDIR)/*
.PHONY: clean