# COMPILE_c_o_template, COMPILE_cc_o_template, COMPILE_S_o_template -
# templates that create rules for compilation of sources
-# CMETRIC_o_h_template - FIXME
-
# PROGRAM_template, LIBRARY_template, SOLIB_template - templates that
# create rules for compilation of a program, library and shared
# library. The rules can use rules produced by COMPILE_xxx_template.
ASM_EXT = .S
CC = $(CROSS_COMPILE)gcc
+CXX = $(CROSS_COMPILE)g++
LINK = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
OBJCOPY = $(CROSS_COMPILE)objcopy
-include $(OBJS_DIR)/*.d
-SOURCES2OBJS = .o/.c .o/.cc .o/.cxx .o/.S .o/.o
+SOURCES2OBJS = .o/.c .o/.cc .o/.cxx .o/.S .o/.s .o/.o
-SOURCES2OBJSLO = .lo/.c .lo/.cc .lo/.cxx .lo/.S .lo/.lo
+SOURCES2OBJSLO = .lo/.c .lo/.cc .lo/.cxx .lo/.S .lo/.s .lo/.lo
#%.lo: %.c
# $(CC) -o $@ $(LCFLAGS) -c $<
-c_o_COMPILE = $$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $$(CFLAGS)
+c_o_COMPILE = $$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \
+ $(CPPFLAGS) $(OMK_CFLAGS) $$(CFLAGS)
-cc_o_COMPILE = $$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $$(CFLAGS)
+cc_o_COMPILE = $$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \
+ $(CPPFLAGS) $(CXXFLAGS) $(OMK_CFLAGS) $$(CFLAGS)
S_o_COMPILE = $$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(CPPFLAGS) $(AM_CFLAGS) $$(CFLAGS) $(ASFLAGS)
+ $(CPPFLAGS) $(OMK_CFLAGS) $$(CFLAGS) $(ASFLAGS)
# Check GCC version for user build
ifndef CC_MAJOR_VERSION
-CC_MAJOR_VERSION = $$(shell $$(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+CC_MAJOR_VERSION = $$(shell $$(CC) -dumpversion | $(SED4OMK) -e 's/\([^.]\)\..*/\1/')
endif
# Prepare suitable define for dependency building
ifeq ($$(CC_MAJOR_VERSION),2)
fi
endef
-# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
-define CMETRIC_o_h_template
-$(2): $(1)
- @$(QUIET_CMD_ECHO) " CMETRIC $$@"
- $(Q)if [ -n `dirname $$@` ] ; then \
- if [ ! -e `dirname $$@` ] ; then \
- mkdir -p `dirname $$@` ; fi ; fi
- $(Q)echo >$$@.tmp '/* Automatically generated from $$< */'
- $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */'
-# Bellow, the tricks with redirection are for shells without set -o pipefail
-# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html)
- $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
- | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
- | sort >>$$@.tmp` && exit $$$$status
- $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
- $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
- | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
- | sort >>$$@.tmp` && exit $$$$status
- $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
- $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
- | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
- | sort >>$$@.tmp` && exit $$$$status
- $(Q)mv $$@.tmp $$@
-endef
-
# Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<link-variant>)
define PROGRAM_template
$(2)/$(1)$(3:%=-%): $$($(1)_OBJS)
@$(QUIET_CMD_ECHO) " LINK $$@"
- $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES))" ] ; \
- then echo $$(CC) $$(CPPFLAGS) $$(AM_CPPFLAGS) $$(AM_CFLAGS) $$(CFLAGS) ; \
- else echo $$(CXX) $$(CPPFLAGS) $$(AM_CPPFLAGS) $$(AM_CXXFLAGS) $$(CXXFLAGS) ; fi) \
- $$(AM_LDFLAGS) $$(LDFLAGS) $$($(1)$(3:%=-%)_LDFLAGS) -Wl,-Map,$(1)$(3:%=-%).map \
- $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_MOREOBJS) $$($(1)_LIBS:%=-l%) \
+ $(Q) $$(if $$(filter %.cc,$$($(1)_SOURCES)) , \
+ $$(CXX) $$(CPPFLAGS) $$(OMK_CPPFLAGS) $$(OMK_CXXFLAGS) $$(CXXFLAGS) , \
+ $$(CC) $$(CPPFLAGS) $$(OMK_CPPFLAGS) $$(OMK_CFLAGS) $$(CFLAGS) ) \
+ $$(OMK_LDFLAGS) $$(LDFLAGS) $$($(1)$(3:%=-%)_LDFLAGS) -Wl,-Map,$(1)$(3:%=-%).map \
+ $$($(1)_OBJS) $$($(1)_MOREOBJS) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) \
-o $$@
@echo "$(2)/$(1)$(3:%=-%): \\" >$(OBJS_DIR)/$(1)$(3:%=-%).exe.d
@if [ -n "$(LD_SCRIPT)" ]; then \
echo " $(LIB_DIR)/$(LD_SCRIPT).ld$(3:%=-%) \\" >>$(OBJS_DIR)/$(1)$(3:%=-%).exe.d; fi
- @sed -n -e 's|^LOAD \(.*\)$$$$| \1 \&|p' $(OBJS_DIR)/$(1)$(3:%=-%).map|tr '&' '\134' >>$(OBJS_DIR)/$(1)$(3:%=-%).exe.d
+ @$(SED4OMK) -n -e 's|^LOAD \(.*\)$$$$| \1 \&|p' $(OBJS_DIR)/$(1)$(3:%=-%).map|tr '&' '\134' | grep -v '^ linker [^ ]' >>$(OBJS_DIR)/$(1)$(3:%=-%).exe.d
@echo >>$(OBJS_DIR)/$(1).exe.d
endef