Quantum Leaps 16708447b9 5.4.0
2015-05-14 16:05:04 -04:00

306 lines
8.2 KiB
Makefile

##############################################################################
# Product: Makefile for QP/C++, DPP on mbed-LPC1768, QV kernel, GNU-ARM
# Last Updated for Version: 5.4.0
# Date of the Last Update: 2015-04-03
#
# 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:
# Web: http://www.state-machine.com
# Email: info@state-machine.com
##############################################################################
# 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
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP/C++ framework (if not provided in an environemnt var.)
ifeq ($(QPCPP),)
QPCPP := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPCPP)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPCPP)/source \
$(QP_PORT_DIR) \
$(QPCPP)/3rd_party/mbed-lpc1768 \
$(QPCPP)/3rd_party/mbed-lpc1768/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPCPP)/include \
-I$(QPCPP)/source \
-I$(QP_PORT_DIR) \
-I$(QPCPP)/3rd_party/CMSIS/Include \
-I$(QPCPP)/3rd_party/mbed-lpc1768
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
system_LPC17xx.c \
startup_LPC17xx.c
# C++ source files
CPP_SRCS := \
bsp.cpp \
main.cpp \
philo.cpp \
table.cpp
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qep_hsm.cpp \
qep_msm.cpp \
qf_act.cpp \
qf_actq.cpp \
qf_defer.cpp \
qf_dyn.cpp \
qf_mem.cpp \
qf_ps.cpp \
qf_qact.cpp \
qf_qeq.cpp \
qf_qmact.cpp \
qf_time.cpp \
qv.cpp
QP_ASMS :=
QS_SRCS := \
qs.cpp \
qs_fp.cpp
LIB_DIRS :=
LIBS :=
# combine all the necessary soruces
#
VPATH += $(QPCPP)/3rd_party/gnu_cpp
CPP_SRCS += $(QP_SRCS) mini_cpp.cpp
ASM_SRCS += $(QP_ASMS)
# defines
DEFINES :=
# ARM CPU, FPU, and Float-ABI types
ARM_CPU := -mcpu=cortex-m3
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-g++
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
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M4F
#
ifeq (rel, $(CONF)) # Release configuration ............................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) -defsym=FPU_VFP_V4_SP_D16=1
CFLAGS = $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -Os $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-ffunction-sections -fdata-sections -Wall -fno-rtti -fno-exceptions \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) \
-mthumb -nostdlib \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
else ifeq (spy, $(CONF)) # Spy configuration ................................
BIN_DIR := spy
CPP_SRCS += $(QS_SRCS)
ASFLAGS = -g $(ARM_CPU) -defsym=FPU_VFP_V4_SP_D16=1
CFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -O $(INCLUDES) $(DEFINES) -DQ_SPY
CPPFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-ffunction-sections -fdata-sections -Wall -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES) -DQ_SPY
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) \
-mthumb -nostdlib \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
else # default Debug configuration .......................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) -defsym=FPU_VFP_V4_SP_D16=1
CFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -O $(INCLUDES) $(DEFINES)
CPPFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-ffunction-sections -fdata-sections -Wall -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) \
-mthumb -nostdlib \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
endif
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) -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
.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 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)