-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (44 loc) · 1.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
include Makefile.common
STARTUP=startup.c
LINKERSCRIPT=linker.ld
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-T$(LINKERSCRIPT)
LDLIBS+=-lm
LDLIBS+=-lstm32
#LDLIBS+=-lusbfs
all: libs src
$(CC) -o $(BUILDDIR)/$(PROGRAM).elf $(LDFLAGS) \
-Wl,--whole-archive \
src/app.a \
-Wl,--no-whole-archive \
$(LDLIBS)
$(OBJCOPY) -O ihex $(BUILDDIR)/$(PROGRAM).elf $(BUILDDIR)/$(PROGRAM).hex
$(OBJCOPY) -O binary $(BUILDDIR)/$(PROGRAM).elf $(BUILDDIR)/$(PROGRAM).bin
#Extract info contained in ELF to readable text-files:
$(RE) -a $(BUILDDIR)/$(PROGRAM).elf > $(BUILDDIR)/$(PROGRAM).info_elf
$(SIZE) -d -B -t $(BUILDDIR)/$(PROGRAM).elf > $(BUILDDIR)/$(PROGRAM).info_size
$(OD) -S $(BUILDDIR)/$(PROGRAM).elf > $(BUILDDIR)/$(PROGRAM).info_code
$(NM) -t d -S --size-sort -s $(BUILDDIR)/$(PROGRAM).elf > $(BUILDDIR)/$(PROGRAM).info_symbol
.PHONY: libs src clean
libs:
$(MAKE) -C libs $@
src:
$(MAKE) -C src $@
debug:
$(GDB) -x 'gdb-init' $(BUILDDIR)/$(PROGRAM).elf
usbprogram: all
dfu-util -R -a 0 -d 0483:df11 -s 0x08000000 -D $(BUILDDIR)/$(PROGRAM).bin
program: all
$(STM32FLASH) $(BUILDDIR)/$(PROGRAM).bin $(FLASHLOC)
clean:
$(MAKE) -C src $@
$(MAKE) -C libs $@
rm -f $(BUILDDIR)/$(PROGRAM).elf $(BUILDDIR)/$(PROGRAM).hex $(BUILDDIR)/$(PROGRAM).bin \
$(BUILDDIR)/$(PROGRAM).info_elf $(BUILDDIR)/$(PROGRAM).info_size
rm -f $(BUILDDIR)/$(PROGRAM).info_code
rm -f $(BUILDDIR)/$(PROGRAM).info_symbol
appclean:
$(MAKE) -C src $@
rm -f $(BUILDDIR)/$(PROGRAM).elf $(BUILDDIR)/$(PROGRAM).hex $(BUILDDIR)/$(PROGRAM).bin \
$(BUILDDIR)/$(PROGRAM).info_elf $(BUILDDIR)/$(PROGRAM).info_size
rm -f $(BUILDDIR)/$(PROGRAM).info_code
rm -f $(BUILDDIR)/$(PROGRAM).info_symbol