qpc/ports/posix/Makefile

215 lines
5.5 KiB
Makefile
Raw Normal View History

2012-08-14 18:07:04 -04:00
##############################################################################
2015-04-28 13:45:35 -04:00
# Product: Makefile for QP/C port to POSIX, GNU toolset
2017-05-27 10:41:37 -04:00
# Last Updated for Version: 5.9.1
# Date of the Last Update: 2017-05-25
2012-08-14 18:07:04 -04:00
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
2017-05-27 10:41:37 -04:00
# Copyright (C) 2005-2017 Quantum Leaps, LLC. All rights reserved.
2012-08-14 18:07:04 -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:07:04 -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:16:32 -04:00
# https://state-machine.com
2016-06-10 21:50:26 -04:00
# mailto:info@state-machine.com
2012-08-14 18:07:04 -04:00
##############################################################################
# examples of invoking this Makefile:
2017-05-27 10:41:37 -04:00
# building configurations: Debug (default), Release and Spy
2012-08-14 18:07:04 -04:00
# make
# make CONF=rel
# make CONF=spy
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
# make CONF=spy clean
2013-12-30 17:37:40 -05:00
#
2012-08-14 18:07:04 -04:00
#-----------------------------------------------------------------------------
2015-04-28 13:45:35 -04:00
# project name
2012-08-14 18:07:04 -04:00
#
2015-04-28 13:45:35 -04:00
PROJECT := qp
2012-08-14 18:07:04 -04:00
#-----------------------------------------------------------------------------
2015-04-28 13:45:35 -04:00
# project directories
2012-08-14 18:07:04 -04:00
#
2015-04-28 13:45:35 -04:00
# location of the QP/C framework
QPC := ../..
# QP port used in this project
QP_PORT_DIR := .
2013-12-30 17:37:40 -05:00
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
# list of all source directories used by this project
VPATH = \
2017-05-27 10:41:37 -04:00
$(QPC)/src/qf \
$(QPC)/src/qs \
2015-04-28 13:45:35 -04:00
$(QP_PORT_DIR)
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
# list of all include directories needed by this project
INCLUDES = \
2013-12-30 17:37:40 -05:00
-I$(QPC)/include \
2017-05-27 10:41:37 -04:00
-I$(QPC)/src \
2013-12-30 17:37:40 -05:00
-I$(QP_PORT_DIR)
2012-08-14 18:07:04 -04:00
#-----------------------------------------------------------------------------
# files
#
# C source files
2015-04-28 13:45:35 -04:00
C_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 \
qf_time.c \
qf_port.c
C_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 \
qs_64bit.c
2012-08-14 18:07:04 -04:00
# C++ source files
2015-04-28 13:45:35 -04:00
CPP_SRCS :=
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
# defines
DEFINES :=
2012-08-14 18:07:04 -04:00
#-----------------------------------------------------------------------------
2015-04-28 13:45:35 -04:00
# GNU toolset
2012-08-14 18:07:04 -04:00
#
2015-04-28 13:45:35 -04:00
CC := gcc
LIB := ar
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
##############################################################################
# Typically, you should not need to change anything below this line
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
MKDIR := mkdir -p
RM := rm -f
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
#-----------------------------------------------------------------------------
# build options for various configurations
#
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
LIBFLAGS := rs
2012-08-14 18:07:04 -04:00
2017-05-27 10:41:37 -04:00
ifeq (rel, $(CONF)) # Release configuration .................................
2012-08-14 18:07:04 -04:00
2015-09-04 12:08:22 -04:00
BIN_DIR := rel
2012-08-14 18:07:04 -04:00
2017-05-27 10:41:37 -04:00
CFLAGS = -c -ffunction-sections -fdata-sections \
2015-09-04 12:08:22 -04:00
-Os -Wall -W $(INCLUDES) $(DEFINES) -pthread -DNDEBUG
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
else ifeq (spy, $(CONF)) # Spy configuration ................................
2012-08-14 18:07:04 -04:00
2015-09-04 12:08:22 -04:00
BIN_DIR := spy
2012-08-14 18:07:04 -04:00
2017-05-27 10:41:37 -04:00
CFLAGS = -c -g -ffunction-sections -fdata-sections \
2015-09-04 12:08:22 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread -DQ_SPY
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
# add the QS sources...
C_SRCS += $(C_QS_SRCS)
2012-08-14 18:07:04 -04:00
2015-09-04 12:08:22 -04:00
else # default Debug configuration ..........................................
2012-08-14 18:07:04 -04:00
2015-09-04 12:08:22 -04:00
BIN_DIR := dbg
2012-08-14 18:07:04 -04:00
2017-05-27 10:41:37 -04:00
CFLAGS = -c -g -ffunction-sections -fdata-sections \
2015-09-04 12:08:22 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES) -pthread
2013-12-30 17:37:40 -05:00
2015-09-04 12:08:22 -04:00
endif # .....................................................................
2012-08-14 18:07:04 -04:00
2015-09-04 12:08:22 -04:00
C_OBJS := $(patsubst %.c, %.o, $(C_SRCS))
CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SRCS))
2015-04-28 13:45:35 -04:00
TARGET_LIB := $(BIN_DIR)/lib$(PROJECT).a
2012-08-14 18:07:04 -04:00
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))
2015-04-28 13:45:35 -04:00
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
2012-08-14 18:07:04 -04:00
#-----------------------------------------------------------------------------
# rules
#
2015-04-28 13:45:35 -04:00
all: $(TARGET_LIB)
-$(RM) $(BIN_DIR)/*.o $(BIN_DIR)/*.d
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
$(TARGET_LIB) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(LIB) $(LIBFLAGS) $@ $^
2012-08-14 18:07:04 -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 : %.c
2017-05-27 10:41:37 -04:00
$(CC) $(CFLAGS) $< -o $@
2012-08-14 18:07:04 -04:00
$(BIN_DIR)/%.o : %.cpp
2017-05-27 10:41:37 -04:00
$(CPP) $(CPPFLAGS) $< -o $@
2012-08-14 18:07:04 -04:00
2013-12-30 17:37:40 -05:00
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
2015-04-28 13:45:35 -04:00
ifneq ($(MAKECMDGOALS),show)
2012-08-14 18:07:04 -04:00
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
2015-04-28 13:45:35 -04:00
endif
2013-12-30 17:37:40 -05:00
endif
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
#-----------------------------------------------------------------------------
# the clean target
#
2012-08-14 18:07:04 -04:00
.PHONY : clean
clean:
2015-04-28 13:45:35 -04:00
-$(RM) $(BIN_DIR)/*.o $(BIN_DIR)/*.d $(TARGET_LIB)
2017-05-27 10:41:37 -04:00
2015-04-28 13:45:35 -04:00
#-----------------------------------------------------------------------------
# the show target for debugging
#
2012-08-14 18:07:04 -04:00
show:
2015-04-28 13:45:35 -04:00
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo TARGET_LIB = $(TARGET_LIB)
@echo C_SRCS = $(C_SRCS)
2012-08-14 18:07:04 -04:00
@echo CPP_SRCS = $(CPP_SRCS)
2015-04-28 13:45:35 -04:00
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
2015-09-04 12:08:22 -04:00
@echo CPP_OBJS_EXT = $(CPP_OBJS_EXT)
2012-08-14 18:07:04 -04:00
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)