@@ -51,11 +51,14 @@ VPATH := .
5151INCLUDES := -I.
5252
5353C_SRCS := \
54+ main.c \
55+ bsp.c \
5456 blinky.c
5557
5658DEFINES :=
5759
5860CPP_SRCS :=
61+
5962LIB_DIRS :=
6063LIBS :=
6164OUTPUT := $(PROJECT )
@@ -65,34 +68,34 @@ OUTPUT := $(PROJECT)
6568#
6669TARGET := host
6770
68- DEFINES : =
71+ DEFINES + =
6972
7073BIN_DIR := build_$(TARGET )
7174
7275# -----------------------------------------------------------------------------
7376# QP framework
7477#
7578
76- # location of the QP/C framework (if not provided in an env. variable)
77- ifeq ($(QP ) ,)
78- QP := ../../..
79+ # location of the QP framework (if not provided in an env. variable)
80+ ifeq ($(QPC ) ,)
81+ QPC := ../../..
7982endif
8083
8184ifeq ($(OS ) ,Windows_NT)
8285
8386ifdef QV
84- QP_PORT_DIR := $(QP ) /ports/win32-qv
87+ QP_PORT_DIR := $(QPC ) /ports/win32-qv
8588else
86- QP_PORT_DIR := $(QP ) /ports/win32
89+ QP_PORT_DIR := $(QPC ) /ports/win32
8790endif
8891LIBS += -lws2_32
8992
9093else
9194
9295ifdef QV
93- QP_PORT_DIR := $(QP ) /ports/posix-qv
96+ QP_PORT_DIR := $(QPC ) /ports/posix-qv
9497else
95- QP_PORT_DIR := $(QP ) /ports/posix
98+ QP_PORT_DIR := $(QPC ) /ports/posix
9699endif
97100LIBS += -lpthread
98101
@@ -102,11 +105,11 @@ VPATH += \
102105 $(QP_PORT_DIR )
103106
104107INCLUDES += \
105- -I$(QP ) /include \
108+ -I$(QPC ) /include \
106109 -I$(QP_PORT_DIR )
107110
108111# -----------------------------------------------------------------------------
109- # QP/C framework sources
112+ # QP framework sources
110113#
111114QP_SRCS := \
112115 qep_hsm.c \
@@ -131,52 +134,61 @@ QS_SRCS := \
131134 qs_port.c
132135
133136VPATH += \
134- $(QP ) /src/qf \
135- $(QP ) /src/qs $(QP_PORT_DIR )
137+ $(QPC ) /src/qf \
138+ $(QPC ) /src/qs \
139+ $(QP_PORT_DIR )
136140
137141INCLUDES += \
138- -I$(QP ) /include \
142+ -I$(QPC ) /include \
139143 -I$(QP_PORT_DIR )
140144
141145# add the QP sources to the build
142146C_SRCS += $(QP_SRCS )
143147
144148ifeq (spy, $(CONF ) ) # Spy configuration
145- VPATH += $(QP ) /src/qs
149+ VPATH += $(QPC ) /src/qs
146150C_SRCS += $(QS_SRCS )
147151endif
148152
149153# -----------------------------------------------------------------------------
150- # GNU toolset:
151- # NOTE: GNU toolset (MinGW) is included in the QTools collection for Windows, see:
152- # https://www.state-machine.com/qtools
154+ # GNU GCC toolset for the host:
155+ # NOTE: GNU toolset for Windows (MinGW) is included in the QTools collection
156+ # for Windows, see: https://www.state-machine.com/qtools
157+ #
153158# It is assumed that %QTOOLS%\bin directory is added to the PATH
154159#
155160CC := gcc
156161CPP := g++
157162LINK := gcc # for C programs
158163# LINK := g++ # for C++ programs
159- COV := gcov -f
160164
161165# -----------------------------------------------------------------------------
162166# basic utilities (included in QTools for Windows), see:
163167# https://www.state-machine.com/qtools
164168#
165169ifeq ($(OS ) ,Windows_NT)
170+ TARGET_EXT := .exe
166171 MKDIR := mkdir
167172 RM := rm
168- TARGET_EXT := .exe
173+ CAT := type
174+ COV := gcov -abcgum
175+ CODE_COV := --coverage -fcondition-coverage # NOTE: required gcc 14 or newer
169176else ifeq ($(OSTYPE),cygwin)
177+ TARGET_EXT := .exe
170178 MKDIR := mkdir -p
171179 RM := rm -f
172- TARGET_EXT := .exe
180+ CAT := cat
181+ COV := gcov -b
182+ CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
173183else
184+ TARGET_EXT :=
174185 MKDIR := mkdir -p
175186 RM := rm -f
176- TARGET_EXT :=
187+ CAT := cat
188+ COV := gcov -b
189+ CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
177190endif
178191
179-
180192# #############################################################################
181193# Typically you should not need to change anything below this line
182194
@@ -187,10 +199,12 @@ ifeq (rel, $(CONF)) # Release configuration ..................................
187199
188200BIN_DIR := build_rel
189201# gcc options:
190- CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
202+ CFLAGS := -c -fno-pie -std=c11 -pedantic \
203+ -Wall -Wextra -Wpedantic -Wsign-conversion \
191204 -O3 $(INCLUDES ) $(DEFINES ) $(DEF ) -DNDEBUG
192205
193- CPPFLAGS := -c -fno-pie -std=c++11 -pedantic -Wall -Wextra \
206+ CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
207+ -Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
194208 -fno-rtti -fno-exceptions \
195209 -O3 $(INCLUDES ) $(DEFINES ) $(DEF ) -DNDEBUG
196210
@@ -199,10 +213,12 @@ else ifeq (spy, $(CONF)) # Spy configuration ................................
199213BIN_DIR := build_spy
200214
201215# gcc options:
202- CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
216+ CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
217+ -Wall -Wextra -Wpedantic -Wsign-conversion \
203218 -O $(INCLUDES ) $(DEFINES ) $(DEF ) -DQ_SPY
204219
205- CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
220+ CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic \
221+ -Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
206222 -fno-rtti -fno-exceptions \
207223 -O $(INCLUDES ) $(DEFINES ) -DQ_SPY
208224
@@ -211,23 +227,25 @@ else # default Debug configuration .........................................
211227BIN_DIR := build
212228
213229# gcc options:
214- CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
230+ CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
231+ -Wall -Wextra -Wpedantic -Wsign-conversion \
215232 -O $(INCLUDES ) $(DEFINES ) $(DEF )
216233
217- CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
234+ CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic \
235+ -Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
218236 -fno-rtti -fno-exceptions \
219237 -O $(INCLUDES ) $(DEFINES ) $(DEF )
220238
221239endif # .....................................................................
222240
223- ifndef GCC_OLD
224- LINKFLAGS := -no-pie
241+ ifdef GCOV
242+ CFLAGS += $(CODE_COV)
243+ CPPFLAGS += $(CODE_COV)
244+ LINKFLAGS := $(CODE_COV)
225245endif
226246
227- ifdef GCOV
228- CFLAGS += -fprofile-arcs -ftest-coverage
229- CPPFLAGS += -fprofile-arcs -ftest-coverage
230- LINKFLAGS += -lgcov --coverage
247+ ifndef GCC_OLD
248+ LINKFLAGS += -no-pie
231249endif
232250
233251# -----------------------------------------------------------------------------
@@ -247,7 +265,6 @@ endif
247265
248266# -----------------------------------------------------------------------------
249267# rules
250- #
251268
252269.PHONY : clean show
253270
@@ -256,7 +273,7 @@ all: $(TARGET_EXE)
256273ifeq (spy, $(CONF ) )
257274
258275$(TARGET_EXE ) : $(C_OBJS_EXT ) $(CPP_OBJS_EXT )
259- $(CC ) $(CFLAGS ) $(QP ) /src/qs/qstamp.c -o $(BIN_DIR ) /qstamp.o
276+ $(CC ) $(CFLAGS ) $(QPC ) /src/qs/qstamp.c -o $(BIN_DIR ) /qstamp.o
260277 $(LINK ) $(LINKFLAGS ) $(LIB_DIRS ) -o $@ $^ $(BIN_DIR ) /qstamp.o $(LIBS )
261278
262279else
@@ -281,12 +298,12 @@ $(BIN_DIR)/%.o : %.cpp
281298# create BIN_DIR and include dependencies only if needed
282299ifneq ($(MAKECMDGOALS ) ,clean)
283300 ifneq ($(MAKECMDGOALS),show)
284- ifneq ($(MAKECMDGOALS),debug)
301+ ifneq ($(MAKECMDGOALS),debug)
285302ifeq ("$(wildcard $(BIN_DIR ) ) ","")
286303$(shell $(MKDIR) $(BIN_DIR))
287304endif
288305-include $(C_DEPS_EXT ) $(CPP_DEPS_EXT )
289- endif
306+ endif
290307 endif
291308endif
292309
0 commit comments