2019-03-22 23:35:00 +08:00
|
|
|
# ******************************************************************************
|
|
|
|
# config.mk make-it-quick project
|
|
|
|
# ******************************************************************************
|
2017-03-25 06:57:50 +08:00
|
|
|
#
|
2019-03-22 23:35:00 +08:00
|
|
|
# File description:
|
2017-03-25 06:57:50 +08:00
|
|
|
#
|
2018-04-03 22:44:24 +08:00
|
|
|
# This is the shared makefile configuration file Make-It-Quick
|
2017-03-25 06:57:50 +08:00
|
|
|
# This where the location of specific directories should be specified
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2019-03-22 23:35:00 +08:00
|
|
|
# ******************************************************************************
|
|
|
|
# This software is licensed under the GNU General Public License v3
|
|
|
|
# (C) 2017-2019, Christophe de Dinechin <christophe@dinechin.org>
|
|
|
|
# ******************************************************************************
|
|
|
|
# This file is part of make-it-quick
|
2019-03-16 01:54:07 +08:00
|
|
|
#
|
2019-03-22 23:35:00 +08:00
|
|
|
# make-it-quick is free software: you can r 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.
|
2019-03-16 01:54:07 +08:00
|
|
|
#
|
2019-03-22 23:35:00 +08:00
|
|
|
# make-it-quick 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.
|
2019-03-16 01:54:07 +08:00
|
|
|
#
|
2019-03-22 23:35:00 +08:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with make-it-quick, in a file named COPYING.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
# ******************************************************************************
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
# Use /bin/sh as a basic shell, since it is faster than bash
|
|
|
|
# even when it's actually bash underneath, at least
|
|
|
|
# according to http://www.oreilly.com/openbook/make3/book/ch10.pdf
|
|
|
|
SHELL= /bin/bash
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Default build target and options (can be overriden with env variables)
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Default target
|
2018-04-05 23:25:12 +08:00
|
|
|
TARGET?=opt
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2017-04-15 20:28:32 +08:00
|
|
|
# Default build environment if not set
|
|
|
|
BUILDENV?=auto
|
|
|
|
|
2017-11-27 23:38:31 +08:00
|
|
|
# Default top level directory
|
|
|
|
TOP?=$(abspath .)/
|
|
|
|
|
2017-11-28 00:17:59 +08:00
|
|
|
# Default output for build products
|
2018-04-05 23:25:12 +08:00
|
|
|
OUTPUT?=$(TOP)
|
2017-11-28 00:17:59 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
# Default location for object files
|
2020-09-02 04:11:55 +08:00
|
|
|
BUILD?= $(TOP).build/
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
# Default location for build logs
|
2017-11-28 00:17:59 +08:00
|
|
|
LOGS?=$(TOP).logs/
|
2017-11-20 19:41:22 +08:00
|
|
|
LAST_LOG?=$(LOGS)make.log
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
# Stuff to clean
|
2017-11-28 18:16:36 +08:00
|
|
|
TO_CLEAN= *~ *.bak
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2021-02-12 14:41:44 +08:00
|
|
|
# Kinds of installable stuff
|
|
|
|
INSTALLABLE= exe \
|
|
|
|
lib \
|
|
|
|
dll \
|
|
|
|
header \
|
|
|
|
share \
|
|
|
|
license \
|
|
|
|
man \
|
|
|
|
doc \
|
|
|
|
var \
|
|
|
|
etc \
|
|
|
|
config \
|
|
|
|
sysconfig \
|
|
|
|
pkgconfig
|
|
|
|
|
|
|
|
# Stuff to install, with one of the suffixes above
|
|
|
|
WARE.exe?= $(MIQ_OUTEXE)
|
|
|
|
WARE.lib?= $(MIQ_OUTLIB)
|
|
|
|
WARE.dll?= $(MIQ_OUTDLL)
|
|
|
|
WARE.man?= $(MANPAGES)
|
|
|
|
WARE.header?= $(HEADERS)
|
|
|
|
WARE.doc?= $(wildcard README*)
|
|
|
|
WARE.license?= $(wildcard COPYING* LICENSE*)
|
|
|
|
WARE.pkgconfig?=$(PACKAGE_NAME:%=%.pc)
|
|
|
|
|
|
|
|
# Where we pick up the stuff to install (default is source)
|
|
|
|
WARE_DIR.pkgconfig?=$(MIQ_OBJDIR)
|
|
|
|
|
|
|
|
# Where to put system configuration files
|
|
|
|
SYSCONFIG?=$(PREFIX.etc)
|
2018-04-05 23:25:12 +08:00
|
|
|
|
|
|
|
# Buildenv for recursive builds
|
|
|
|
RECURSE_BUILDENV=$(BUILDENV)
|
|
|
|
|
|
|
|
# How to avoid parallel builds by default
|
|
|
|
NOT_PARALLEL?= .NOTPARALLEL
|
|
|
|
|
|
|
|
# Git revision for the current code
|
|
|
|
GIT_REVISION:= $(shell git rev-parse --short HEAD 2> /dev/null || echo "unknown")
|
|
|
|
|
2019-03-09 02:11:09 +08:00
|
|
|
# System configuration if installed
|
|
|
|
-include $(MIQ)config.system-setup.mk
|
|
|
|
|
2018-09-20 23:18:29 +08:00
|
|
|
# Local configuration if any
|
|
|
|
-include $(MIQ)config.local-setup.mk
|
|
|
|
|
2018-09-20 00:52:54 +08:00
|
|
|
# Extract defaults for package name and version if not set
|
|
|
|
PACKAGE_NAME?=$(firstword $(PRODUCTS) $(notdir $(shell pwd)))
|
2018-09-20 23:18:29 +08:00
|
|
|
PACKAGE_VERSION?=$(shell (git describe --always --match 'v[0-9].*' 2> /dev/null | sed -e 's/^v//') || echo unknown)
|
2018-05-26 17:17:39 +08:00
|
|
|
|
2019-03-09 21:15:25 +08:00
|
|
|
# Use package version for products version if not set
|
|
|
|
PRODUCTS_VERSION?=$(PACKAGE_VERSION)
|
|
|
|
|
2019-03-07 00:01:12 +08:00
|
|
|
# Package installation directory intermediate variables
|
2018-04-11 04:15:28 +08:00
|
|
|
PACKAGE_DIR?=$(PACKAGE_NAME:%=%/)
|
2018-04-06 05:47:28 +08:00
|
|
|
PACKAGE_LIBS=$(MIQ_PRODLIB)
|
|
|
|
PACKAGE_DLLS=$(MIQ_PRODDLL)
|
2017-11-28 19:50:32 +08:00
|
|
|
|
2021-02-23 18:11:53 +08:00
|
|
|
# Install headers, docs and var items in package subdirectory by default
|
|
|
|
PACKAGE_DIR.header?=$(PACKAGE_DIR)
|
|
|
|
PACKAGE_DIR.share?=$(PACKAGE_DIR)
|
|
|
|
PACKAGE_DIR.doc?=$(PACKAGE_DIR)
|
|
|
|
PACKAGE_DIR.license?=$(PACKAGE_DIR)
|
|
|
|
PACKAGE_DIR.config?=$(PACKAGE_DIR)
|
|
|
|
PACKAGE_DIR.var?=$(PACKAGE_DIR)
|
|
|
|
|
2018-09-20 23:18:29 +08:00
|
|
|
# Location of configuration files, etc (tweaked at install time)
|
2018-04-13 21:17:08 +08:00
|
|
|
CONFIG_SOURCES?=$(MIQ)config/
|
2018-04-04 01:10:42 +08:00
|
|
|
|
2018-02-15 17:51:15 +08:00
|
|
|
# Sources to reformat
|
2021-02-12 14:41:44 +08:00
|
|
|
CLANG_FORMAT_SOURCES=$(SOURCES) $(WARE.header)
|
2018-02-15 17:51:15 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Installation paths
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2019-03-07 00:01:12 +08:00
|
|
|
# Variables typically provided by configure scripts
|
|
|
|
PREFIX?=/usr/local/
|
2020-12-19 03:51:12 +08:00
|
|
|
PREFIX.bin?=$(PREFIX)bin/
|
|
|
|
PREFIX.sbin?=$(PREFIX)sbin/
|
|
|
|
PREFIX.libexec?=$(PREFIX)libexec/
|
2021-02-12 14:41:44 +08:00
|
|
|
PREFIX.exe?=$(PREFIX.bin)
|
|
|
|
PREFIX.lib?=$(PREFIX)lib/
|
2020-12-19 03:51:12 +08:00
|
|
|
PREFIX.dll?=$(PREFIX.lib)
|
2021-02-12 14:41:44 +08:00
|
|
|
PREFIX.header?=$(PREFIX)include/
|
2020-12-19 03:51:12 +08:00
|
|
|
PREFIX.share?=$(PREFIX)share/
|
|
|
|
PREFIX.man?=$(PREFIX.share)man/
|
|
|
|
PREFIX.doc?=$(PREFIX.share)doc/
|
2021-02-12 14:41:44 +08:00
|
|
|
PREFIX.license?=$(PREFIX.doc)
|
|
|
|
PREFIX.config?=$(PREFIX.share)config/
|
2020-12-19 03:51:12 +08:00
|
|
|
PREFIX.var?=$(PREFIX)var/
|
2021-02-12 14:41:44 +08:00
|
|
|
PREFIX.etc?=/etc/
|
|
|
|
PREFIX.sysconfig=$(SYSCONFIG)
|
|
|
|
PREFIX.pkgconfig=$(PREFIX.share)pkgconfig/
|
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2019-03-07 00:01:12 +08:00
|
|
|
# Package configuration directories by default
|
|
|
|
# The defaut is to install binaries and shared libraries in the prefix
|
|
|
|
# but to install headers and data items under a directory named after project
|
2021-02-12 14:41:44 +08:00
|
|
|
define package-install
|
|
|
|
|
2021-02-23 18:11:53 +08:00
|
|
|
PACKAGE_INSTALL.$1?=$$(DESTDIR)$$(PREFIX.$1)$$(PACKAGE_DIR.$1)
|
2021-02-12 14:41:44 +08:00
|
|
|
|
|
|
|
endef
|
|
|
|
$(eval $(foreach i,$(INSTALLABLE),$(call package-install,$i)))
|
2019-03-11 15:21:52 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2021-02-23 18:11:53 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compilation flags
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-06-19 16:41:25 +08:00
|
|
|
# Standard specification (use GCC standard names)
|
|
|
|
# For a compiler that is not GCC compatible, please state options corresponding
|
|
|
|
# to the relevant GNU option names as follows:
|
|
|
|
# CCFLAGS_STD=$(CC_FLAGS_STD_$(CC_STD))
|
|
|
|
# CCFLAGS_STD_gnu11=[whatever option is needed here]
|
2017-11-09 00:06:52 +08:00
|
|
|
CC_STD ?=gnu11
|
|
|
|
CXX_STD ?=gnu++11
|
2017-06-19 16:41:25 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
# Compilation flags
|
2018-04-05 23:25:12 +08:00
|
|
|
DEFINES_TARGET_debug= DEBUG
|
|
|
|
DEFINES_TARGET_opt= DEBUG OPTIMIZED
|
|
|
|
DEFINES_TARGET_release= NDEBUG OPTIMIZED RELEASE
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
# Default for C++ flags is to use CFLAGS
|
2018-04-05 23:25:12 +08:00
|
|
|
CXXFLAGS_TARGET_debug= $(CFLAGS_TARGET_debug)
|
|
|
|
CXXFLAGS_TARGET_opt= $(CFLAGS_TARGET_opt)
|
|
|
|
CXXFLAGS_TARGET_release= $(CFLAGS_TARGET_release)
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Toools we use
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ECHO= /bin/echo
|
|
|
|
TIME= time
|
2019-03-11 15:21:52 +08:00
|
|
|
MKDIR= mkdir
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# OS name for a given build environment
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2018-04-05 23:25:12 +08:00
|
|
|
OS_NAME= $(OS_NAME_BUILDENV_$(BUILDENV))
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Warning extraction (combines outputs from multiple compiler "races")
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# GCC and clang write something like: "warning: GCC keeps it simple"
|
|
|
|
# Visual Studio writes something like: "warning C2013: Don't use Visual Studio"
|
|
|
|
|
|
|
|
WARNING_MSG= '[Ww]arning\( \?\[\?[A-Za-z]\+[0-9]\+\]\?\)\?:'
|
|
|
|
ERROR_MSG= '[Ee]rror\( \?\[\?[A-Za-z]\+[0-9]\+\]\?\)\?:'
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Colorization
|
|
|
|
#------------------------------------------------------------------------------
|
2021-02-11 05:53:36 +08:00
|
|
|
# These use ANSI code, but they work on Mac, Windows, Linux, BSD and VMS,
|
|
|
|
# which is good enough for most use cases.
|
2017-03-25 06:57:50 +08:00
|
|
|
# Change them if you want to work from an hpterm on HP-UX ;-)
|
|
|
|
INFO_STEP_COL= \\033[37;44m
|
2021-02-11 05:53:36 +08:00
|
|
|
INFO_ESTEP_COL= \\033[37;41m
|
|
|
|
INFO_WSTEP_COL= \\033[30;43m
|
2017-03-25 06:57:50 +08:00
|
|
|
INFO_NAME_COL= \\033[33;44m
|
|
|
|
INFO_LINE_COL= \\033[36;49m
|
|
|
|
INFO_ERR_COL= \\033[31m
|
|
|
|
INFO_WRN_COL= \\033[33m
|
|
|
|
INFO_POS_COL= \\033[32m
|
|
|
|
INFO_RST_COL= \\033[39;49;27m
|
|
|
|
INFO_CLR_EOL= \\033[K
|
2021-02-11 05:53:36 +08:00
|
|
|
INFO= printf "%-16s %-56s%6s\n"
|
|
|
|
INFO_NONL= printf "%-16s %-56s"
|
|
|
|
INFO_TEST= printf "%-16s %-56s%6s\n"
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
# Color for build steps
|
|
|
|
STEP_COLOR:= $(shell printf "$(INFO_STEP_COL)")
|
2021-02-11 05:53:36 +08:00
|
|
|
WSTEP_COLOR:= $(shell printf "$(INFO_WSTEP_COL)")
|
|
|
|
ESTEP_COLOR:= $(shell printf "$(INFO_ESTEP_COL)")
|
|
|
|
LINE_COLOR:= $(shell printf "$(INFO_LINE_COL)")
|
|
|
|
NAME_COLOR:= $(shell printf "$(INFO_NAME_COL)")
|
2017-03-25 06:57:50 +08:00
|
|
|
ERR_COLOR:= $(shell printf "$(INFO_ERR_COL)")
|
|
|
|
WRN_COLOR:= $(shell printf "$(INFO_WRN_COL)")
|
|
|
|
POS_COLOR:= $(shell printf "$(INFO_POS_COL)")
|
|
|
|
DEF_COLOR:= $(shell printf "$(INFO_RST_COL)")
|
|
|
|
CLR_EOLINE:= $(shell printf "$(INFO_CLR_EOL)")
|
|
|
|
|
|
|
|
SEDOPT_windows= -u
|
|
|
|
|
|
|
|
# Colorize warnings, errors and progress information
|
2017-04-15 20:05:05 +08:00
|
|
|
LINE_BUFFERED=--line-buffered
|
2021-02-11 15:24:00 +08:00
|
|
|
COLOR_FILTER= | grep $(LINE_BUFFERED) -v -e "^true &&" $(COLORIZE)
|
2021-03-04 15:33:07 +08:00
|
|
|
COLORIZE?= | sed $(SEDOPT_$(OS_NAME)) \
|
2021-02-11 05:53:36 +08:00
|
|
|
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ww]arning\)/$(POS_COLOR)\1$(WRN_COLOR)\2$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ee]rror\)/$(POS_COLOR)\1$(ERR_COLOR)\2$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[BEGIN\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[END\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
|
|
|
-e 's/\(\[OK\]\)/$(POS_COLOR)\1$(DEF_COLOR)/g' \
|
|
|
|
-e 's/\(\[NO\]\)/$(ERR_COLOR)\1$(DEF_COLOR)/g' \
|
|
|
|
-e 's/\(\[KO\]\)/$(ERR_COLOR)\1$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[WARNING\]\)\(.*\)$$/$(WSTEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[MISSING\]\)\(.*\)$$/$(WSTEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[ERROR\]\)\(.*\)$$/$(ERR_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
|
|
|
-e 's/^\(\[FAIL\]\)\(.*\)$$/$(ERR_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
|
2021-02-16 15:27:21 +08:00
|
|
|
-e 's/^\(\[[A-Z/ 0-9-]\{1,\}\]\)\(.*\)$$/$(NAME_COLOR)\1$(LINE_COLOR)\2$(DEF_COLOR)/g' ; \
|
|
|
|
[ $${PIPESTATUS[0]} -eq 0 ]
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Logging
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-11-08 19:02:39 +08:00
|
|
|
ifndef V
|
2018-04-05 23:25:12 +08:00
|
|
|
LOG_COMMANDS= PRINT_COMMAND="true && " 2>&1 | \
|
|
|
|
tee $(MIQ_BUILDLOG) \
|
|
|
|
$(COLOR_FILTER) ; \
|
|
|
|
RC=$${PIPESTATUS[0]} $${pipestatus[1]} ; \
|
|
|
|
$(ECHO) `grep -v '^true &&' $(MIQ_BUILDLOG) | \
|
|
|
|
grep -i $(ERROR_MSG) $(MIQ_BUILDLOG) | \
|
|
|
|
wc -l` Errors, \
|
|
|
|
`grep -v '^true &&' $(MIQ_BUILDLOG) | \
|
|
|
|
grep -i $(WARNING_MSG) | \
|
|
|
|
wc -l` Warnings in $(MIQ_BUILDLOG); \
|
|
|
|
cp $(MIQ_BUILDLOG) $(LAST_LOG); \
|
2017-03-25 06:57:50 +08:00
|
|
|
exit $$RC
|
2017-11-08 19:02:39 +08:00
|
|
|
endif
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
|
2017-04-15 20:28:32 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Build configuration and rules
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Include actual configuration for specific BUILDENV - At end for overrides
|
2018-04-05 23:25:12 +08:00
|
|
|
include $(MIQ)config.$(BUILDENV).mk
|