2017-03-25 06:57:50 +08:00
|
|
|
#******************************************************************************
|
2017-06-16 16:34:22 +08:00
|
|
|
# config.gnu.mk Recorder project
|
2017-03-25 06:57:50 +08:00
|
|
|
#******************************************************************************
|
|
|
|
#
|
|
|
|
# File Description:
|
|
|
|
#
|
|
|
|
# Makefile configuration file for GNU tools
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#******************************************************************************
|
|
|
|
# (C) 1992-2017 Christophe de Dinechin <christophe@dinechin.org>
|
|
|
|
#This software is licensed under the GNU General Public License v3
|
|
|
|
#See file COPYING for details.
|
|
|
|
#******************************************************************************
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Tools
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-06-19 18:59:10 +08:00
|
|
|
CC= $(CROSS_COMPILE:%=%-)gcc
|
|
|
|
CXX= $(CROSS_COMPILE:%=%-)g++
|
2017-07-19 05:14:50 +08:00
|
|
|
ifeq ($(filter %.cpp,$(SOURCES)),)
|
|
|
|
LD= $(CC)
|
|
|
|
else
|
2017-06-19 16:41:25 +08:00
|
|
|
LD= $(CXX)
|
2017-07-19 05:14:50 +08:00
|
|
|
endif
|
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
|
|
|
LIBTOOL= libtool -no_warning_for_no_symbols
|
|
|
|
INSTALL= install
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compilation flags
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-11-24 18:23:23 +08:00
|
|
|
CFLAGS_STD= $(CC_STD:%=-std=%) -fPIC
|
|
|
|
CXXFLAGS_STD= $(CXX_STD:%=-std=%) -fPIC
|
2017-06-19 16:41:25 +08:00
|
|
|
|
2017-03-25 06:57:50 +08:00
|
|
|
CFLAGS_debug= -g -Wall -fno-inline
|
2017-04-18 23:42:33 +08:00
|
|
|
CFLAGS_opt= -g -O3 -Wall
|
2017-03-25 06:57:50 +08:00
|
|
|
CFLAGS_release= -O3 -Wall
|
|
|
|
CFLAGS_profile= -pg
|
|
|
|
CFLAGS_cxx= -x c++
|
|
|
|
LDFLAGS_debug= -g
|
|
|
|
LDFLAGS_profile=-pg
|
2017-05-01 23:06:28 +08:00
|
|
|
DEPFLAGS= -MD -MP -MF $(@).d -MT $@
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# File extensions
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OBJ_EXT= .o
|
|
|
|
LIB_EXT= .a
|
2017-06-16 16:34:22 +08:00
|
|
|
EXE_EXT=
|
2017-03-25 06:57:50 +08:00
|
|
|
DLL_EXT= .so
|
|
|
|
|
2017-11-08 23:10:51 +08:00
|
|
|
EXE_PFX=
|
|
|
|
LIB_PFX= lib
|
|
|
|
DLL_PFX= lib
|
2017-03-25 06:57:50 +08:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Build rules
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-11-28 19:50:32 +08:00
|
|
|
MAKE_CC= $(CC) $(CFLAGS) $(CPPFLAGS_$*) $(CFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
|
|
|
|
MAKE_CXX= $(CXX) $(CXXFLAGS) $(CPPFLAGS_$*) $(CXXFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
|
|
|
|
MAKE_AS= $(CC) $(CFLAGS) $(CPPFLAGS_$*) $(CFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
|
|
|
|
MAKE_DIR= mkdir -p $*
|
|
|
|
MAKE_OBJDIR= $(MAKE_DIR) && touch $@
|
|
|
|
MAKE_LIB= $(AR) $@ $(LINK_INPUTS)&& $(RANLIB) $@
|
|
|
|
MAKE_DLL= $(LD) -shared $(LDFLAGS) $(LDFLAGS_$*) $(LINK_CMDLINE) -o $@
|
|
|
|
MAKE_EXE= $(LD) $(LDFLAGS) $(LDFLAGS_$*) $(LINK_CMDLINE) -o $@
|
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
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-05-01 23:06:28 +08:00
|
|
|
CC_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
|
|
|
|
CXX_DEPEND= $(CXX) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
|
|
|
|
AS_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
|
2017-05-02 21:27:41 +08:00
|
|
|
|
|
|
|
|
2017-11-08 23:10:51 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Test environment
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TEST_ENV= LD_LIBRARY_PATH=$(OBJROOT)
|
|
|
|
|
|
|
|
|
2017-05-02 21:27:41 +08:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Configuration checks
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2017-11-22 00:23:49 +08:00
|
|
|
CFG_UPPER=$(shell echo -n "$(ORIG_TARGET)" | tr '[:lower:]' '[:upper:]' | tr -c '[:alnum:]' '_')
|
|
|
|
CFG_FLAGS=$(shell grep '// [A-Z]*FLAGS=' "$<" | sed -e 's|// [A-Z]*FLAGS=||g')
|
|
|
|
|
|
|
|
CFG_DEF= echo '\#define'
|
|
|
|
CFG_TEST= \
|
|
|
|
$(CFG_FLAGS) "$<" -o "$<".exe > "$<".err 2>&1 && \
|
|
|
|
"$<".exe > "$<".out && echo 1 || echo 0
|
|
|
|
CFG_UNDEF0= \
|
|
|
|
| sed -e 's|^\#define \(.*\) 0$$|/* \#undef \1 */|g' > "$@"; \
|
|
|
|
[ -f "$<".out ] && cat >> "$@" "$<".out; true
|
2017-11-24 17:43:30 +08:00
|
|
|
CFG_CFLAGS= $(CFLAGS) $(shell cat $(PKG_CFLAGS) $(PKG_LDFLAGS) /dev/null)
|
|
|
|
CFG_CXXFLAGS= $(CXXFLAGS) $(shell cat $(PKG_CFLAGS) $(PKG_LDFLAGS) /dev/null)
|
2017-11-22 00:23:49 +08:00
|
|
|
|
2017-11-24 17:43:30 +08:00
|
|
|
CFG_CC_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) $(CFG_TEST)`
|
|
|
|
CFG_CXX_CMD= `$(CXX) $(CFG_CXXFLAGS) $(CXXFLAGS_CONFIG_$*) $(CFG_TEST)`
|
|
|
|
CFG_LIB_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) -l$* $(CFG_TEST)`
|
|
|
|
CFG_FN_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) $(CFG_TEST)`
|
2017-11-22 00:23:49 +08:00
|
|
|
|
|
|
|
CC_CONFIG= $(CFG_DEF) HAVE_$(CFG_UPPER)_H $(CFG_CC_CMD) $(CFG_UNDEF0)
|
|
|
|
CXX_CONFIG= $(CFG_DEF) HAVE_$(CFG_UPPER) $(CFG_CXX_CMD) $(CFG_UNDEF0)
|
|
|
|
LIB_CONFIG= $(CFG_DEF) HAVE_LIB$(CFG_UPPER) $(CFG_LIB_CMD) $(CFG_UNDEF0)
|
|
|
|
FN_CONFIG= $(CFG_DEF) HAVE_$(CFG_UPPER) $(CFG_FN_CMD) $(CFG_UNDEF0)
|
|
|
|
|
2017-11-28 21:45:14 +08:00
|
|
|
MAKE_CONFIG= sed -e 's|^\#define \([^ ]*\) \(.*\)$$|\1=\2|g' \
|
2017-11-22 00:23:49 +08:00
|
|
|
-e 's|.*undef.*||g' < "$<" > "$@"
|