Skip to content

Commit 56a816c

Browse files
committed
8.1.2
1 parent 74edeb4 commit 56a816c

10 files changed

Lines changed: 194 additions & 152 deletions

File tree

posix-win32/dpp/Makefile

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ C_SRCS := \
5656
philo.c \
5757
table.c
5858

59-
DEFINES :=
60-
6159
CPP_SRCS :=
60+
6261
LIB_DIRS :=
6362
LIBS :=
6463
OUTPUT := $(PROJECT)
@@ -76,7 +75,7 @@ BIN_DIR := build_$(TARGET)
7675
# QP framework
7776
#
7877

79-
# location of the QP/C framework (if not provided in an env. variable)
78+
# location of the QP framework (if not provided in an env. variable)
8079
ifeq ($(QP),)
8180
QP := ../../..
8281
endif
@@ -135,7 +134,7 @@ QS_SRCS := \
135134

136135
VPATH += \
137136
$(QP)/src/qf \
138-
$(QP)/src/qs $(QP_PORT_DIR)
137+
$(QP_PORT_DIR)
139138

140139
INCLUDES += \
141140
-I$(QP)/include \
@@ -150,36 +149,43 @@ C_SRCS += $(QS_SRCS)
150149
endif
151150

152151
#-----------------------------------------------------------------------------
153-
# GNU toolset:
154-
# NOTE: GNU toolset (MinGW) is included in the QTools collection for Windows, see:
155-
# https://www.state-machine.com/qtools
152+
# GNU GCC toolset for the host:
153+
# NOTE: GNU toolset for Windows (MinGW) is included in the QTools collection
154+
# for Windows, see: https://www.state-machine.com/qtools
155+
#
156156
# It is assumed that %QTOOLS%\bin directory is added to the PATH
157157
#
158158
CC := gcc
159159
CPP := g++
160160
LINK := gcc # for C programs
161-
#LINK := g++ # for C++ programs
162-
COV := gcov -f
163161

164162
#-----------------------------------------------------------------------------
165163
# basic utilities (included in QTools for Windows), see:
166164
# https://www.state-machine.com/qtools
167165
#
168166
ifeq ($(OS),Windows_NT)
167+
TARGET_EXT := .exe
169168
MKDIR := mkdir
170169
RM := rm
171-
TARGET_EXT := .exe
170+
CAT := type
171+
COV := gcov -abcgum
172+
CODE_COV := --coverage -fcondition-coverage # NOTE: required gcc 14 or newer
172173
else ifeq ($(OSTYPE),cygwin)
174+
TARGET_EXT := .exe
173175
MKDIR := mkdir -p
174176
RM := rm -f
175-
TARGET_EXT := .exe
177+
CAT := cat
178+
COV := gcov -b
179+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
176180
else
181+
TARGET_EXT :=
177182
MKDIR := mkdir -p
178183
RM := rm -f
179-
TARGET_EXT :=
184+
CAT := cat
185+
COV := gcov -b
186+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
180187
endif
181188

182-
183189
##############################################################################
184190
# Typically you should not need to change anything below this line
185191

@@ -190,10 +196,12 @@ ifeq (rel, $(CONF)) # Release configuration ..................................
190196

191197
BIN_DIR := build_rel
192198
# gcc options:
193-
CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
199+
CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall \
200+
-Wall -Wextra -Wpedantic -Wsign-conversion \
194201
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
195202

196-
CPPFLAGS := -c -fno-pie -std=c++11 -pedantic -Wall -Wextra \
203+
CPPFLAGS := -c -fno-pie -std=c++17 -pedantic \
204+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
197205
-fno-rtti -fno-exceptions \
198206
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
199207

@@ -202,10 +210,12 @@ else ifeq (spy, $(CONF)) # Spy configuration ................................
202210
BIN_DIR := build_spy
203211

204212
# gcc options:
205-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
213+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
214+
-Wall -Wextra -Wpedantic -Wsign-conversion \
206215
-O $(INCLUDES) $(DEFINES) $(DEF) -DQ_SPY
207216

208-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
217+
CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
218+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
209219
-fno-rtti -fno-exceptions \
210220
-O $(INCLUDES) $(DEFINES) -DQ_SPY
211221

@@ -214,23 +224,25 @@ else # default Debug configuration .........................................
214224
BIN_DIR := build
215225

216226
# gcc options:
217-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
227+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
228+
-Wall -Wextra -Wpedantic -Wsign-conversion \
218229
-O $(INCLUDES) $(DEFINES) $(DEF)
219230

220-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
231+
CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
232+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
221233
-fno-rtti -fno-exceptions \
222234
-O $(INCLUDES) $(DEFINES) $(DEF)
223235

