-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (48 loc) · 1.41 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
56
57
58
59
60
61
62
63
64
65
66
67
CROSSCOMPILE = arm-none-eabi-
CC = $(CROSSCOMPILE)gcc
LD = $(CROSSCOMPILE)ld
AS = $(CROSSCOMPILE)as
DB = $(CROSSCOMPILE)gdb
CPP = $(CROSSCOMPILE)cpp
OBJCOPY = $(CROSSCOMPILE)objcopy
DIRS = src lib
DEVICE = STM32F030R8
GDB_SERVER = JLinkGDBServer
ENDIAN = little
ARCH = -mcpu=cortex-m0 -mthumb
ASFLAGS = -g
CPPFLAGS = -Iinclude -D$(DEVICE) -DSTM32F030x8
CFLAGS = -Wall -Wextra -g -O1 -std=gnu99 $(ARCH)
LDFLAGS = -T ld_ram.lds -nostdlib
LDLIBS =
CSRCS = $(foreach DIR, $(DIRS), $(wildcard $(DIR)/*.c))
SSRCS = $(foreach DIR, $(DIRS), $(wildcard $(DIR)/*.s))
OBJS = $(CSRCS:%.c=%.o) $(SSRCS:%.s=%.o)
DEPS = $(CSRCS:%.c=%.d)
EXE = main
ELF = $(EXE).elf
IMG = $(EXE).bin
STATEMENT = statement
TP = tp
TP_PATH = $(STATEMENT)/$(TP)
$(IMG): $(ELF)
$(OBJCOPY) -O binary $< $@
$(ELF): $(OBJS) ld_ram.lds
$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@
-include $(DEPS)
%.d: %.c
@$(CC) $(CPPFLAGS) $(CFLAGS) -M -MF $@ -MP $< -MT $(@:%.d=%.o)
gdb_server:
$(GDB_SERVER) -device $(DEVICE) -endian $(ENDIAN) -if SWD -speed auto -ir -LocalhostOnly
gdb:
$(DB) $(ELF)
clean:
$(RM) $(OBJS) $(DEPS)
$(RM) $(STATEMENT)/*.aux $(STATEMENT)/*.fdb_latexmk $(STATEMENT)/*.fls $(STATEMENT)/*.log $(STATEMENT)/*.out $(STATEMENT)/*.toc
clean-all: clean
$(RM) $(ELF) $(IMG) $(TP_PATH).pdf
re: clean-all $(IMG)
tp: $(TP_PATH).pdf
$(TP_PATH).pdf: $(TP_PATH).tex
pdflatex -output-directory $(STATEMENT) $<
.PHONY: gdb gdb_server clean clean-all re tp