zephyr/make/target/toolchain/common/defs.objects
Inaky Perez-Gonzalez 8ddf82cf70 First commit
Signed-off-by:  <inaky.perez-gonzalez@intel.com>
2015-04-10 16:44:37 -07:00

131 lines
5.3 KiB
Plaintext

# defs.objects - build system
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3) Neither the name of Wind River Systems nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
iUSE_CCACHE_y = y
# ccache does not work if cflags are passed through a file: they must be
# passed on the command-line, so force NO_FLAGS_FILES if using it
iNO_FLAGS_FILES = $(or ${iUSE_CCACHE_${VXMICRO_USE_CCACHE}},${VXMICRO_NO_FLAGS_FILES})
iOBJ_VAR_EXT_y = $o
iOBJ_VAR_EXT_n = flags
iOBJ_VAR_EXT_ = flags
iOBJ_VAR_EXT = ${iOBJ_VAR_EXT_${iNO_FLAGS_FILES}}
$(if ${iOBJ_VAR_EXT},,$(error VXMICRO_NO_FLAGS_FILES is set to an invalid value))
# $(word 1,$1): basename
# $(word 2,$1): output dir
# $(word 3,$1): source file
#####
# generate a .o file from a C file
define one_C_obj_file__rule
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iLIB_CFLAGS=$${$$(or $${iLIB_NAME},COMMON)_CFLAGS}
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iSRC_CFLAGS=$$(strip \
$${$${iLIB_NAME}$$(if $${iLIB_NAME},_,)$$(word 1,$1)_CFLAGS} \
$${-iinclude}$$(word 2,$1)/$$(word 1,$1).hash \
)
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iINC_PATHS=$$(strip \
$$(foreach path,$${iINCLUDE_DIR},-I $${path}) \
)
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iOBJ_FLAGS=$$(strip \
$${CFLAGS} $${iLIB_CFLAGS} $${iSRC_CFLAGS} $${iTC_SYSINC} $${iINC_PATHS} \
)
# Generate the hash file
$$(word 2,$1)/$$(word 1,$1).hash: | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Generating [$$(notdir $$@)]'
$q${HOS_GenHash} $$@ $$@
ifeq (${iNO_FLAGS_FILES},y)
$$(word 2,$1)/$$(word 1,$1).$o: $$(word 3,$1) $$(word 2,$1)/$$(word 1,$1).hash ${iDEPEND_ON_MAKEFILES} | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Compiling [$$(notdir $$<)]'
$q${HOS_ccache} ${CC} $${iOBJ_FLAGS} $$< -o $$@
$q${CC} $${iOBJ_FLAGS} $${iCC_DEP_GEN} $$< $${iCC_DEP_TARGET}$$@ $${iCC_DEP_FILE}$${@:.o=.d} $${iQUIESCE_DOT_D}
else
$$(word 2,$1)/$$(word 1,$1).flags: ${iDEPEND_ON_MAKEFILES} | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Preparing [$$(notdir $$@)]'
$qecho $${CFLAGS} $${iLIB_CFLAGS} $${iSRC_CFLAGS} $${iTC_SYSINC} $${iINC_PATHS} > $$@
$$(word 2,$1)/$$(word 1,$1).$o: $$(word 3,$1) $$(word 2,$1)/$$(word 1,$1).hash $$(word 2,$1)/$$(word 1,$1).flags | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Compiling [$$(notdir $$<)]'
$q${CC} @$$(word 2,$1)/$$(word 1,$1).flags $$< $${-o} $$@
$q${CC} @$$(word 2,$1)/$$(word 1,$1).flags $${iCC_DEP_GEN} $$< $${iCC_DEP_TARGET}$$@ $${iCC_DEP_FILE}$${@:.o=.d} $${iQUIESCE_DOT_D}
endif
endef
#####
# generate a .o file from an assembly file
define one_ASM_obj_file__rule
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iLIB_ASMFLAGS=$${$$(or $${iLIB_NAME},COMMON)_ASMFLAGS}
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iSRC_ASMFLAGS=$$(strip \
$${$${iLIB_NAME}$$(if $${iLIB_NAME},_,)$$(word 1,$1)_ASMFLAGS} \
)
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iINC_PATHS=$$(strip \
$$(foreach path,$${iINCLUDE_DIR},-I $${path}) \
)
$$(word 2,$1)/$$(word 1,$1).${iOBJ_VAR_EXT}: iOBJ_FLAGS=$$(strip \
$${ASMFLAGS} $${iLIB_ASMFLAGS} $${iSRC_ASMFLAGS} $${iINC_PATHS} \
)
ifeq (${iNO_FLAGS_FILES},y)
$$(word 2,$1)/$$(word 1,$1).$o: $$(word 3,$1) ${iDEPEND_ON_MAKEFILES} | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Assembling [$$(notdir $$<)]'
$q${AS} $${iOBJ_FLAGS} $${iPP_AS} $$< -o $$@
$q${AS} $${iOBJ_FLAGS} $${iCC_DEP_GEN} $$< $${iCC_DEP_TARGET}$$@ $${iCC_DEP_FILE}$${@:.o=.d} $${iQUIESCE_DOT_D}
else
$$(word 2,$1)/$$(word 1,$1).flags: ${iDEPEND_ON_MAKEFILES} | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Preparing [$$(notdir $$@)]'
$qecho $${ASMFLAGS} $${iLIB_ASMFLAGS} $${iSRC_ASMFLAGS} $${iPP_AS} $${iINC_PATHS} > $$@
$$(word 2,$1)/$$(word 1,$1).$o: $$(word 3,$1) $$(word 2,$1)/$$(word 1,$1).flags | $$(word 2,$1)/.dir
-@${HOS_Echo} '[${vTOOL}] Assembling [$$(notdir $$<)]'
$q${AS} @$$(word 2,$1)/$$(word 1,$1).flags $$< $${-o} $$@
$q${AS} @$$(word 2,$1)/$$(word 1,$1).flags $${iCC_DEP_GEN} $$< $${iCC_DEP_TARGET}$$@ $${iCC_DEP_FILE}$${@:.o=.d} $${iQUIESCE_DOT_D}
endif
endef
#####