325 lines
8.6 KiB
Makefile
Raw Normal View History

2015-04-28 13:45:35 -04:00
##############################################################################
2015-12-24 14:33:20 -05:00
# Product: Makefile for DPP on NUCLEO-L053R8, QXK kernel, GNU-ARM
# Last Updated for Version: 5.6.0
# Date of the Last Update: 2015-12-10
2015-04-28 13:45:35 -04:00
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact information:
2015-09-04 12:08:22 -04:00
# http://www.state-machine.com
# mailto:info@state-machine.com
2015-04-28 13:45:35 -04:00
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
# make CONF=spy
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
# make CONF=spy 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:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
2015-12-24 14:33:20 -05:00
PROJECT := dpp-qxk
2015-04-28 13:45:35 -04:00
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP/C framework (if not provided in an environemnt var.)
ifeq ($(QPC),)
2015-12-24 14:33:20 -05:00
QPC := ../../../../..
2015-04-28 13:45:35 -04:00
endif
# QP port used in this project
2015-12-24 14:33:20 -05:00
QP_PORT_DIR := $(QPC)/ports/arm-cm/qxk/gnu
2015-04-28 13:45:35 -04:00
# list of all source directories used by this project
VPATH = \
.. \
2015-12-24 14:33:20 -05:00
../.. \
2015-04-28 13:45:35 -04:00
$(QPC)/source \
$(QP_PORT_DIR) \
$(QPC)/3rd_party/nucleo-l053r8 \
2015-05-14 15:45:53 -04:00
$(QPC)/3rd_party/nucleo-l053r8/gnu
2015-04-28 13:45:35 -04:00
# list of all include directories needed by this project
INCLUDES = \
2015-05-14 15:45:53 -04:00
-I../.. \
2015-04-28 13:45:35 -04:00
-I$(QPC)/include \
-I$(QPC)/source \
-I$(QP_PORT_DIR) \
-I$(QPC)/3rd_party/CMSIS/Include \
-I$(QPC)/3rd_party/nucleo-l053r8
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
2015-12-24 14:33:20 -05:00
test.c \
2015-04-28 13:45:35 -04:00
system_stm32l0xx.c \
startup_stm32l053xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qep_hsm.c \
qep_msm.c \
qf_act.c \
qf_actq.c \
qf_defer.c \
qf_dyn.c \
qf_mem.c \
qf_ps.c \
qf_qact.c \
qf_qeq.c \
qf_qmact.c \
2015-12-24 14:33:20 -05:00
qf_time.c \
qxk.c \
qxk_xthr.c \
qxk_sema.c \
qxk_mutex.c
2015-04-28 13:45:35 -04:00
2015-12-24 14:33:20 -05:00
QP_ASMS := \
qxk_port.s
2015-04-28 13:45:35 -04:00
QS_SRCS := \
qs.c \
2015-09-04 12:08:22 -04:00
qs_rx.c \
2015-04-28 13:45:35 -04:00
qs_fp.c
2015-12-24 14:33:20 -05:00
LIB_DIRS :=
LIBS :=
2015-04-28 13:45:35 -04:00
# defines
DEFINES :=
2015-12-24 14:33:20 -05:00
# 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]
#
2015-04-28 13:45:35 -04:00
ARM_CPU := -mcpu=cortex-m0plus
2015-12-24 14:33:20 -05:00
ARM_ARCH := 6 # NOTE: must match the ARM_CPU!
2015-04-28 13:45:35 -04:00
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see http://gnutoolchains.com/arm-eabi/
#
ifeq ($(GNU_ARM),)
GNU_ARM = C:/tools/gnu_arm-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-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-eabi-g++
AS := $(GNU_ARM)/bin/arm-eabi-as
LINK := $(GNU_ARM)/bin/arm-eabi-gcc
BIN := $(GNU_ARM)/bin/arm-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
#-----------------------------------------------------------------------------
2015-05-22 20:36:44 -04:00
# build options for various configurations for ARM Cortex-M4F
2015-04-28 13:45:35 -04:00
#
2015-05-22 20:36:44 -04:00
# combine all the soruces...
2015-12-24 14:33:20 -05:00
C_SRCS += $(QP_SRCS)
2015-04-28 13:45:35 -04:00
ASM_SRCS += $(QP_ASMS)
2015-12-24 14:33:20 -05:00
# add the pre-defined symbol for ARM architecture
DEFINES += -D__ARM_ARCH=$(ARM_ARCH)
ASM_CPU += -defsym=__ARM_ARCH=$(ARM_ARCH)
2015-05-22 20:36:44 -04:00
# add the pre-defined symbol __FPU_PRESENT if needed...
ifneq (,$(ARM_FPU))
DEFINES += -D__FPU_PRESENT
ASM_FPU += -defsym=__FPU_PRESENT=1
endif
2015-04-28 13:45:35 -04:00
2015-05-22 20:36:44 -04:00
ifeq (rel, $(CONF)) # Release configuration ..................................
2015-04-28 13:45:35 -04:00
BIN_DIR := rel
2015-12-24 14:33:20 -05:00
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
2015-04-28 13:45:35 -04:00
CFLAGS = $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
2015-05-22 20:36:44 -04:00
-ffunction-sections -fdata-sections \
2015-10-10 10:50:06 -04:00
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
2015-04-28 13:45:35 -04:00
2015-05-22 20:36:44 -04:00
CPPFLAGS = $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
2015-10-10 10:50:06 -04:00
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
2015-04-28 13:45:35 -04:00
else ifeq (spy, $(CONF)) # Spy configuration ................................
BIN_DIR := spy
C_SRCS += $(QS_SRCS)
2015-12-24 14:33:20 -05:00
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
2015-04-28 13:45:35 -04:00
CFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
2015-05-22 20:36:44 -04:00
-ffunction-sections -fdata-sections \
2015-04-28 13:45:35 -04:00
-O $(INCLUDES) $(DEFINES) -DQ_SPY
2015-05-22 20:36:44 -04:00
CPPFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES) -DQ_SPY
2015-04-28 13:45:35 -04:00
2015-05-22 20:36:44 -04:00
else # default Debug configuration ..........................................
2015-04-28 13:45:35 -04:00
BIN_DIR := dbg
2015-12-24 14:33:20 -05:00
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
2015-04-28 13:45:35 -04:00
CFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
2015-05-22 20:36:44 -04:00
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
2015-04-28 13:45:35 -04:00
2015-05-22 20:36:44 -04:00
CPPFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
2015-04-28 13:45:35 -04:00
-O $(INCLUDES) $(DEFINES)
2015-05-22 20:36:44 -04:00
endif # ......................................................................
2015-04-28 13:45:35 -04:00
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) \
-mthumb -nostdlib \
-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)
2015-09-04 12:08:22 -04:00
$(CC) $(CFLAGS) -c $(QPC)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
2015-04-28 13:45:35 -04:00
$(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) -c $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -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
2015-05-22 20:36:44 -04:00
2015-04-28 13:45:35 -04:00
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
2015-05-22 20:36:44 -04:00
@echo PROJECT = $(PROJECT)
2015-04-28 13:45:35 -04:00
@echo CONF = $(CONF)
2015-05-22 20:36:44 -04:00
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
2015-04-28 13:45:35 -04:00
@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)