Skip to content

Commit e731c20

Browse files
committed
7.3.5
1 parent 56512ee commit e731c20

File tree

4 files changed

+347
-3
lines changed

4 files changed

+347
-3
lines changed

posix-win32/dpp/Makefile_cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
##############################################################################
22
# Product: Makefile for QP/C for Windows and POSIX *HOSTS*
3-
# Last updated for version 7.3.4
4-
# Last updated on 2024-02-15
3+
# Last updated for version 7.3.5
4+
# Last updated on 2024-05-31
55
#
66
# Q u a n t u m L e a P s
77
# ------------------------
@@ -32,7 +32,7 @@
3232
# <info@state-machine.com>
3333
##############################################################################
3434
#
35-
# This Makefile demonstates how to build QP/C with C++ compiler
35+
# This Makefile demonstates how to build QP/C compiled as C++ code
3636
#
3737
# NOTE:
3838
# To use this Makefile on Windows, you will need the GNU make utility, which

posix-win32/dpp/Makefile_mixed

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
##############################################################################
2+
# Product: Makefile for QP/C for Windows and POSIX *HOSTS*
3+
# Last updated for version 7.3.5
4+
# Last updated on 2024-05-31
5+
#
6+
# Q u a n t u m L e a P s
7+
# ------------------------
8+
# Modern Embedded Software
9+
#
10+
# Copyright (C) 2005 Quantum Leaps, LLC, <state-machine.com>.
11+
#
12+
# This program is open source software: you can redistribute it and/or
13+
# modify it under the terms of the GNU General Public License as published
14+
# by the Free Software Foundation, either version 3 of the License, or
15+
# (at your option) any later version.
16+
#
17+
# Alternatively, this program may be distributed and modified under the
18+
# terms of Quantum Leaps commercial licenses, which expressly supersede
19+
# the GNU General Public License and are specifically designed for
20+
# licensees interested in retaining the proprietary status of their code.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <www.gnu.org/licenses/>.
29+
#
30+
# Contact information:
31+
# <www.state-machine.com/licensing>
32+
# <info@state-machine.com>
33+
##############################################################################
34+
#
35+
# This Makefile demonstates how to build QP/C compiled as C code, but mix it
36+
# with C++ code
37+
#
38+
# NOTE:
39+
# To use this Makefile on Windows, you will need the GNU make utility, which
40+
# is included in the QTools collection for Windows, see:
41+
# https://github.com/QuantumLeaps/qtools
42+
#
43+
44+
#-----------------------------------------------------------------------------
45+
# project name:
46+
#
47+
PROJECT := dpp
48+
49+
#-----------------------------------------------------------------------------
50+
# project directories:
51+
#
52+
53+
# list of all source directories used by this project
54+
VPATH := .
55+
56+
# list of all include directories needed by this project
57+
INCLUDES := -I.
58+
59+
# location of the QP/C framework (if not provided in an env. variable)
60+
ifeq ($(QPC),)
61+
QPC := ../../..
62+
endif
63+
64+
#-----------------------------------------------------------------------------
65+
# project files:
66+
#
67+
68+
# C source files...
69+
C_SRCS := \
70+
bsp.c \
71+
philo.c \
72+
table.c
73+
74+
# C++ source files...
75+
CPP_SRCS := \
76+
main.cpp
77+
78+
LIB_DIRS :=
79+
LIBS :=
80+
81+
# defines...
82+
# QP_CONFIG controls inclusion of the QP configuration file 'qp_config.h'
83+
DEFINES := -DQP_CONFIG \
84+
$(DEF)
85+
86+
ifeq (,$(CONF))
87+
CONF := dbg
88+
endif
89+
90+
#-----------------------------------------------------------------------------
91+
# add QP/C framework:
92+
#
93+
C_SRCS += \
94+
qep_hsm.c \
95+
qep_msm.c \
96+
qf_act.c \
97+
qf_actq.c \
98+
qf_defer.c \
99+
qf_dyn.c \
100+
qf_mem.c \
101+
qf_ps.c \
102+
qf_qact.c \
103+
qf_qeq.c \
104+
qf_qmact.c \
105+
qf_time.c \
106+
qf_port.c
107+
108+
QS_SRCS := \
109+
qs.c \
110+
qs_64bit.c \
111+
qs_rx.c \
112+
qs_fp.c \
113+
qs_port.c
114+
115+
ifeq ($(OS),Windows_NT)
116+
117+
# NOTE:
118+
# For Windows hosts, you can choose:
119+
# - the single-threaded QP/C port (win32-qv) or
120+
# - the multithreaded QP/C port (win32).
121+
#
122+
QP_PORT_DIR := $(QPC)/ports/win32-qv
123+
#QP_PORT_DIR := $(QPC)/ports/win32
124+
LIBS += -lws2_32
125+
126+
else
127+
128+
# NOTE:
129+
# For POSIX hosts (Linux, MacOS), you can choose:
130+
# - the single-threaded QP/C port (posix-qv) or
131+
# - the multithreaded QP/C port (posix).
132+
#
133+
QP_PORT_DIR := $(QPC)/ports/posix-qv
134+
#QP_PORT_DIR := $(QPC)/ports/posix
135+
136+
LIBS += -lpthread
137+
138+
endif
139+
140+
#=============================================================================
141+
# Typically you should not need to change anything below this line
142+
143+
VPATH += $(QPC)/src/qf $(QP_PORT_DIR)
144+
INCLUDES += -I$(QPC)/include -I$(QP_PORT_DIR)
145+
146+
#-----------------------------------------------------------------------------
147+
# GNU toolset:
148+
#
149+
# NOTE:
150+
# GNU toolset (MinGW) is included in the QTools collection for Windows, see:
151+
# https://github.com/QuantumLeaps/qtools
152+
# It is assumed that $(QTOOLS)/bin directory is added to the PATH
153+
#
154+
CC := gcc
155+
CPP := g++
156+
#LINK := gcc # for C programs
157+
LINK := g++ # for C++ programs
158+
159+
#-----------------------------------------------------------------------------
160+
# basic utilities (depends on the OS this Makefile runs on):
161+
#
162+
ifeq ($(OS),Windows_NT)
163+
MKDIR := mkdir
164+
RM := rm
165+
TARGET_EXT := .exe
166+
else ifeq ($(OSTYPE),cygwin)
167+
MKDIR := mkdir -p
168+
RM := rm -f
169+
TARGET_EXT := .exe
170+
else
171+
MKDIR := mkdir -p
172+
RM := rm -f
173+
TARGET_EXT :=
174+
endif
175+
176+
#-----------------------------------------------------------------------------
177+
# build configurations...
178+
179+
ifeq (rel, $(CONF)) # Release configuration ..................................
180+
181+
BIN_DIR := build_rel
182+
# gcc options:
183+
CFLAGS = -c -O3 -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
184+
$(INCLUDES) $(DEFINES) -DNDEBUG
185+
186+
CPPFLAGS = -c -O3 -fno-pie -std=c++11 -pedantic -Wall -Wextra \
187+
-fno-rtti -fno-exceptions \
188+
$(INCLUDES) $(DEFINES) -DNDEBUG
189+
190+
else ifeq (spy, $(CONF)) # Spy configuration ................................
191+
192+
BIN_DIR := build_spy
193+
194+
C_SRCS += $(QS_SRCS)
195+
VPATH += $(QPC)/src/qs
196+
197+
# gcc options:
198+
CFLAGS = -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
199+
$(INCLUDES) $(DEFINES) -DQ_SPY
200+
201+
CPPFLAGS = -c -g -O -fno-pie -std=c++11 -pedantic -Wall -Wextra \
202+
-fno-rtti -fno-exceptions \
203+
$(INCLUDES) $(DEFINES) -DQ_SPY
204+
205+
else # default Debug configuration .........................................
206+
207+
BIN_DIR := build
208+
209+
# gcc options:
210+
CFLAGS = -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
211+
$(INCLUDES) $(DEFINES)
212+
213+
CPPFLAGS = -c -g -O -fno-pie -std=c++11 -pedantic -Wall -Wextra \
214+
-fno-rtti -fno-exceptions \
215+
$(INCLUDES) $(DEFINES)
216+
217+
endif # .....................................................................
218+
219+
ifndef GCC_OLD
220+
LINKFLAGS := -no-pie
221+
endif
222+
223+
#-----------------------------------------------------------------------------
224+
C_OBJS := $(patsubst %.c,%.o, $(C_SRCS))
225+
CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS))
226+
227+
TARGET_EXE := $(BIN_DIR)/$(PROJECT)$(TARGET_EXT)
228+
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
229+
C_DEPS_EXT := $(patsubst %.o,%.d, $(C_OBJS_EXT))
230+
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
231+
CPP_DEPS_EXT := $(patsubst %.o,%.d, $(CPP_OBJS_EXT))
232+
233+
# create $(BIN_DIR) if it does not exist
234+
ifeq ("$(wildcard $(BIN_DIR))","")
235+
$(shell $(MKDIR) $(BIN_DIR))
236+
endif
237+
238+
#-----------------------------------------------------------------------------
239+
# rules
240+
#
241+
242+
.PHONY: clean show
243+
244+
all: $(TARGET_EXE)
245+
246+
$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT)
247+
$(CPP) $(CPPFLAGS) $(QPC)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
248+
$(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
249+
250+
$(BIN_DIR)/%.d : %.c
251+
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
252+
253+
$(BIN_DIR)/%.d : %.cpp
254+
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
255+
256+
$(BIN_DIR)/%.o : %.c
257+
$(CC) $(CFLAGS) $< -o $@
258+
259+
$(BIN_DIR)/%.o : %.cpp
260+
$(CPP) $(CPPFLAGS) $< -o $@
261+
262+
# create BIN_DIR and include dependencies only if needed
263+
ifneq ($(MAKECMDGOALS),clean)
264+
ifneq ($(MAKECMDGOALS),show)
265+
ifneq ($(MAKECMDGOALS),debug)
266+
ifeq ("$(wildcard $(BIN_DIR))","")
267+
$(shell $(MKDIR) $(BIN_DIR))
268+
endif
269+
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
270+
endif
271+
endif
272+
endif
273+
274+
clean :
275+
-$(RM) $(BIN_DIR)/*.o \
276+
$(BIN_DIR)/*.d \
277+
$(TARGET_EXE)
278+
279+
show :
280+
@echo PROJECT = $(PROJECT)
281+
@echo TARGET_EXE = $(TARGET_EXE)
282+
@echo VPATH = $(VPATH)
283+
@echo C_SRCS = $(C_SRCS)
284+
@echo CPP_SRCS = $(CPP_SRCS)
285+
@echo C_DEPS_EXT = $(C_DEPS_EXT)
286+
@echo C_OBJS_EXT = $(C_OBJS_EXT)
287+
@echo C_DEPS_EXT = $(C_DEPS_EXT)
288+
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
289+
@echo CPP_OBJS_EXT = $(CPP_OBJS_EXT)
290+
@echo LIB_DIRS = $(LIB_DIRS)
291+
@echo LIBS = $(LIBS)
292+
@echo DEFINES = $(DEFINES)
293+

posix-win32/dpp/Makefile_t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# <www.state-machine.com/licensing>
3232
# <info@state-machine.com>
3333
##############################################################################
34+
# This Makefile demonstates the multi-threaded QP/C port (qpc/ports/win32)
3435
#
3536
# examples of invoking this Makefile:
3637
# building configurations: Debug (default), Release, and Spy

posix-win32/dpp/main.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//============================================================================
2+
// APP example
3+
// Last updated for version 7.3.5
4+
// Last updated on 2024-05-31
5+
//
6+
// Q u a n t u m L e a P s
7+
// ------------------------
8+
// Modern Embedded Software
9+
//
10+
// Copyright (C) 2005 Quantum Leaps, LLC. <state-machine.com>
11+
//
12+
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
13+
//
14+
// This software is dual-licensed under the terms of the open source GNU
15+
// General Public License version 3 (or any later version), or alternatively,
16+
// under the terms of one of the closed source Quantum Leaps commercial
17+
// licenses.
18+
//
19+
// The terms of the open source GNU General Public License version 3
20+
// can be found at: <www.gnu.org/licenses/gpl-3.0>
21+
//
22+
// The terms of the closed source Quantum Leaps commercial licenses
23+
// can be found at: <www.state-machine.com/licensing>
24+
//
25+
// Redistributions in source code must retain this top-level comment block.
26+
// Plagiarizing this software to sidestep the license obligations is illegal.
27+
//
28+
// Contact information:
29+
// <www.state-machine.com/licensing>
30+
// <info@state-machine.com>
31+
//============================================================================
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
#include "qpc.h" // QP/C real-time embedded framework
37+
#include "dpp.h" // DPP Application interface
38+
#include "bsp.h" // Board Support Package
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif
43+
44+
//............................................................................
45+
int main(int argc, char *argv[]) {
46+
QF_init(); // initialize the framework
47+
BSP_init(argc, argv); // initialize the BSP
48+
BSP_start(); // start the AOs/Threads
49+
return QF_run(); // run the QF application
50+
}

0 commit comments

Comments
 (0)