| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- ##############################################################################
- # Product: Makefile for QP/C for Windows and POSIX *HOSTS*
- # Last updated for version 7.2.0
- # Last updated on 2022-11-13
- #
- # Q u a n t u m L e a P s
- # ------------------------
- # Modern Embedded Software
- #
- # Copyright (C) 2005 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 <www.gnu.org/licenses/>.
- #
- # Contact information:
- # <www.state-machine.com/licensing>
- # <info@state-machine.com>
- ##############################################################################
- #
- # examples of invoking this Makefile:
- # building configurations: Debug (default), Release, and Spy
- # make
- # make CONF=rel
- # make CONF=spy
- # make clean # cleanup the build
- # make CONF=spy clean # cleanup the build
- #
- # NOTE:
- # To use this Makefile on Windows, you will need the GNU make utility, which
- # is included in the QTools collection for Windows, see:
- # http://sourceforge.net/projects/qpc/files/QTools/
- #
- #-----------------------------------------------------------------------------
- # project name:
- #
- PROJECT := comp
- #-----------------------------------------------------------------------------
- # project directories:
- #
- # list of all source directories used by this project
- VPATH := . \
- # list of all include directories needed by this project
- INCLUDES := -I. \
- # location of the QP/C framework (if not provided in an env. variable)
- ifeq ($(QPC),)
- QPC := ../../..
- endif
- #-----------------------------------------------------------------------------
- # project files:
- #
- # C source files...
- C_SRCS := \
- main.c \
- bsp.c \
- alarm.c \
- clock.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
- ifeq (,$(CONF))
- CONF := dbg
- endif
- #-----------------------------------------------------------------------------
- # add QP/C framework:
- #
- C_SRCS += \
- qep_hsm.c \
- qep_msm.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
- QS_SRCS := \
- qs.c \
- qs_64bit.c \
- qs_rx.c \
- qs_fp.c \
- qs_port.c
- ifeq ($(OS),Windows_NT)
- # NOTE:
- # For Windows hosts, you can choose:
- # - the single-threaded QP/C port (win32-qv) or
- # - the multithreaded QP/C port (win32).
- #
- QP_PORT_DIR := $(QPC)/ports/win32-qv
- #QP_PORT_DIR := $(QPC)/ports/win32
- LIBS += -lws2_32
- else
- # NOTE:
- # For POSIX hosts (Linux, MacOS), you can choose:
- # - the single-threaded QP/C port (win32-qv) or
- # - the multithreaded QP/C port (win32).
- #
- QP_PORT_DIR := $(QPC)/ports/posix-qv
- #QP_PORT_DIR := $(QPC)/ports/posix
- LIBS += -lpthread
- endif
- #============================================================================
- # Typically you should not need to change anything below this line
- VPATH += $(QPC)/src/qf $(QP_PORT_DIR)
- INCLUDES += -I$(QPC)/include -I$(QP_PORT_DIR)
- #-----------------------------------------------------------------------------
- # GNU toolset:
- #
- # NOTE:
- # GNU toolset (MinGW) is included in the QTools collection for Windows, see:
- # https://www.state-machine.com/qtools
- # It is assumed that %QTOOLS%\bin directory is added to the PATH
- #
- CC := gcc
- CPP := g++
- LINK := gcc # for C programs
- #LINK := g++ # for C++ programs
- #-----------------------------------------------------------------------------
- # basic utilities (depends on the OS this Makefile runs on):
- #
- ifeq ($(OS),Windows_NT)
- MKDIR := mkdir
- RM := rm
- TARGET_EXT := .exe
- else ifeq ($(OSTYPE),cygwin)
- MKDIR := mkdir -p
- RM := rm -f
- TARGET_EXT := .exe
- else
- MKDIR := mkdir -p
- RM := rm -f
- TARGET_EXT :=
- endif
- #-----------------------------------------------------------------------------
- # build configurations...
- ifeq (rel, $(CONF)) # Release configuration ..................................
- BIN_DIR := build_rel
- # gcc options:
- CFLAGS = -c -O3 -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
- $(INCLUDES) $(DEFINES) -DNDEBUG
- CPPFLAGS = -c -O3 -fno-pie -std=c++11 -pedantic -Wall -Wextra \
- -fno-rtti -fno-exceptions \
- $(INCLUDES) $(DEFINES) -DNDEBUG
- else ifeq (spy, $(CONF)) # Spy configuration ................................
- BIN_DIR := build_spy
- C_SRCS += $(QS_SRCS)
- VPATH += $(QPC)/src/qs
- # gcc options:
- CFLAGS = -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
- $(INCLUDES) $(DEFINES) -DQ_SPY
- CPPFLAGS = -c -g -O -fno-pie -std=c++11 -pedantic -Wall -Wextra \
- -fno-rtti -fno-exceptions \
- $(INCLUDES) $(DEFINES) -DQ_SPY
- else # default Debug configuration .........................................
- BIN_DIR := build
- # gcc options:
- CFLAGS = -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
- $(INCLUDES) $(DEFINES)
- CPPFLAGS = -c -g -O -fno-pie -std=c++11 -pedantic -Wall -Wextra \
- -fno-rtti -fno-exceptions \
- $(INCLUDES) $(DEFINES)
- endif # .....................................................................
- 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)$(TARGET_EXT)
- 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))
- #-----------------------------------------------------------------------------
- # rules
- #
- .PHONY: clean show
- all: $(TARGET_EXE)
- $(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT)
- $(CC) $(CFLAGS) $(QPC)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
- $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
- $(BIN_DIR)/%.d : %.c
- $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
- $(BIN_DIR)/%.d : %.cpp
- $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
- $(BIN_DIR)/%.o : %.c
- $(CC) $(CFLAGS) $< -o $@
- $(BIN_DIR)/%.o : %.cpp
- $(CPP) $(CPPFLAGS) $< -o $@
- # create BIN_DIR and include dependencies only if needed
- ifneq ($(MAKECMDGOALS),clean)
- ifneq ($(MAKECMDGOALS),show)
- ifneq ($(MAKECMDGOALS),debug)
- ifeq ("$(wildcard $(BIN_DIR))","")
- $(shell $(MKDIR) $(BIN_DIR))
- endif
- -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)
|