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.
241 lines
6.4 KiB
Makefile
241 lines
6.4 KiB
Makefile
##############################################################################
|
|
# Product: Makefile for the EK-TM4C123GXL board and the GNU-ARM toolchain
|
|
# used in the video lessons "Modern Embedded Programming".
|
|
#
|
|
# Q u a n t u m L e a P s
|
|
# ------------------------
|
|
# Modern Embedded Software
|
|
#
|
|
# Copyright (C) 2018 Miro Samek. All rights reserved.
|
|
#
|
|
# Contact information:
|
|
# https://www.state-machine.com
|
|
# mailto:info@state-machine.com
|
|
##############################################################################
|
|
# examples of invoking this Makefile:
|
|
# building configurations: Debug (default), Release, and Spy
|
|
# make
|
|
# make CONF=rel
|
|
#
|
|
# cleaning configurations: Debug (default), Release, and Spy
|
|
# make clean
|
|
# make CONF=rel clean
|
|
#
|
|
# NOTE:
|
|
# To use this Makefile on Windows, you will need the GNU make utility, which
|
|
# is included in the Qtools collection for Windows, see:
|
|
# https://github.com/QuantumLeaps/qtools
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# project name
|
|
#
|
|
PROJECT := project
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# project directories
|
|
#
|
|
|
|
# location of the run-time environment (RTE)
|
|
ifeq ($(RTE),)
|
|
RTE := ..
|
|
endif
|
|
|
|
# list of all source directories used by this project
|
|
VPATH = \
|
|
. \
|
|
$(RTE)/ek-tm4c123gxl \
|
|
$(RTE)/ek-tm4c123gxl/gnu
|
|
|
|
# list of all include directories needed by this project
|
|
INCLUDES = \
|
|
-I. \
|
|
-I$(RTE)/CMSIS/Include \
|
|
-I$(RTE)/ek-tm4c123gxl
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# files
|
|
#
|
|
|
|
# assembler source files
|
|
ASM_SRCS :=
|
|
|
|
# C source files
|
|
C_SRCS := \
|
|
bsp.c \
|
|
miros.c \
|
|
main.c \
|
|
system_TM4C123GH6PM.c \
|
|
startup_TM4C123GH6PM.c
|
|
|
|
# C++ source files
|
|
CPP_SRCS :=
|
|
|
|
OUTPUT := $(PROJECT)
|
|
LD_SCRIPT := $(PROJECT).ld
|
|
|
|
LIB_DIRS :=
|
|
LIBS :=
|
|
|
|
# defines
|
|
DEFINES := -DTARGET_IS_TM4C123_RB1
|
|
|
|
# ARM CPU, ARCH, FPU, and Float-ABI types...
|
|
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
|
|
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
|
|
# ARM_FPU: [ | vfp]
|
|
# FLOAT_ABI: [ | soft | softfp | hard]
|
|
#
|
|
ARM_CPU := -mcpu=cortex-m4
|
|
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
|
|
ARM_FPU := -mfpu=vfp
|
|
FLOAT_ABI := -mfloat-abi=softfp
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
|
|
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
|
|
#
|
|
ifeq ($(GNU_ARM),)
|
|
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
|
|
endif
|
|
|
|
# make sure that the GNU-ARM toolset exists...
|
|
ifeq ("$(wildcard $(GNU_ARM))","")
|
|
$(error GNU_ARM toolset not found. Please adjust the Makefile)
|
|
endif
|
|
|
|
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
|
|
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
|
|
AS := $(GNU_ARM)/bin/arm-none-eabi-as
|
|
LINK := $(GNU_ARM)/bin/arm-none-eabi-gcc
|
|
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
|
|
|
|
|
|
##############################################################################
|
|
# Typically, you should not need to change anything below this line
|
|
|
|
# basic utilities (included in Qtools for Windows), see:
|
|
# http://sourceforge.net/projects/qpc/files/Qtools
|
|
|
|
MKDIR := mkdir
|
|
RM := rm
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# build options for various configurations for ARM Cortex-M4F
|
|
#
|
|
|
|
# combine all the soruces...
|
|
C_SRCS += $(QP_SRCS)
|
|
ASM_SRCS += $(QP_ASMS)
|
|
|
|
ifeq (rel, $(CONF)) # Release configuration ..................................
|
|
|
|
BIN_DIR := rel
|
|
|
|
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
|
|
|
|
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
|
|
-ffunction-sections -fdata-sections \
|
|
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
|
|
|
|
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
|
|
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
|
|
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
|
|
|
|
else # default Debug configuration ..........................................
|
|
|
|
BIN_DIR := dbg
|
|
|
|
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
|
|
|
|
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
|
|
-ffunction-sections -fdata-sections \
|
|
-O $(INCLUDES) $(DEFINES)
|
|
|
|
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
|
|
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
|
|
-O $(INCLUDES) $(DEFINES)
|
|
|
|
endif # ......................................................................
|
|
|
|
|
|
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
|
|
-specs=nosys.specs -specs=nano.specs \
|
|
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
|
|
|
|
|
|
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
|
|
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
|
|
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
|
|
|
|
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
|
|
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
|
|
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
|
|
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
|
|
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
|
|
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
|
|
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
|
|
|
|
# create $(BIN_DIR) if it does not exist
|
|
ifeq ("$(wildcard $(BIN_DIR))","")
|
|
$(shell $(MKDIR) $(BIN_DIR))
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# rules
|
|
#
|
|
|
|
all: $(TARGET_BIN)
|
|
#all: $(TARGET_ELF)
|
|
|
|
$(TARGET_BIN): $(TARGET_ELF)
|
|
$(BIN) -O binary $< $@
|
|
|
|
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
|
|
$(LINK) $(LINKFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
$(BIN_DIR)/%.d : %.c
|
|
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
|
|
|
|
$(BIN_DIR)/%.d : %.cpp
|
|
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
|
|
|
|
$(BIN_DIR)/%.o : %.s
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
$(BIN_DIR)/%.o : %.c
|
|
$(CC) $(CFLAGS) $< -o $@
|
|
|
|
$(BIN_DIR)/%.o : %.cpp
|
|
$(CPP) $(CPPFLAGS) $< -o $@
|
|
|
|
# include dependency files only if our goal depends on their existence
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
ifneq ($(MAKECMDGOALS),show)
|
|
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
|
|
endif
|
|
endif
|
|
|
|
|
|
.PHONY : clean
|
|
clean:
|
|
-$(RM) $(BIN_DIR)/*.o \
|
|
$(BIN_DIR)/*.d \
|
|
$(BIN_DIR)/*.bin \
|
|
$(BIN_DIR)/*.elf \
|
|
$(BIN_DIR)/*.map
|
|
|
|
show:
|
|
@echo PROJECT = $(PROJECT)
|
|
@echo CONF = $(CONF)
|
|
@echo DEFINES = $(DEFINES)
|
|
@echo ASM_FPU = $(ASM_FPU)
|
|
@echo ASM_SRCS = $(ASM_SRCS)
|
|
@echo C_SRCS = $(C_SRCS)
|
|
@echo CPP_SRCS = $(CPP_SRCS)
|
|
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
|
|
@echo C_OBJS_EXT = $(C_OBJS_EXT)
|
|
@echo C_DEPS_EXT = $(C_DEPS_EXT)
|
|
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
|
|
@echo TARGET_ELF = $(TARGET_ELF)
|