4 OPENCM3_DIR=/home/mj/stm/libopencm3
7 all: $(BINARY).elf $(BINARY).bin
10 ../bin/st-flash write $(BINARY).bin 0x8000000
17 include $(OPENCM3_DIR)/mk/genlink-config.mk
19 PREFIX ?= arm-none-eabi
26 OBJCOPY := $(PREFIX)-objcopy
27 OBJDUMP := $(PREFIX)-objdump
33 TGT_CFLAGS += $(OPT) $(CSTD) $(DEBUG)
34 TGT_CFLAGS += $(ARCH_FLAGS)
35 TGT_CFLAGS += -Wall -Wextra -Wshadow -Wimplicit-function-declaration
36 TGT_CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
37 TGT_CFLAGS += -fno-common -ffunction-sections -fdata-sections
41 TGT_LDFLAGS += --static -nostartfiles
42 TGT_LDFLAGS += -T$(LDSCRIPT)
43 TGT_LDFLAGS += $(ARCH_FLAGS) $(DEBUG)
44 TGT_LDFLAGS += -Wl,-Map=$(*).map -Wl,--cref
45 TGT_LDFLAGS += -Wl,--gc-sections
47 TGT_LDFLAGS += -Wl,--print-gc-sections
50 LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
52 include $(OPENCM3_DIR)/mk/genlink-rules.mk
55 @printf " OBJCOPY $(*).bin\n"
56 $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin
58 %.elf: $(OBJS) $(LDSCRIPT)
59 @printf " LD $(*).elf\n"
60 $(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $*.elf
63 @printf " CC $(*).c\n"
64 $(Q)$(CC) $(TGT_CFLAGS) $(CFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $*.o -c $*.c
69 $(Q)rm -f *.elf *.bin *.o *.d *.map $(LDSCRIPT)
73 $(STFLASH) write $(*).bin 0x8000000
78 -include $(OBJS:.o=.d)