forked from Eddy0402/MSP430f5529_Linux_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·59 lines (43 loc) · 1.31 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
MAKDIR = mk
MAK = $(wildcard $(MAKDIR)/*.mk)
include $(MAK)
ELFOUT=$(DEVICE).out
FIRMWARE=$(DEVICE).hex
OUTDIR=build
INCLUDE_DIR += \
include
SRCDIR += \
src \
SRC += \
$(wildcard $(addsuffix /*.c,$(SRCDIR))) \
$(wildcard $(addsuffix /*.s,$(SRCDIR))) \
INCLUDES = $(addprefix -I,$(INCLUDE_DIR))
OBJS := $(addprefix $(OUTDIR)/,$(patsubst %.S, %.o, $(patsubst %.s, %.o, $(patsubst %.c, %.o, $(SRC)))))
DEPENDS = $(addsuffix .d,$(OBJS))
CFLAGS = -I $(SUPPORT_FILE_DIRECTORY) $(INCLUDES) -mmcu=$(DEVICE) -O2 -g
LFLAGS = -L $(SUPPORT_FILE_DIRECTORY) -T $(DEVICE).ld
all: $(FIRMWARE)
$(OUTDIR)/%.o: %.s
@mkdir -p $(dir $@)
@echo " CC "$@
@$(CC) $(CFLAGS) -c $< -o $@
$(OUTDIR)/%.o: %.c
@mkdir -p $(dir $@)
@echo " CC "$@
@$(CC) $(CFLAGS) -MMD -MF [email protected] -c $< -o $@
$(FIRMWARE): $(ELFOUT)
@echo " OBJCOPY " $? $@
@$(OBJCOPY) -Oihex $? $@
$(ELFOUT): $(OBJS)
@echo " LD " $@
@$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
debug: all
$(GDB_SERVER) $(GDB_SERVER_DAT) &
$(GDB) $(ELFOUT) -x tools/gdbscript
flash:
LD_LIBRARY_PATH=$(FLASH_LIBDIR) $(FLASH) -w $(FIRMWARE) -v -g -z [VCC]
LD_LIBRARY_PATH=$(FLASH_LIBDIR) $(FLASH) -r [Firmware Output.txt,MAIN]
clean:
rm -rf $(OBJS) $(FIRMWARE) $(ELFOUT)
.PHONY: all clean flash debug
-include $(DEPENDS)