2 OBJS=test.o util-debug.o ds18b20.o
4 OPENCM3_DIR=/home/mj/stm/libopencm3
7 all: $(BINARY).elf $(BINARY).bin
10 ../bin/st-flash write $(BINARY).bin 0x8000000
20 include $(OPENCM3_DIR)/mk/genlink-config.mk
22 PREFIX ?= arm-none-eabi
29 OBJCOPY := $(PREFIX)-objcopy
30 OBJDUMP := $(PREFIX)-objdump
36 TGT_CFLAGS += $(OPT) $(CSTD) $(DEBUG)
37 TGT_CFLAGS += $(ARCH_FLAGS)
38 TGT_CFLAGS += -Wall -Wextra -Wshadow -Wimplicit-function-declaration
39 TGT_CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
40 TGT_CFLAGS += -fno-common -ffunction-sections -fdata-sections
44 TGT_LDFLAGS += --static -nostartfiles
45 TGT_LDFLAGS += -T$(LDSCRIPT)
46 TGT_LDFLAGS += $(ARCH_FLAGS) $(DEBUG)
47 TGT_LDFLAGS += -Wl,-Map=$(*).map -Wl,--cref
48 TGT_LDFLAGS += -Wl,--gc-sections
50 TGT_LDFLAGS += -Wl,--print-gc-sections
53 LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
55 include $(OPENCM3_DIR)/mk/genlink-rules.mk
58 @printf " OBJCOPY $(*).bin\n"
59 $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin
61 %.elf: $(OBJS) $(LDSCRIPT)
62 @printf " LD $(*).elf\n"
63 $(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $*.elf
66 @printf " CC $(*).c\n"
67 $(Q)$(CC) $(TGT_CFLAGS) $(CFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $*.o -c $*.c
72 $(Q)rm -f *.elf *.bin *.o *.d *.map $(LDSCRIPT)
76 $(STFLASH) write $(*).bin 0x8000000
81 -include $(OBJS:.o=.d)