1# 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	$(info generating image: $@)
15	$(NOECHO)$(SIZE) $<
16	$(NOECHO)$(OBJCOPY) -O binary $< $@
17
18$(OUTELF).hex: $(OUTELF)
19	$(info generating hex file: $@)
20	$(NOECHO)$(OBJCOPY) -O ihex $< $@
21
22$(OUTELF): $(ALLMODULE_OBJS) $(EXTRA_OBJS) $(LINKER_SCRIPT) $(EXTRA_LINKER_SCRIPTS)
23	$(info linking $@)
24	$(NOECHO)$(SIZE) -t --common $(sort $(ALLMODULE_OBJS)) $(EXTRA_OBJS)
25	$(NOECHO)$(LD) $(GLOBAL_LDFLAGS) $(ARCH_LDFLAGS) -dT $(LINKER_SCRIPT) \
26		$(addprefix -T,$(EXTRA_LINKER_SCRIPTS)) \
27		$(ALLMODULE_OBJS) $(EXTRA_OBJS) $(LIBGCC) -Map=$(OUTELF).map -o $@
28
29$(OUTELF).sym: $(OUTELF)
30	$(info generating symbols: $@)
31	$(NOECHO)$(OBJDUMP) -t $< | $(CPPFILT) > $@
32
33$(OUTELF).sym.sorted: $(OUTELF)
34	$(info generating sorted symbols: $@)
35	$(NOECHO)$(OBJDUMP) -t $< | $(CPPFILT) | sort > $@
36
37$(OUTELF).lst: $(OUTELF)
38	$(info generating listing: $@)
39	$(NOECHO)$(OBJDUMP) $(ARCH_OBJDUMP_FLAGS) -d $< | $(CPPFILT) > $@
40
41$(OUTELF).debug.lst: $(OUTELF)
42	$(info generating listing: $@)
43	$(NOECHO)$(OBJDUMP) $(ARCH_OBJDUMP_FLAGS) -S $< | $(CPPFILT) > $@
44
45$(OUTELF).dump: $(OUTELF)
46	$(info generating objdump: $@)
47	$(NOECHO)$(OBJDUMP) -x $< | $(CPPFILT) > $@
48
49$(OUTELF).size: $(OUTELF)
50	$(info generating size map: $@)
51	$(NOECHO)$(NM) -S --size-sort $< | $(CPPFILT) > $@
52
53# print some information about the build
54$(BUILDDIR)/srcfiles.txt: $(OUTELF)
55	$(info generating $@)
56	$(NOECHO)echo $(sort $(ALLSRCS)) | tr ' ' '\n' > $@
57
58$(BUILDDIR)/include_paths.txt: $(OUTELF)
59	$(info generating $@)
60	$(NOECHO)echo $(subst -I,,$(sort $(GLOBAL_INCLUDES))) | tr ' ' '\n' > $@
61
62#include arch/$(ARCH)/compile.mk
63
64