############################################################################## # Product: Makefile for QUTEST; QP/C on POSIX *Target* # Last updated for version 6.8.2 # Last updated on 2020-06-23 # # Q u a n t u m L e a P s # ------------------------ # Modern Embedded Software # # Copyright (C) 2005-2020 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 . # # Contact information: # # ############################################################################## # # examples of invoking this Makefile: # make -f make_posix # make and run the tests in the current directory # make -f make_posix HOST=192.168.1.65:6601 # make and run the executable # make -f make_posix norun # only make but not run the tests # make -f make_posix clean # cleanup the build # #----------------------------------------------------------------------------- # project name: # PROJECT := test_qutest #----------------------------------------------------------------------------- # project directories: # # list of all source directories used by this project VPATH = . \ ../src # list of all include directories needed by this project INCLUDES = -I. \ -I../src # location of the QP/C framework (if not provided in an env. variable) ifeq ($(QPC),) QPC := ../../../.. endif ifeq ($(MAKECMDGOALS),test) # make sure that QTOOLS env. variable is defined... ifeq ("$(wildcard $(QTOOLS))","") $(error QTOOLS not found. Please install QTools and define QTOOLS env. variable) endif endif #----------------------------------------------------------------------------- # project files: # # C source files... C_SRCS := \ test_qutest.c # C++ source files... CPP_SRCS := LIB_DIRS := LIBS := # defines... # QP_API_VERSION controls the QP API compatibility; 9999 means the latest API DEFINES := -DQP_API_VERSION=9999 #----------------------------------------------------------------------------- # add QP/C framework: # # QP port used in this project QP_PORT_DIR := $(QPC)/ports/posix-qutest 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 \ qs.c \ qs_64bit.c \ qs_rx.c \ qs_fp.c \ qutest.c \ qutest_port.c LIBS += -lpthread #============================================================================ # Typically you should not need to change anything below this line VPATH += $(QPC)/src/qf $(QPC)/src/qs $(QP_PORT_DIR) INCLUDES += -I$(QPC)/include -I$(QPC)/src -I$(QP_PORT_DIR) #----------------------------------------------------------------------------- # GNU toolset: # CC := gcc CPP := g++ LINK := gcc # for C programs #LINK := g++ # for C++ programs #----------------------------------------------------------------------------- # basic utilities: MKDIR := mkdir -p RM := rm -f #----------------------------------------------------------------------------- # build options... BIN_DIR := build_$(TARGET CFLAGS = -c -g -O -Wall -Wstrict-prototypes -W $(INCLUDES) $(DEFINES) \ -DQ_SPY -DQ_UTEST -DQ_HOST CPPFLAGS = -c -g -O -Wall -W -fno-rtti -fno-exceptions $(INCLUDES) $(DEFINES) \ -DQ_SPY -DQ_UTEST -DQ_HOST ifndef GCC_OLD LINKFLAGS := -no-pie endif #----------------------------------------------------------------------------- C_OBJS := $(patsubst %.c,%.o, $(C_SRCS)) CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS)) TARGET_EXE := $(BIN_DIR)/$(PROJECT) 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 # .PHONY : norun test clean show ifeq ($(MAKECMDGOALS),norun) all : $(TARGET_EXE) norun : all else all : $(TARGET_EXE) run endif $(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(CC) $(CFLAGS) $(QPC)/include/qstamp.c -o $(BIN_DIR)/qstamp.o $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS) # run the test fixture on a POSIX target in a loop, so that it is re-started # after every test. The loop is terminated by pressing Ctrl-C on the keyboard. # run : $(TARGET_EXE) set -e; while true; do \ echo "restarting $(TARGET_EXE)"; \ $(TARGET_EXE) "" $(HOST); \ done $(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) $< -o $@ $(BIN_DIR)/%.o : %.c $(CC) $(CFLAGS) $< -o $@ # include dependency files only if our goal depends on their existence ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),show) ifneq ($(MAKECMDGOALS),test) -include $(C_DEPS_EXT) $(CPP_DEPS_EXT) endif endif endif clean : -$(RM) $(BIN_DIR)/*.o \ $(BIN_DIR)/*.d \ $(TARGET_EXE) show : @echo PROJECT = $(PROJECT) @echo TARGET_EXE = $(TARGET_EXE) @echo VPATH = $(VPATH) @echo C_SRCS = $(C_SRCS) @echo CPP_SRCS = $(CPP_SRCS) @echo C_DEPS_EXT = $(C_DEPS_EXT) @echo C_OBJS_EXT = $(C_OBJS_EXT) @echo C_DEPS_EXT = $(C_DEPS_EXT) @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) @echo LIB_DIRS = $(LIB_DIRS) @echo LIBS = $(LIBS) @echo DEFINES = $(DEFINES) @echo HOST = $(HOST)