Newer
Older
OUTPUT_DIR := ./output
IMAGE := $(OUTPUT_DIR)/RTOSDemo.out
# The directory that contains the /source and /demo sub directories.
FREERTOS_ROOT = ./../FreeRTOS/FreeRTOS
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
SIZE = arm-none-eabi-size
MAKE = make
CFLAGS += -ffreestanding -mthumb -mcpu=cortex-m3
CFLAGS += -Wall -Wextra -Wshadow
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT $@
#CFLAGS += -std=c99
#CFLAGS += -Wpedantic -fanalyzer
#CFLAGS += -flto
CFLAGS += $(INCLUDE_DIRS)
LDFLAGS += -nostartfiles
LDFLAGS += -specs=nano.specs -specs=nosys.specs # -specs=rdimon.specs
#
# Kernel build.
#
KERNEL_DIR = $(FREERTOS_ROOT)/Source
KERNEL_PORT_DIR += $(KERNEL_DIR)/portable/GCC/ARM_CM3
INCLUDE_DIRS += -I$(KERNEL_DIR)/include \
-I$(KERNEL_PORT_DIR)
VPATH += $(KERNEL_DIR) $(KERNEL_PORT_DIR) $(KERNEL_DIR)/portable/MemMang
SOURCE_FILES += $(KERNEL_DIR)/event_groups.c
SOURCE_FILES += $(KERNEL_DIR)/stream_buffer.c
SOURCE_FILES += $(KERNEL_DIR)/portable/MemMang/heap_4.c
SOURCE_FILES += $(KERNEL_DIR)/portable/GCC/ARM_CM3/port.c
#
# Application entry point. main_blinky is self contained. main_full builds
# the above common demo (and test) files too.
#
DEMO_PROJECT = .
VPATH += $(DEMO_PROJECT)
INCLUDE_DIRS += -I$(DEMO_PROJECT) -I$(DEMO_PROJECT)/CMSIS
SOURCE_FILES += (DEMO_PROJECT)/main.c
SOURCE_FILES += ./startup_gcc.c
SOURCE_FILES += ./IntTimer.c
# Lightweight print formatting to use in place of the heavier GCC equivalent.
SOURCE_FILES += ./printf-stdarg.c
#Create a list of object files with the desired output directory path.
OBJS_NO_PATH = $(notdir $(OBJS))
OBJS_OUTPUT = $(OBJS_NO_PATH:%.o=$(OUTPUT_DIR)/%.o)
#Create a list of dependency files with the desired output directory path.
DEP_FILES := $(SOURCE_FILES:%.c=$(OUTPUT_DIR)/%.d)
DEP_FILES_NO_PATH = $(notdir $(DEP_FILES))
DEP_OUTPUT = $(DEP_FILES_NO_PATH:%.d=$(OUTPUT_DIR)/%.d)
%.o : %.c
$(OUTPUT_DIR)/%.o : %.c $(OUTPUT_DIR)/%.d Makefile
$(IMAGE): ./mps2_m3.ld $(OBJS_OUTPUT) Makefile
@echo ""
@echo ""
@echo "--- Final linking ---"
@echo ""
$(LD) $(CFLAGS) $(LDFLAGS) $(OBJS_OUTPUT) -o $(IMAGE)
$(SIZE) $(IMAGE)
rm -f $(IMAGE) $(OUTPUT_DIR)/RTOSDemo.map $(OUTPUT_DIR)/*.o $(OUTPUT_DIR)/*.d
#use "make print-[VARIABLE_NAME] to print the value of a variable generated by
#this makefile.
print-% : ; @echo $* = $($*)
qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel output/RTOSDemo.out -monitor none -nographic -serial stdio
.PHONY: all clean