make-it-quick/config.mk

218 lines
7.9 KiB
Makefile
Raw Normal View History

2017-03-25 06:57:50 +08:00
#******************************************************************************
# config.mk Make-It-Quick project
2017-03-25 06:57:50 +08:00
#******************************************************************************
#
# File Description:
#
# 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
#
#
#
#
#
#
#******************************************************************************
2018-04-03 21:15:09 +08:00
# (C) 1992-2018 Christophe de Dinechin <christophe@dinechin.org>
# This software is licensed under the GNU General Public License v3
# See LICENSE file for details.
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
TARGET?=opt
2017-03-25 06:57:50 +08:00
# Default build environment if not set
BUILDENV?=auto
# Default top level directory
TOP?=$(abspath .)/
# Default output for build products
OUTPUT?=$(TOP)
2017-03-25 06:57:50 +08:00
# Default location for object files
OBJFILES?= $(TOP).objects/
2017-03-25 06:57:50 +08:00
# Default location for build logs
LOGS?=$(TOP).logs/
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
2017-11-28 19:50:32 +08:00
# Stuff to install
TO_INSTALL=
# 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")
# Local configuration if any
-include $(MIQ)config.local-setup.mk
# Extract defaults for package name and version if not set
PACKAGE_NAME?=$(firstword $(PRODUCTS) $(notdir $(shell pwd)))
PACKAGE_VERSION?=$(shell (git describe --always --match 'v[0-9].*' 2> /dev/null | sed -e 's/^v//') || echo unknown)
# Package installation directory
PACKAGE_DIR?=$(PACKAGE_NAME:%=%/)
PACKAGE_LIBS=$(MIQ_PRODLIB)
PACKAGE_DLLS=$(MIQ_PRODDLL)
2017-11-28 19:50:32 +08:00
# Package configuration directories by default
PACKAGE_PREFIX?=$(PREFIX)
PACKAGE_PREFIX_LIB?=$(PREFIX_LIB)
PACKAGE_PREFIX_HDR?=$(PREFIX_HDR)
# Location of configuration files, etc (tweaked at install time)
CONFIG_SOURCES?=$(MIQ)config/
# Sources to reformat
CLANG_FORMAT_SOURCES=$(SOURCES) $(HDR_INSTALL)
2017-03-25 06:57:50 +08:00
#------------------------------------------------------------------------------
# Installation paths
#------------------------------------------------------------------------------
2017-11-30 17:06:05 +08:00
SYSCONFIG?=$(DESTDIR)/etc/
2017-11-06 23:58:00 +08:00
PREFIX?=$(DESTDIR)/usr/local/
2017-03-25 06:57:50 +08:00
PREFIX_BIN?=$(PREFIX)bin/
PREFIX_LIB?=$(PREFIX)lib/$(PACKAGE_DIR)
2017-03-25 06:57:50 +08:00
PREFIX_DLL?=$(PREFIX_LIB)
PREFIX_HDR?=$(PREFIX)include/$(PACKAGE_DIR)
PREFIX_SHARE?=$(PREFIX)share/$(PACKAGE_DIR)
PREFIX_PKGCONFIG=$(PREFIX)share/pkgconfig/
2017-03-25 06:57:50 +08:00
#------------------------------------------------------------------------------
# Compilation flags
#------------------------------------------------------------------------------
# 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]
CC_STD ?=gnu11
CXX_STD ?=gnu++11
2017-03-25 06:57:50 +08:00
# Compilation flags
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
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
#------------------------------------------------------------------------------
# OS name for a given build environment
#------------------------------------------------------------------------------
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
#------------------------------------------------------------------------------
# These use ANSI code, but they work on Mac, Windows, Linux, BSD and VMS, which is good enough
# Change them if you want to work from an hpterm on HP-UX ;-)
INFO_STEP_COL= \\033[37;44m
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
INFO= printf "%-20s %s %s %s %s %s %s %s\n"
INFO_NONL= printf "%-20s %-30s %s %s %s %s %s %s"
2017-03-25 06:57:50 +08:00
# Color for build steps
STEP_COLOR:= $(shell printf "$(INFO_STEP_COL)")
LINE_COLOR:= $(shell printf "$(INFO_NAME_COL)")
NAME_COLOR:= $(shell printf "$(INFO_LINE_COL)")
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
2017-12-01 17:31:55 +08:00
COLOR_FILTER= | grep $(LINE_BUFFERED) -v -e "^true &&" -e "^[A-Za-z0-9_-]\+\.\(c\|h\|cpp\|hpp\)$$" \
$(COLORIZE)
COLORIZE= | sed $(SEDOPT_$(OS_NAME)) \
2017-03-25 06:57:50 +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/^\(\[[A-Z/ 0-9-]\{1,\}\]\)\(.*\)$$/$(LINE_COLOR)\1$(NAME_COLOR)\2$(DEF_COLOR)/g'
#------------------------------------------------------------------------------
# Logging
#------------------------------------------------------------------------------
ifndef V
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
endif
2017-03-25 06:57:50 +08:00
#------------------------------------------------------------------------------
# Build configuration and rules
#------------------------------------------------------------------------------
# Include actual configuration for specific BUILDENV - At end for overrides
include $(MIQ)config.$(BUILDENV).mk