You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB
Makefile

AS := arm-none-eabi-as
CC := arm-none-eabi-gcc
OBJCOPY := arm-none-eabi-objcopy
OUTFILE := main.out
HEXFILE := $(subst .out,.hex,$(OUTFILE))
MCUFLAGS := -mthumb -mcpu=cortex-m4 #-mfloat-abi=hard -mfpu=fpv4-sp-d16
AFLAGS = $(MCUFLAGS)
CFLAGS += $(MCUFLAGS) -ggdb -g3 -O0 \
-I$(COMMON_DIR) -I$(COMMON_DIR)/cmsis \
-fno-builtin -fsigned-char -ffreestanding \
-Wall -Werror -Wextra -pedantic
LDFLAGS := -T $(COMMON_DIR)/link.ld -nostartfiles
CFILES += $(wildcard $(COMMON_DIR)/*.c) \
$(wildcard $(COMMON_DIR)/*.s)
OFILES := $(patsubst %.c, %.o, $(patsubst %.s, %.o, $(CFILES)))
.PHONY: all upload clean
all: $(OUTFILE)
upload: $(HEXFILE)
@openocd -f interface/stlink.cfg -f target/stm32l4x.cfg \
-c "program $(HEXFILE) verify reset exit"
clean:
@echo " CLEAN"
@rm -f $(OUTFILE) $(OFILES)
$(HEXFILE): $(OUTFILE)
@echo " OBJCOPY " $@
@$(OBJCOPY) -O ihex $< $@
$(OUTFILE): $(OFILES)
@echo " CC " $@
@$(CC) $(CFLAGS) $(LDFLAGS) $(OFILES) -o $@
%.o: %.c
@echo " CC " $<
@$(CC) $(CFLAGS) -c $< -o $@
%.o: %.s
@echo " AS " $<
@$(AS) $(AFLAGS) -c $< -o $@