blob: 42d642f1b7df095dcec0e0835f3e60626e6e4829 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001# use linker garbage collection, if requested
2ifeq ($(WITH_LINKER_GC),1)
3GLOBAL_COMPILEFLAGS += -ffunction-sections -fdata-sections
4GLOBAL_LDFLAGS += --gc-sections
5endif
6
7ifneq (,$(EXTRA_BUILDRULES))
8-include $(EXTRA_BUILDRULES)
9endif
10
11$(EXTRA_LINKER_SCRIPTS):
12
13$(OUTBIN): $(OUTELF)
14 @echo generating image: $@
15 $(NOECHO)$(SIZE) $<
16 $(NOECHO)$(OBJCOPY) -O binary $< $@
17
18$(OUTELF).hex: $(OUTELF)
19 @echo generating hex file: $@
20 $(NOECHO)$(OBJCOPY) -O ihex $< $@
21
22$(OUTELF): $(ALLMODULE_OBJS) $(EXTRA_OBJS) $(LINKER_SCRIPT) $(EXTRA_LINKER_SCRIPTS)
23 @echo linking $@
24 $(NOECHO)$(SIZE) -t --common $(sort $(ALLMODULE_OBJS)) $(EXTRA_OBJS)
25 $(NOECHO)$(LD) $(GLOBAL_LDFLAGS) -dT $(LINKER_SCRIPT) $(addprefix -T,$(EXTRA_LINKER_SCRIPTS)) \
26 $(ALLMODULE_OBJS) $(EXTRA_OBJS) $(LIBGCC) -o $@
27
28$(OUTELF).sym: $(OUTELF)
29 @echo generating symbols: $@
30 $(NOECHO)$(OBJDUMP) -t $< | $(CPPFILT) > $@
31
32$(OUTELF).sym.sorted: $(OUTELF)
33 @echo generating sorted symbols: $@
34 $(NOECHO)$(OBJDUMP) -t $< | $(CPPFILT) | sort > $@
35
36$(OUTELF).lst: $(OUTELF)
37 @echo generating listing: $@
38 $(NOECHO)$(OBJDUMP) -Mreg-names-raw -d $< | $(CPPFILT) > $@
39
40$(OUTELF).debug.lst: $(OUTELF)
41 @echo generating listing: $@
42 $(NOECHO)$(OBJDUMP) -Mreg-names-raw -S $< | $(CPPFILT) > $@
43
44$(OUTELF).dump: $(OUTELF)
45 @echo generating objdump: $@
46 $(NOECHO)$(OBJDUMP) -x $< > $@
47
48$(OUTELF).size: $(OUTELF)
49 @echo generating size map: $@
50 $(NOECHO)$(NM) -S --size-sort $< > $@
51
52# print some information about the build
53$(BUILDDIR)/srcfiles.txt:
54 @echo generating $@
55 $(NOECHO)echo $(sort $(ALLSRCS)) | tr ' ' '\n' > $@
56
57.PHONY: $(BUILDDIR)/srcfiles.txt
58
59$(BUILDDIR)/include_paths.txt:
60 @echo generating $@
61 $(NOECHO)echo $(subst -I,,$(sort $(GLOBAL_INCLUDES))) | tr ' ' '\n' > $@
62
63.PHONY: $(BUILDDIR)/include_paths.txt
64
65#include arch/$(ARCH)/compile.mk
66