-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
53 lines (40 loc) · 1.33 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
# Makefile for ti-msp430
# intended for a single source (assembly) file (.asm)
# to be converted to a object (.o) and executable (.elf)
GCC_DIR = /opt/ti-msp430
SUPPORT_HEADERS = $(GCC_DIR)/lib/gcc/msp430-elf/9.3.1/include
SUPPORT_LINKS = $(GCC_DIR)/lib/gcc/msp430-elf/9.3.1/include
# Set your device here
MCU ?= msp430g2553
CC = msp430-elf-gcc
AS = msp430-elf-as
LD = msp430-elf-ld
GDB = msp430-elf-gdb
AFLAGS = -D --warn --strip-local-absolute
LFLAGS = -L $(SUPPORT_LINKS) --warn-section-align --warn-unresolved-symbols -q -m msp430elf -T $(MCU).ld
DEBUG ?= 0
ifeq ($(DEBUG), 1)
AFLAGS += -g --gdwarf-2 --defsym DEBUG=1
endif
ENTRY_SECT ?= Reset
SRCS := $(wildcard *.asm)
OBJS := $(addsuffix .o,$(basename $(SRCS)))
PYTHON_SCRIPT := $(wildcard *.py)
PYTHON_SCRIPT_OUTPUT := $(wildcard *.inc)
TARGET := $(basename $(SRCS))
.PHONY: setup
setup: $(PYTHON_SCRIPT)
@echo "--- Generating GNU AS header file"
python3 $(PYTHON_SCRIPT) -d $(MCU) -I $(SUPPORT_HEADERS) -L $(SUPPORT_LINKS) --msp430_comments
.PHONY: all
all: setup $(TARGET).elf
$(TARGET).elf: $(OBJS)
@echo "--- Linking build"
$(LD) $(LFLAGS) $(OBJS) -e $(ENTRY_SECT) -o $@
$(OBJS): $(SRCS)
@echo "--- Compiling objects"
$(AS) $(AFLAGS) -I $(SUPPORT_HEADERS) -mmcu=$(MCU) $(SRCS) -o $@
.PHONY: clean
clean:
@echo "--- Cleaning build"
-rm $(OBJS) $(TARGET).elf $(PYTHON_SCRIPT_OUTPUT)