224236
endif # .....................................................................
225237

226-
ifndef GCC_OLD
227-
LINKFLAGS := -no-pie
238+
ifdef GCOV
239+
CFLAGS += $(CODE_COV)
240+
CPPFLAGS += $(CODE_COV)
241+
LINKFLAGS := $(CODE_COV)
228242
endif
229243

230-
ifdef GCOV
231-
CFLAGS += -fprofile-arcs -ftest-coverage
232-
CPPFLAGS += -fprofile-arcs -ftest-coverage
233-
LINKFLAGS += -lgcov --coverage
244+
ifndef GCC_OLD
245+
LINKFLAGS += -no-pie
234246
endif
235247

236248
#-----------------------------------------------------------------------------
@@ -250,7 +262,6 @@ endif
250262

251263
#-----------------------------------------------------------------------------
252264
# rules
253-
#
254265

255266
.PHONY: clean show
256267

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
# <info@state-machine.com>
2929
##############################################################################
3030
#
31-
# examples of invoking this Makefile:
32-
# building configurations: Debug (default), Release, and Spy
33-
# make
34-
# make CONF=rel
35-
# make CONF=spy
36-
# make clean # cleanup the build
37-
# make CONF=spy clean # cleanup the build
31+
# this makefile builds the project as follows:
32+
#
33+
# - QP/C source code compiled as C++17
34+
# - All other C source code compiled as C++17
35+
# - All other C++ code compiled as C++17
36+
# - Project linked as C++
3837
#
3938
# NOTE:
4039
# To use this Makefile on Windows, you will need the GNU make utility, which
@@ -56,9 +55,8 @@ C_SRCS := \
5655
philo.c \
5756
table.c
5857

59-
DEFINES :=
60-
6158
CPP_SRCS :=
59+
6260
LIB_DIRS :=
6361
LIBS :=
6462
OUTPUT := $(PROJECT)
@@ -76,37 +74,36 @@ BIN_DIR := build_$(TARGET)
7674
# QP framework
7775
#
7876

79-
# location of the QP/C framework (if not provided in an env. variable)
80-
ifeq ($(QPC),)
81-
QPC := ../../..
77+
# location of the QP framework (if not provided in an env. variable)
78+
ifeq ($(QP),)
79+
QP := ../../..
8280
endif
8381

8482
ifeq ($(OS),Windows_NT)
8583

8684
ifdef QV
87-
QP_PORT_DIR := $(QPC)/ports/win32-qv
85+
QP_PORT_DIR := $(QP)/ports/win32-qv
8886
else
89-
QP_PORT_DIR := $(QPC)/ports/win32
87+
QP_PORT_DIR := $(QP)/ports/win32
9088
endif
9189
LIBS += -lws2_32
9290

9391
else
9492

9593
ifdef QV
96-
QP_PORT_DIR := $(QPC)/ports/posix-qv
94+
QP_PORT_DIR := $(QP)/ports/posix-qv
9795
else
98-
QP_PORT_DIR := $(QPC)/ports/posix
96+
QP_PORT_DIR := $(QP)/ports/posix
9997
endif
10098
LIBS += -lpthread
10199

102100
endif
103101

104102
VPATH += \
105-
$(QPC)/src/qs \
106103
$(QP_PORT_DIR)
107104

108105
INCLUDES += \
109-
-I$(QPC)/include \
106+
-I$(QP)/include \
110107
-I$(QP_PORT_DIR)
111108

112109
#-----------------------------------------------------------------------------
@@ -135,52 +132,59 @@ QS_SRCS := \
135132
qs_port.c
136133

137134
VPATH += \
138-
$(QPC)/src/qf \
139-
$(QPC)/src/qs $(QP_PORT_DIR)
135+
$(QP)/src/qf \
136+
$(QP_PORT_DIR)
140137

141138
INCLUDES += \
142-
-I$(QPC)/include \
139+
-I$(QP)/include \
143140
-I$(QP_PORT_DIR)
144141

145142
# add the QP sources to the build
146143
C_SRCS += $(QP_SRCS)
147144

148145
ifeq (spy, $(CONF)) # Spy configuration
149-
VPATH += $(QPC)/src/qs
146+
VPATH += $(QP)/src/qs
150147
C_SRCS += $(QS_SRCS)
151148
endif
152149

