rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | # use linker garbage collection, if requested |
| 2 | ifeq ($(WITH_LINKER_GC),1) |
| 3 | GLOBAL_COMPILEFLAGS += -ffunction-sections -fdata-sections |
| 4 | GLOBAL_LDFLAGS += --gc-sections |
| 5 | endif |
| 6 | |
| 7 | ifneq (,$(EXTRA_BUILDRULES)) |
| 8 | -include $(EXTRA_BUILDRULES) |
| 9 | endif |
| 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 | |