286 lines
7.8 KiB
Makefile
Raw Normal View History

2012-08-14 18:00:48 -04:00
##############################################################################
2018-10-25 11:13:01 -04:00
# Product: Makefile for QP/C++, Win32-GUI, GNU GCC
2018-11-22 11:34:13 -05:00
# Last updated for version 6.3.7
# Last updated on 2018-11-06
2012-08-14 18:00:48 -04:00
#
2018-10-25 11:13:01 -04:00
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
2012-08-14 18:00:48 -04:00
#
2018-10-25 11:13:01 -04:00
# Copyright (C) 2005-2018 Quantum Leaps, LLC. All rights reserved.
2012-08-14 18:00:48 -04:00
#
# 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
2012-08-14 18:00:48 -04:00
# (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 <http://www.gnu.org/licenses/>.
#
# Contact information:
2018-10-25 11:13:01 -04:00
# https://www.state-machine.com
2015-09-29 11:34:38 -04:00
# mailto:info@state-machine.com
2012-08-14 18:00:48 -04:00
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
# make CONF=spy
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
# make CONF=spy clean
2015-05-14 16:05:04 -04:00
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
2018-10-25 11:13:01 -04:00
# is included in the QTools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/QTools/
2015-05-14 16:05:04 -04:00
#
2015-06-06 18:30:55 -04:00
#-----------------------------------------------------------------------------
# project name
2013-12-30 17:41:15 -05:00
#
2018-10-25 11:13:01 -04:00
PROJECT := dpp-gui
2015-06-06 18:30:55 -04:00
#-----------------------------------------------------------------------------
2018-10-25 11:13:01 -04:00
# project directories:
2013-12-30 17:41:15 -05:00
#
2015-06-06 18:30:55 -04:00
# list of all source directories used by this project
2018-10-25 11:13:01 -04:00
VPATH := . \
2015-06-06 18:30:55 -04:00
..
# list of all include directories needed by this project
2018-10-25 11:13:01 -04:00
INCLUDES := -I. \
-I..
2015-06-06 18:30:55 -04:00
# list of resource include directories needed by this project
RCINCLUDES = \
-IRes
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
# location of the QP/C framework (if not provided in an env. variable)
ifeq ($(QPCPP),)
QPCPP := ../../../..
endif
2015-05-14 16:05:04 -04:00
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2018-10-25 11:13:01 -04:00
# project files:
2015-06-06 18:30:55 -04:00
#
# C source files...
2018-10-25 11:13:01 -04:00
C_SRCS := \
2015-06-06 18:30:55 -04:00
# C++ source files...
2018-10-25 11:13:01 -04:00
CPP_SRCS := \
2015-06-06 18:30:55 -04:00
bsp.cpp \
main.cpp \
philo.cpp \
table.cpp
# Resource files...
RC_SRCS := \
dpp-gui.rc
LIB_DIRS :=
LIBS :=
# defines...
# QP_API_VERSION controls the QP API compatibility; 9999 means the latest API
DEFINES := -DQP_API_VERSION=9999
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
ifeq (,$(CONF))
CONF := dbg
endif
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2018-10-25 11:13:01 -04:00
# add QP/C framework (depends on the OS this Makefile runs on):
2015-05-14 16:05:04 -04:00
#
2018-10-25 11:13:01 -04:00
ifeq ($(OS),Windows_NT)
2015-05-14 16:05:04 -04:00
# NOTE:
2018-10-25 11:13:01 -04:00
# For Windows hosts, you can choose:
# - the single-threaded QP/C port (win32-qv) or
# - the multithreaded QP/C port (win32).
#
QP_PORT_DIR := $(QPCPP)/ports/win32-qv
#QP_PORT_DIR := $(QPCPP)/ports/win32
LIB_DIRS += -L$(QP_PORT_DIR)/$(CONF)
LIBS += -lqp
else
$(error GUI build currently not supported on POSIX)
endif
#============================================================================
# Typically you should not need to change anything below this line
VPATH += $(QPCPP)/src/qf $(QP_PORT_DIR)
INCLUDES += -I$(QPCPP)/include -I$(QPCPP)/src -I$(QP_PORT_DIR)
#-----------------------------------------------------------------------------
# GNU toolset:
2015-05-14 16:05:04 -04:00
#
# NOTE:
2018-10-25 11:13:01 -04:00
# GNU toolset (MinGW) is included in the QTools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/QTools/
# It is assumed that %QTOOLS%\bin directory is added to the PATH
2012-08-14 18:00:48 -04:00
#
CC := gcc
CPP := g++
2015-05-14 16:05:04 -04:00
#LINK := gcc # for C programs
LINK := g++ # for C++ programs
2018-10-25 11:13:01 -04:00
# NOTE:
# This Makefile assumes that the windres utility is available on the PATH
# (windres is available in the QTools collection for Windows)
#
RC := windres
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
2018-10-25 11:13:01 -04:00
# basic utilities (depends on the OS this Makefile runs on):
2012-08-14 18:00:48 -04:00
#
2018-10-25 11:13:01 -04:00
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...
2012-08-14 18:00:48 -04:00
2015-05-14 16:05:04 -04:00
ifeq (rel, $(CONF)) # Release configuration ..................................
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
BIN_DIR := build_rel
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
CFLAGS = -c -ffunction-sections -fdata-sections \
-O1 -Wall -W $(INCLUDES) $(DEFINES) -DNDEBUG
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
CPPFLAGS = -c -ffunction-sections -fdata-sections \
-O1 -Wall -W $(INCLUDES) $(DEFINES) -DNDEBUG
2012-08-14 18:00:48 -04:00
else ifeq (spy, $(CONF)) # Spy configuration ................................
2018-10-25 11:13:01 -04:00
BIN_DIR := build_spy
2015-06-06 18:30:55 -04:00
2018-11-22 11:34:13 -05:00
LIBS += -lws2_32
2015-09-29 11:34:38 -04:00
2018-10-25 11:13:01 -04:00
CFLAGS = -c -g -ffunction-sections -fdata-sections \
2015-06-06 18:30:55 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES) -DQ_SPY
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
CPPFLAGS =-c -g -ffunction-sections -fdata-sections \
2015-06-06 18:30:55 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES) -DQ_SPY
2012-08-14 18:00:48 -04:00
2015-05-14 16:05:04 -04:00
else # default Debug configuration ..........................................
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
BIN_DIR := build
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
CFLAGS = -c -g -ffunction-sections -fdata-sections \
2015-06-06 18:30:55 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES)
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
CPPFLAGS = -c -g -ffunction-sections -fdata-sections \
2015-06-06 18:30:55 -04:00
-O -Wall -W $(INCLUDES) $(DEFINES)
2012-08-14 18:00:48 -04:00
2015-06-06 18:30:55 -04:00
endif # .....................................................................
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
LINKFLAGS :=
2012-08-14 18:00:48 -04:00
2015-06-06 18:30:55 -04:00
# is it a GUI application (any GUI resources provided?) ...
ifneq (,$(RC_SRCS))
LINKFLAGS += -mwindows
2016-05-05 12:22:15 -04:00
DEFINES += -DQWIN_GUI
2015-06-06 18:30:55 -04:00
endif
2012-08-15 13:55:24 -04:00
2015-05-14 16:05:04 -04:00
#-----------------------------------------------------------------------------
2018-10-25 11:13:01 -04:00
C_OBJS := $(patsubst %.c,%.o, $(C_SRCS))
CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS))
2015-05-14 16:05:04 -04:00
RC_OBJS := $(patsubst %.rc, %.o, $(RC_SRCS))
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
TARGET_EXE := $(BIN_DIR)/$(PROJECT)$(TARGET_EXT)
2012-08-14 18:00:48 -04:00
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
2018-10-25 11:13:01 -04:00
C_DEPS_EXT := $(patsubst %.o,%.d, $(C_OBJS_EXT))
2012-08-14 18:00:48 -04:00
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
2018-10-25 11:13:01 -04:00
CPP_DEPS_EXT := $(patsubst %.o,%.d, $(CPP_OBJS_EXT))
2012-08-14 18:00:48 -04:00
RC_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(RC_OBJS))
2015-05-14 16:05:04 -04:00
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
2012-08-14 18:00:48 -04:00
#-----------------------------------------------------------------------------
# rules
#
2015-05-14 16:05:04 -04:00
all: $(TARGET_EXE)
2012-08-14 18:00:48 -04:00
2015-06-06 18:30:55 -04:00
$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT)
2018-10-25 11:13:01 -04:00
$(CPP) $(CPPFLAGS) $(QPCPP)/include/qstamp.cpp -o $(BIN_DIR)/qstamp.o
2015-09-29 11:34:38 -04:00
$(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
2012-08-14 18:00:48 -04:00
2012-08-15 13:55:24 -04:00
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
2012-08-14 18:00:48 -04:00
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
2012-08-15 13:55:24 -04:00
$(BIN_DIR)/%.o : %.cpp
2018-10-25 11:13:01 -04:00
$(CPP) $(CPPFLAGS) $< -o $@
2012-08-15 13:55:24 -04:00
2012-08-14 18:00:48 -04:00
$(BIN_DIR)/%.o : %.c
2018-10-25 11:13:01 -04:00
$(CC) $(CFLAGS) $< -o $@
2012-08-14 18:00:48 -04:00
$(BIN_DIR)/%.o : %.rc
$(RC) $(RCINCLUDES) -i $< -o $@
2014-04-13 21:35:34 -04:00
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
2012-08-14 18:00:48 -04:00
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
2014-04-13 21:35:34 -04:00
endif
endif
2012-08-14 18:00:48 -04:00
2018-10-25 11:13:01 -04:00
.PHONY : clean show
clean :
2013-12-30 17:41:15 -05:00
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
2018-10-25 11:13:01 -04:00
$(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 RC_SRCS = $(RC_SRCS)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
2013-12-30 17:41:15 -05:00
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
2015-05-14 16:05:04 -04:00
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
2015-06-06 18:30:55 -04:00
@echo CPP_OBJS_EXT = $(CPP_OBJS_EXT)
2013-12-30 17:41:15 -05:00
@echo RC_OBJS_EXT = $(RC_OBJS_EXT)
2018-10-25 11:13:01 -04:00
@echo LIB_DIRS = $(LIB_DIRS)
@echo LIBS = $(LIBS)
@echo DEFINES = $(DEFINES)