153150
#-----------------------------------------------------------------------------
154-
# GNU toolset:
155-
# NOTE: GNU toolset (MinGW) is included in the QTools collection for Windows, see:
156-
# https://www.state-machine.com/qtools
151+
# GNU GCC toolset for the host:
152+
# NOTE: GNU toolset for Windows (MinGW) is included in the QTools collection
153+
# for Windows, see: https://www.state-machine.com/qtools
154+
#
157155
# It is assumed that %QTOOLS%\bin directory is added to the PATH
158156
#
159157
CC := gcc
160158
CPP := g++
161-
#LINK := gcc # for C programs
162159
LINK := g++ # for C++ programs
163-
COV := gcov -f
164160

165161
#-----------------------------------------------------------------------------
166162
# basic utilities (included in QTools for Windows), see:
167163
# https://www.state-machine.com/qtools
168164
#
169165
ifeq ($(OS),Windows_NT)
166+
TARGET_EXT := .exe
170167
MKDIR := mkdir
171168
RM := rm
172-
TARGET_EXT := .exe
169+
CAT := type
170+
COV := gcov -abcgum
171+
CODE_COV := --coverage -fcondition-coverage # NOTE: required gcc 14 or newer
173172
else ifeq ($(OSTYPE),cygwin)
173+
TARGET_EXT := .exe
174174
MKDIR := mkdir -p
175175
RM := rm -f
176-
TARGET_EXT := .exe
176+
CAT := cat
177+
COV := gcov -b
178+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
177179
else
180+
TARGET_EXT :=
178181
MKDIR := mkdir -p
179182
RM := rm -f
180-
TARGET_EXT :=
183+
CAT := cat
184+
COV := gcov -b
185+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
181186
endif
182187

183-
184188
##############################################################################
185189
# Typically you should not need to change anything below this line
186190

@@ -191,10 +195,12 @@ ifeq (rel, $(CONF)) # Release configuration ..................................
191195

192196
BIN_DIR := build_rel
193197
# gcc options:
194-
CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
198+
CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall \
199+
-Wall -Wextra -Wpedantic -Wsign-conversion \
195200
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
196201

197-
CPPFLAGS := -c -fno-pie -std=c++11 -pedantic -Wall -Wextra \
202+
CPPFLAGS := -c -fno-pie -std=c++17 -pedantic \
203+
-Wall -Wextra -Wpedantic -Wsign-conversion \
198204
-fno-rtti -fno-exceptions \
199205
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
200206

@@ -203,10 +209,12 @@ else ifeq (spy, $(CONF)) # Spy configuration ................................
203209
BIN_DIR := build_spy
204210

205211
# gcc options:
206-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
212+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
213+
-Wall -Wextra -Wpedantic -Wsign-conversion \
207214
-O $(INCLUDES) $(DEFINES) $(DEF) -DQ_SPY
208215

209-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
216+
CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
217+
-Wall -Wextra -Wpedantic -Wsign-conversion \
210218
-fno-rtti -fno-exceptions \
211219
-O $(INCLUDES) $(DEFINES) -DQ_SPY
212220

@@ -215,23 +223,25 @@ else # default Debug configuration .........................................
215223
BIN_DIR := build
216224

217225
# gcc options:
218-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
226+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
227+
-Wall -Wextra -Wpedantic -Wsign-conversion \
219228
-O $(INCLUDES) $(DEFINES) $(DEF)
220229

221-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
230+
CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
231+
-Wall -Wextra -Wpedantic -Wsign-conversion \
222232
-fno-rtti -fno-exceptions \
223233
-O $(INCLUDES) $(DEFINES) $(DEF)
224234

225235
endif # .....................................................................
226236

227-
ifndef GCC_OLD
228-
LINKFLAGS := -no-pie
237+
ifdef GCOV
238+
CFLAGS += $(CODE_COV)
239+
CPPFLAGS += $(CODE_COV)
240+
LINKFLAGS := $(CODE_COV)
229241
endif
230242

231-
ifdef GCOV
232-
CFLAGS += -fprofile-arcs -ftest-coverage
233-
CPPFLAGS += -fprofile-arcs -ftest-coverage
234-
LINKFLAGS += -lgcov --coverage
243+
ifndef GCC_OLD
244+
LINKFLAGS += -no-pie
235245
endif
236246

237247
#-----------------------------------------------------------------------------
@@ -251,7 +261,6 @@ endif
251261

252262
#-----------------------------------------------------------------------------
253263
# rules
254-
#
255264

256265
.PHONY: clean show
257266

@@ -260,7 +269,7 @@ all: $(TARGET_EXE)
260269
ifeq (spy, $(CONF))
261270

262271
$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT)
263-
$(CPP) $(CPPFLAGS) $(QPC)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
272+
$(CPP) $(CPPFLAGS) $(QP)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
264273
$(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
265274

266275
else

0 commit comments

Comments
 (0)