2019-03-22 23:35:00 +08:00
|
|
|
# ******************************************************************************
|
|
|
|
# config.gnu.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
|
|
|
#
|
|
|
|
# Makefile configuration file for GNU tools
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
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
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Tools
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-06-19 18:59:10 +08:00
|
|
|
CC= $(CROSS_COMPILE:%=%-)gcc
|
|
|
|
CXX= $(CROSS_COMPILE:%=%-)g++
|
2019-03-25 06:08:28 +08:00
|
|
|
LD= $(LD_$(words $(filter-out 0,$(words $(filter %.cpp,$(MIQ_SOURCES))))))
|
|
|
|
LD_0= $(CC)
|
|
|
|
LD_1= $(CXX)
|
2017-06-19 16:19:48 +08:00
|
|
|
CPP= $(CC) -E
|
2017-03-25 06:57:50 +08:00
|
|
|
PYTHON= python
|
2017-06-19 18:59:10 +08:00
|
|
|
AR= $(CROSS_COMPILE:%=%-)ar -rcs
|
|
|
|
RANLIB= $(CROSS_COMPILE:%=%-)ranlib
|
2017-03-25 06:57:50 +08:00
|
|
|
INSTALL= install
|
2020-12-19 03:51:12 +08:00
|
|
|
INSTALL.data= $(INSTALL) -m 644
|
|
|
|
INSTALL.bin= $(INSTALL)
|
|
|
|
INSTALL.h= $(INSTALL.data)
|
|
|
|
INSTALL.share= $(INSTALL.data)
|
|
|
|
INSTALL.lib= $(INSTALL)
|
|
|
|
INSTALL.man= $(INSTALL.data)
|
|
|
|
INSTALL.doc= $(INSTALL.data)
|
|
|
|
INSTALL.etc= $(INSTALL.data)
|
2018-09-20 00:09:25 +08:00
|
|
|
UNINSTALL= /bin/rm -f
|
2020-12-19 03:51:12 +08:00
|
|
|
UNINSTALL.dir= /bin/rmdir > /dev/null 2>&1
|
|
|
|
UNINSTALL.ok= || true
|
2017-11-28 23:48:57 +08:00
|
|
|
CAT= cat /dev/null
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2018-09-20 00:52:54 +08:00
|
|
|
# Tarball generation
|
|
|
|
GEN_TARBALL= mkdir $(MIQ_TARNAME) && \
|
|
|
|
tar cf - AUTHORS NEWS $(shell git ls-files) | \
|
|
|
|
(cd $(MIQ_TARNAME); tar xf - ) && \
|
|
|
|
tar cfj $@ $(MIQ_TARNAME) && \
|
|
|
|
rm -rf $(MIQ_TARNAME)
|
|
|
|
|
|
|
|
GEN_AUTHORS= (echo "This software was brought to you by:"; \
|
|
|
|
echo "" ; \
|
|
|
|
git log --format='%aN <%aE>' | sort -u | \
|
|
|
|
sed -e 's/^/- /g'; \
|
|
|
|
echo ""; \
|
|
|
|
echo "Thank you!")
|
2021-09-25 02:50:54 +08:00
|
|
|
GEN_NEWS= grep '^$(shell git tag -n1 `git describe`)' $@ || \
|
|
|
|
(touch $@; \
|
2018-11-10 01:48:23 +08:00
|
|
|
(git tag -l $(shell git describe) -n999 ; \
|
|
|
|
echo ""; \
|
|
|
|
cat $@) \
|
2021-09-25 02:50:54 +08:00
|
|
|
> $@.latest && mv $@.latest $@)
|
2018-09-20 00:52:54 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compilation flags
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2018-04-05 23:25:12 +08:00
|
|
|
CFLAGS_STD= $(CC_STD:%=-std=%) $(CFLAGS_PIC)
|
|
|
|
CXXFLAGS_STD= $(CXX_STD:%=-std=%) $(CFLAGS_PIC)
|
2018-11-20 06:07:09 +08:00
|
|
|
CFLAGS_DEPENDENCIES= -MD -MP -MF "$(@).d" -MT "$(@:$(MIQ_OBJDIR)%=\$$(MIQ_OBJDIR)%)"
|
2018-04-05 23:25:12 +08:00
|
|
|
|
|
|
|
CFLAGS_TARGET_debug= -g -Wall -fno-inline
|
|
|
|
CFLAGS_TARGET_opt= -g -O3 -Wall
|
|
|
|
CFLAGS_TARGET_release= -O3 -Wall
|
|
|
|
CFLAGS_TARGET_profile= -pg
|
|
|
|
LDFLAGS_TARGET_debug= -g
|
|
|
|
LDFLAGS_TARGET_profile= -pg
|
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# File extensions
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2020-09-02 04:04:53 +08:00
|
|
|
EXT.exe=
|
2018-04-10 20:25:02 +08:00
|
|
|
ifdef LIBTOOL
|
2020-09-02 04:04:53 +08:00
|
|
|
EXT.obj= .lo
|
|
|
|
EXT.lib= .la
|
|
|
|
EXT.dll= .la
|
2018-04-10 20:25:02 +08:00
|
|
|
else
|
2020-09-02 04:04:53 +08:00
|
|
|
EXT.obj= .o
|
|
|
|
EXT.lib= .a
|
|
|
|
EXT.dll= .so
|
2018-04-10 20:25:02 +08:00
|
|
|
endif
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2020-09-02 04:04:53 +08:00
|
|
|
PFX.exe=
|
|
|
|
PFX.lib= lib
|
|
|
|
PFX.dll= lib
|
2017-03-25 06:57:50 +08:00
|
|
|
|
2018-05-26 17:17:39 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Shared libraries versioning
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2021-03-04 15:34:30 +08:00
|
|
|
MIQ_SOBASE= $(@F:%.install.dll=%)
|
2018-11-09 19:25:19 +08:00
|
|
|
MIQ_SONAME= $(MIQ_SOBASE)$(MIQ_V_MAJOR:%=.%)
|
2021-03-04 15:34:30 +08:00
|
|
|
MIQ_DLLNAME= $(@F:%.install.dll=%)$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))
|
2018-05-26 17:17:39 +08:00
|
|
|
|
|
|
|
# Conversion to libttool input
|
|
|
|
MIQ_LT_CURRENT= $(shell echo $$(($(MIQ_V_MAJOR) + $(MIQ_V_MINOR))))
|
|
|
|
MIQ_LT_REVISION=$(MIQ_V_PATCH)
|
|
|
|
MIQ_LT_AGE= $(MIQ_V_MINOR)
|
|
|
|
MIQ_LT_VERSION= $(MIQ_LT_CURRENT):$(MIQ_LT_REVISION):$(MIQ_LT_AGE)
|
|
|
|
MIQ_LT_VERS_OPT=$(PRODUCTS_VERSION:%=-version-info $(MIQ_LT_VERSION))
|
|
|
|
|
|
|
|
# Symbolic links for shared libraries
|
|
|
|
MIQ_SONAME_OPT= $(PRODUCTS_VERSION:%=-Wl,-soname -Wl,$(MIQ_SONAME))
|
2021-03-04 15:34:30 +08:00
|
|
|
MIQ_SYMLINKS_SO=ln -sf $(MIQ_DLLNAME) $(MIQ_SOBASE) && \
|
|
|
|
ln -sf $(MIQ_DLLNAME) $(MIQ_SONAME)
|
2018-05-26 17:17:39 +08:00
|
|
|
MIQ_SYMLINKS= $(PRODUCTS_VERSION:%=&& $(MIQ_SYMLINKS_SO))
|
|
|
|
|
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Build rules
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2021-02-14 07:47:01 +08:00
|
|
|
# Select RPATH to include test paths for debug and opt
|
|
|
|
# For TARGET==release, you must install to test
|
|
|
|
RPATH= $(RPATH_$(TARGET)) $(PREFIX.dll)
|
|
|
|
RPATH_debug= . $(OUTPUT)
|
|
|
|
RPATH_opt= . $(OUTPUT)
|
|
|
|
RPATH_release=
|
|
|
|
|
2018-04-10 20:25:02 +08:00
|
|
|
MAKE_DIR= mkdir -p $*
|
|
|
|
MAKE_OBJDIR= $(MAKE_DIR) && touch $@
|
2021-02-14 07:47:01 +08:00
|
|
|
LDFLAGS_RPATH= $(RPATH:%=-Wl,-rpath,%)
|
2018-04-10 20:25:02 +08:00
|
|
|
|
|
|
|
ifdef LIBTOOL
|
2020-09-04 03:51:43 +08:00
|
|
|
COMPILE-lt= $(LIBTOOL) --silent --mode=compile
|
|
|
|
LINK-lt= $(LIBTOOL) --silent --mode=link
|
|
|
|
COMPILE.c= $(COMPILE-lt) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
|
|
|
COMPILE.cpp= $(COMPILE-lt) $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
|
|
|
COMPILE.s= $(COMPILE-lt) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
|
|
|
LINK.lib= $(LINK-lt) $(LD) $(MIQ_LDFLAGS) $(MIQ_LINKARGS) \
|
2019-04-13 04:37:35 +08:00
|
|
|
-o $@ \
|
2018-05-26 17:17:39 +08:00
|
|
|
$(MIQ_LT_VERS_OPT)
|
2020-09-02 06:44:09 +08:00
|
|
|
LINK.dll= $(LINK.lib)
|
2021-03-04 15:34:30 +08:00
|
|
|
INSTALL.dll= $(LIBTOOL) --silent --mode=install $(INSTALL)
|
2020-09-02 06:44:09 +08:00
|
|
|
LINK.exe= $(MIQ_LINK) $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
2018-04-10 20:25:02 +08:00
|
|
|
else
|
|
|
|
# Non-libtool case: manage manually
|
|
|
|
CFLAGS_PIC= -fPIC
|
2020-09-02 06:44:09 +08:00
|
|
|
COMPILE.c= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
|
|
|
COMPILE.cpp= $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
|
|
|
COMPILE.s= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
2020-09-04 03:51:43 +08:00
|
|
|
LINK.lib= $(AR) $@ $^ && $(RANLIB) $@
|
2020-09-02 06:44:09 +08:00
|
|
|
LINK.dll= $(LD) -shared $(MIQ_LINKARGS) $(MIQ_LDFLAGS) \
|
2021-03-04 15:34:30 +08:00
|
|
|
-o $(OUTPUT)$(MIQ_DLLNAME) \
|
2018-05-26 17:17:39 +08:00
|
|
|
$(MIQ_SONAME_OPT) \
|
|
|
|
&& (cd $(OUTPUT) $(MIQ_SYMLINKS))
|
2021-03-04 15:34:30 +08:00
|
|
|
INSTALL.dll= (cd $(PACKAGE_INSTALL.dll) $(MIQ_SYMLINKS)) && $(INSTALL)
|
2020-09-02 06:44:09 +08:00
|
|
|
LINK.exe= $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
2018-04-10 20:25:02 +08:00
|
|
|
endif
|
2017-11-08 23:10:51 +08:00
|
|
|
|
2020-09-02 06:44:09 +08:00
|
|
|
COMPILE.cc= $(COMPILE.cpp)
|
|
|
|
COMPILE.asm= $(COMPILE.s)
|
|
|
|
|
2017-11-08 23:10:51 +08:00
|
|
|
LINK_DIR_OPT= -L
|
|
|
|
LINK_LIB_OPT= -l
|
|
|
|
LINK_DLL_OPT= -l
|
2017-11-24 22:44:04 +08:00
|
|
|
LINK_CFG_OPT= -l
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Dependencies
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2018-04-05 23:25:12 +08:00
|
|
|
CC_DEPEND= $(CC) $(MIQ_CPPFLAGS) -MM -MP -MF $@ -MT $(@:.d=) $<
|
|
|
|
CXX_DEPEND= $(CXX) $(MIQ_CPPFLAGS) -MM -MP -MF $@ -MT $(@:.d=) $<
|
|
|
|
AS_DEPEND= $(CC) $(MIQ_CPPFLAGS) -MM -MP -MF $@ -MT $(@:.d=) $<
|
2017-05-02 21:27:41 +08:00
|
|
|
|
|
|
|
|
2017-11-08 23:10:51 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Test environment
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-11-28 22:14:37 +08:00
|
|
|
TEST_ENV= LD_LIBRARY_PATH=$(OUTPUT)
|
2017-11-08 23:10:51 +08:00
|
|
|
|
|
|
|
|
2017-05-02 21:27:41 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Configuration checks
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2018-04-05 23:25:12 +08:00
|
|
|
MIQ_CFGUPPER= $(shell echo -n "$(MIQ_ORIGTARGET)" | tr '[:lower:]' '[:upper:]' | tr -c '[:alnum:]' '_')
|
|
|
|
MIQ_CFGLFLAGS= $(MIQ_LDFLAGS) \
|
2017-11-30 19:19:44 +08:00
|
|
|
$(shell grep '// [A-Z]*FLAGS=' "$<" | \
|
2018-06-26 20:47:02 +08:00
|
|
|
sed -e 's|// [A-Z]*FLAGS=||g') \
|
|
|
|
$(shell $(CAT) $(MIQ_PKGLDFLAGS))
|
2018-04-05 23:25:12 +08:00
|
|
|
MIQ_CFGFLAGS= $(MIQ_CFGLFLAGS) \
|
2018-06-26 20:47:02 +08:00
|
|
|
$(shell $(CAT) $(MIQ_PKGCFLAGS))
|
2017-11-30 19:19:44 +08:00
|
|
|
|
2018-04-11 04:15:28 +08:00
|
|
|
MIQ_CFGSET= && MIQ_CFGRC=1 || MIQ_CFGRC=0;
|
2018-04-05 23:25:12 +08:00
|
|
|
MIQ_CFGTEST= "$<" -o "$<".exe > "$<".err 2>&1 && \
|
2017-11-30 19:19:44 +08:00
|
|
|
[ -x "$<".exe ] && \
|
2018-04-11 04:15:28 +08:00
|
|
|
"$<".exe > "$<".out \
|
|
|
|
$(MIQ_CFGSET)
|
2018-06-01 21:43:36 +08:00
|
|
|
MIQ_CFG_PRINT= if [ $$MIQ_CFGRC == 1 ]; then \
|
2021-02-11 05:53:36 +08:00
|
|
|
echo "[OK]"; \
|
2018-06-01 21:43:36 +08:00
|
|
|
else \
|
2021-02-11 05:53:36 +08:00
|
|
|
echo "[NO]"; \
|
2018-06-01 21:43:36 +08:00
|
|
|
fi;
|
2018-04-05 23:25:12 +08:00
|
|
|
MIQ_CFGUNDEF0= $$MIQ_CFGRC \
|
2017-11-22 00:23:49 +08:00
|
|
|
| sed -e 's|^\#define \(.*\) 0$$|/* \#undef \1 */|g' > "$@"; \
|
2018-06-01 21:43:36 +08:00
|
|
|
[ -f "$<".out ] && cat >> "$@" "$<".out; \
|
|
|
|
$(MIQ_CFG_PRINT) \
|
|
|
|
true
|
2017-11-30 19:19:44 +08:00
|
|
|
|
2018-04-05 23:25:12 +08:00
|
|
|
MIQ_CFGDEF= echo '\#define'
|
2017-11-30 19:19:44 +08:00
|
|
|
|
2018-06-01 01:53:11 +08:00
|
|
|
MIQ_CFGCFLAGS= $(CFLAGS) $(CFLAGS_CONFIG_$*) $(MIQ_CFGFLAGS)
|
|
|
|
MIQ_CFGCXXFLAGS=$(CXXFLAGS) $(CFLAGS_CONFIG_$*) $(MIQ_CFGFLAGS)
|
2017-11-30 19:19:44 +08:00
|
|
|
|
2018-04-11 04:15:28 +08:00
|
|
|
MIQ_CFGCC_CMD= $(CC) $(MIQ_CFGCFLAGS) $(MIQ_CFGTEST)
|
|
|
|
MIQ_CFGCXX_CMD= $(CXX) $(MIQ_CFGCXXFLAGS) $(MIQ_CFGTEST)
|
|
|
|
MIQ_CFGLIB_CMD= $(CC) $(MIQ_CFGLFLAGS) -l$* $(MIQ_CFGTEST)
|
|
|
|
MIQ_CFGFN_CMD= $(CC) $(MIQ_CFGCFLAGS) $(CFLAGS_CONFIG_$*) $(MIQ_CFGTEST)
|
|
|
|
MIQ_CFGPK_CMD= pkg-config $* --silence-errors $(MIQ_CFGSET)
|
2017-11-30 19:19:44 +08:00
|
|
|
|
2018-04-11 04:15:28 +08:00
|
|
|
MIQ_CC_CFG= $(MIQ_CFGCC_CMD) $(MIQ_CFGDEF) HAVE_$(MIQ_CFGUPPER)_H $(MIQ_CFGUNDEF0)
|
|
|
|
MIQ_CXX_CFG= $(MIQ_CFGCXX_CMD) $(MIQ_CFGDEF) HAVE_$(MIQ_CFGUPPER) $(MIQ_CFGUNDEF0)
|
|
|
|
MIQ_LIB_CFG= $(MIQ_CFGLIB_CMD) $(MIQ_CFGDEF) HAVE_LIB$(MIQ_CFGUPPER) $(MIQ_CFGUNDEF0)
|
|
|
|
MIQ_FN_CFG= $(MIQ_CFGFN_CMD) $(MIQ_CFGDEF) HAVE_$(MIQ_CFGUPPER) $(MIQ_CFGUNDEF0)
|
|
|
|
MIQ_PK_CFG= $(MIQ_CFGPK_CMD) $(MIQ_CFGDEF) HAVE_$(MIQ_CFGUPPER) $(MIQ_CFGUNDEF0)
|
2017-11-22 00:23:49 +08:00
|
|
|
|
2018-04-11 04:15:28 +08:00
|
|
|
MIQ_MK_CFG= sed -e 's|^\#define \([^ ]*\) \(.*\)$$|\1=\2|g' \
|
2017-11-22 00:23:49 +08:00
|
|
|
-e 's|.*undef.*||g' < "$<" > "$@"
|
2018-06-01 21:43:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# pkg-config checks
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_CFLAGS_CHECK= \
|
|
|
|
pkg-config --cflags $* > $@ $(MIQ_PKGCONFIG_ERROR_CHECK)
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_LIBS_CHECK= \
|
|
|
|
pkg-config --libs $* > $@ $(MIQ_PKGCONFIG_ERROR_CHECK)
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_ERROR_CHECK= \
|
|
|
|
|| (echo "Error"": Required package $* not found" && false)
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_BUILDMK= \
|
|
|
|
(echo CFLAGS_PKGCONFIG=`$(CAT) $(MIQ_PKGCFLAGS)`; \
|
|
|
|
echo LDFLAGS_PKGCONFIG=`$(CAT) $(MIQ_PKGLDFLAGS) $(MIQ_PKGLIBS)` ) > $@
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_CFLAGS_OPTIONAL= \
|
|
|
|
(pkg-config --cflags $* --silence-errors > $@ \
|
|
|
|
&& MIQ_CFGRC=1 || MIQ_CFGRC=0; \
|
|
|
|
true)
|
|
|
|
|
|
|
|
MIQ_PKGCONFIG_LIBS_OPTIONAL= \
|
|
|
|
(pkg-config --libs $* --silence-errors > $@ \
|
|
|
|
&& MIQ_CFGRC=1 || MIQ_CFGRC=0; \
|
|
|
|
true)
|
2021-02-11 05:53:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Test checks
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MIQ_TEST= && MIQ_RC=1 || MIQ_RC=0; true
|
|
|
|
PRINT_TEST_OK= if [ $$MIQ_RC == 1 ]; then \
|
|
|
|
echo "[OK]"; \
|
|
|
|
else \
|
|
|
|
echo "[KO]"; \
|
|
|
|
fi;
|