qpcpp/examples/posix/dpp/Makefile

224 lines
6.2 KiB
Makefile
Raw Normal View History

2012-08-14 18:00:48 -04:00
##############################################################################
2016-06-10 21:51:18 -04:00
# Product: Makefile for QP/C++, DPP console, POSIX, GNU compiler
# Last updated for version 5.6.5
# Last updated on 2016-06-07
2012-08-14 18:00:48 -04:00
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
2015-05-14 16:05:04 -04:00
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
2012-08-14 18:00:48 -04:00
#
# 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
2012-08-14 18:00:48 -04:00
# (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:
2017-05-17 13:15:09 -04:00
# https://state-machine.com
2015-09-29 11:34:38 -04:00
# mailto:info@state-machine.com
2012-08-14 18:00:48 -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
2016-06-10 21:51:18 -04:00
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp
2015-05-14 16:05:04 -04:00
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2016-06-10 21:51:18 -04:00
# project directories
#
2015-05-14 16:05:04 -04:00
# location of the QP/C++ framework (if not provided in an environemnt var.)
ifeq ($(QPCPP),)
QPCPP := ../../..
2012-08-14 18:00:48 -04:00
endif
2016-06-10 21:51:18 -04:00
# QP port used in this project
QP_PORT_DIR := $(QPCPP)/ports/posix
# list of all source directories used by this project
VPATH = \
.
# list of all include directories needed by this project
INCLUDES = \
-I. \
-I$(QPCPP)/include
2015-05-14 16:05:04 -04:00
2012-08-14 18:00:48 -04:00
2015-05-14 16:05:04 -04:00
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2016-06-10 21:51:18 -04:00
# files
2012-08-14 18:00:48 -04:00
#
2016-06-10 21:51:18 -04:00
# C source files...
C_SRCS := \
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
# C++ source files...
CPP_SRCS := \
bsp.cpp \
main.cpp \
philo.cpp \
table.cpp
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
LIB_DIRS :=
LIBS :=
# defines...
# QP_API_VERSION controls the QP API compatibility; 9999 means the latest API
DEFINES := -DQP_API_VERSION=9999
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2016-06-10 21:51:18 -04:00
# GNU toolset
2012-08-14 18:00:48 -04:00
#
2016-06-10 21:51:18 -04:00
CC := gcc
CPP := g++
#LINK := gcc # for C programs
LINK := g++ # for C++ programs
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
MKDIR := mkdir -p
RM := rm -f
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
# build options for various configurations
#
2015-05-14 16:05:04 -04:00
ifeq (rel, $(CONF)) # Release configuration ..................................
2012-08-14 18:00:48 -04:00
BIN_DIR := rel
2016-06-10 21:51:18 -04:00
CFLAGS = -ffunction-sections -fdata-sections \
-Os -Wall -W $(INCLUDES) $(DEFINES) -pthread -DNDEBUG
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
CPPFLAGS = -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections \
-Os -Wall -W $(INCLUDES) $(DEFINES) -pthread -DNDEBUG
2012-08-14 18:00:48 -04:00
else ifeq (spy, $(CONF)) # Spy configuration ................................
2015-05-14 16:05:04 -04:00
# make sure that QTOOLS exists...
ifeq ("$(wildcard $(QTOOLS))","")
$(error QTOOLS not found. Please install Qtools and define QTOOLS env. variable)
endif
2013-12-30 17:41:15 -05:00
INCLUDES += -I$(QTOOLS)/qspy/include
VPATH += $(QTOOLS)/qspy/source
C_SRCS += qspy.c
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
BIN_DIR := spy
2015-05-14 16:05:04 -04:00
2016-06-10 21:51:18 -04:00
CFLAGS = -g -ffunction-sections -fdata-sections \
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread -DQ_SPY
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
CPPFLAGS = -g -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections \
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread -DQ_SPY
2012-08-14 18:00:48 -04:00
2015-05-14 16:05:04 -04:00
else # default Debug configuration ..........................................
2012-08-14 18:00:48 -04:00
BIN_DIR := dbg
2016-06-10 21:51:18 -04:00
CFLAGS = -g -ffunction-sections -fdata-sections \
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
CPPFLAGS = -g -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections \
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
endif # .....................................................................
2015-05-14 16:05:04 -04:00
2016-06-10 21:51:18 -04:00
LINKFLAGS := -Wl,-Map,$(BIN_DIR)/$(PROJECT).map,--cref,--gc-sections
2012-08-14 18:00:48 -04:00
2013-12-30 17:41:15 -05:00
#-----------------------------------------------------------------------------
2012-08-14 18:00:48 -04:00
2016-06-10 21:51:18 -04:00
# combine all the soruces...
INCLUDES += -I$(QP_PORT_DIR)
LIB_DIRS += -L$(QP_PORT_DIR)/$(BIN_DIR)
LIBS += -lpthread -lqp
2015-05-14 16:05:04 -04:00
C_OBJS := $(patsubst %.c, %.o, $(C_SRCS))
CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SRCS))
2013-12-30 17:41:15 -05:00
TARGET_BIN := $(BIN_DIR)/$(PROJECT).bin
TARGET_EXE := $(BIN_DIR)/$(PROJECT)
2012-08-14 18:00:48 -04:00
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
2015-05-14 16:05:04 -04:00
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
2012-08-14 18:00:48 -04:00
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
2015-05-14 16:05:04 -04:00
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
2012-08-14 18:00:48 -04:00
2015-05-14 16:05:04 -04:00
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
# rules
#
2015-05-14 16:05:04 -04:00
all: $(TARGET_EXE)
#all: $(TARGET_BIN)
2012-08-14 18:00:48 -04:00
$(TARGET_BIN): $(TARGET_EXE)
$(BIN) -O binary $< $@
2016-06-10 21:51:18 -04:00
$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT)
2015-09-29 11:34:38 -04:00
$(CPP) $(CPPFLAGS) -c $(QPCPP)/include/qstamp.cpp -o $(BIN_DIR)/qstamp.o
2016-06-10 21:51:18 -04:00
$(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
2012-08-14 18:00:48 -04:00
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
2013-12-30 17:41:15 -05:00
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
2012-08-14 18:00:48 -04:00
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
2013-12-30 17:41:15 -05:00
endif
endif
2012-08-14 18:00:48 -04:00
.PHONY : clean
clean:
2016-06-10 21:51:18 -04:00
-$(RM) $(BIN_DIR)/*
2012-08-14 18:00:48 -04:00
show:
2013-12-30 17:41:15 -05:00
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo VPATH = $(VPATH)
@echo C_SRCS = $(C_SRCS)
2012-08-14 18:00:48 -04:00
@echo CPP_SRCS = $(CPP_SRCS)
2013-12-30 17:41:15 -05:00
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
2016-06-10 21:51:18 -04:00
@echo CPP_OBJS_EXT = $(CPP_OBJS_EXT)
@echo LIB_DIRS = $(LIB_DIRS)
@echo LIBS = $(LIBS)