Numworks-zeta-os/Makefile

101 lines
2.5 KiB
Makefile
Raw Normal View History

2024-03-24 12:35:27 +00:00
TARGET = main
# Directories
SRC_DIR = src
BUILD_DIR = build
# Define the linker script location and chip architecture.
LD_SCRIPT = $(SRC_DIR)/linker.ld
MCU_SPEC = cortex-m7
2024-03-24 12:35:27 +00:00
# Toolchain definitions (ARM bare metal defaults)
2024-04-02 16:42:55 +00:00
ifndef RUN_IN_GITHUB_ACTION
2024-04-02 16:44:36 +00:00
TOOLCHAIN = /usr/bin/# if make is run normally
2024-04-02 16:29:50 +00:00
else
2024-04-02 16:42:55 +00:00
TOOLCHAIN = $(ARM_NONE_EABI_GCC_PATH) # if run inside of a github action
2024-04-02 16:29:50 +00:00
endif
2024-04-02 16:44:36 +00:00
CP = $(TOOLCHAIN)arm-none-eabi-g++
CC = $(TOOLCHAIN)arm-none-eabi-gcc
AS = $(TOOLCHAIN)arm-none-eabi-as
LD = $(TOOLCHAIN)arm-none-eabi-ld
OC = $(TOOLCHAIN)arm-none-eabi-objcopy
OD = $(TOOLCHAIN)arm-none-eabi-objdump
OS = $(TOOLCHAIN)arm-none-eabi-size
2024-03-24 12:35:27 +00:00
# Assembly directives.
ASFLAGS += -c
ASFLAGS += -O0
ASFLAGS += -mcpu=$(MCU_SPEC)
ASFLAGS += -march=armv7e-m
ASFLAGS += -mfpu=fpv5-sp-d16
ASFLAGS += -mfloat-abi=softfp
2024-03-24 12:35:27 +00:00
ASFLAGS += -mthumb
ASFLAGS += -Wall
# (Set error messages to appear on a single line.)
ASFLAGS += -fmessage-length=0
# C compilation directives
CFLAGS += -mcpu=$(MCU_SPEC)
CFLAGS += -march=armv7e-m
CFLAGS += -mfpu=fpv5-sp-d16
CFLAGS += -mfloat-abi=softfp
2024-03-24 12:35:27 +00:00
CFLAGS += -mthumb
CFLAGS += -Wall
CFLAGS += -g
# (Set error messages to appear on a single line.)
CFLAGS += -fmessage-length=0
# (Set system to ignore semihosted junk)
CFLAGS += --specs=nosys.specs
# Linker directives.
LSCRIPT = $(LD_SCRIPT)
LFLAGS += -mcpu=$(MCU_SPEC)
LFLAGS += -mthumb
LFLAGS += -Wall
LFLAGS += --specs=nosys.specs
LFLAGS += -nostdlib
LFLAGS += -T$(LSCRIPT)
# AS_SRC = $(SRC_DIR)/core.S
#C_SRC = $(SRC_DIR)/main.c
2024-03-31 16:17:46 +00:00
CPP_SRC := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/Laplace/*.cpp)
C_SRC := $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/Laplace/*.c)
2024-03-24 12:35:27 +00:00
2024-03-24 20:01:38 +00:00
INCLUDE = -I./
INCLUDE += -I./device
#OBJS = $(BUILD_DIR)/$(notdir $(AS_SRC:.S=.o))
#OBJS += $(BUILD_DIR)/$(notdir $(C_SRC:.c=.o))
2024-03-31 16:17:46 +00:00
OBJS += $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SRC))
OBJS += $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(CPP_SRC))
2024-03-24 12:35:27 +00:00
.PHONY: all
all: $(BUILD_DIR)/$(TARGET).bin
#$(BUILD_DIR)/%.o: $(SRC_DIR)/%.S
# $(CC) -x assembler-with-cpp $(ASFLAGS) $< -o $@
2024-03-24 12:35:27 +00:00
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CP) -c $(CFLAGS) $(INCLUDE) $< -o $@
2024-03-24 12:35:27 +00:00
$(BUILD_DIR)/$(TARGET).elf: $(OBJS)
$(CC) $^ $(LFLAGS) -o $@
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(OC) -S -O binary $< $@
$(OS) $<
.PHONY: clean
clean:
rm -f $(BUILD_DIR)/*.o
2024-03-31 19:05:08 +00:00
rm -f $(BUILD_DIR)/Laplace/*.o
2024-03-24 12:35:27 +00:00
rm -f $(BUILD_DIR)/$(TARGET).elf
2024-04-02 14:57:22 +00:00
rm -f $(BUILD_DIR)/$(TARGET).bin
.PHONY: flash
flash:
dfu-util -a 0 -i 0 -s 0x90400000 -D build/main.bin