Files
m241Neelima/vxworks-6.9/target/h/make/rules.library
T
2026-07-30 11:19:44 +05:30

787 lines
28 KiB
Plaintext

# rules.library - Host independent rules for making libraries
#
# Copyright 1984-2012 Wind River Systems, Inc.
#
# The right to copy, distribute, modify or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
# modification history
# --------------------
# 04w,11sep12,pee WIND00328069
# 04v,06feb12,mze fix typo
# 04u,02feb12,mze add .CPP as a valid suffix
# 04t,26jan11,mze fix WIND00252737
# 04s,27oct10,mze change AUTOCONF_INCLUDED macro for posix compliance
# 04r,20sep10,pee WIND00233058
# 04q,05apr10,gvm Added rules to remove .ARM.attributes sections from objects
# for GCC
# 04p,27aug09,pee WIND00179104
# 04o,23jul09,pee add DKM tags for .out files..
# 04n,30jun09,pee adding support for optional rule files.
# 04m,22apr09,pee adding optional CC wrapper.
# 04l,04may09,pee adding VSB private include directory
# 04k,03apr09,pee generation of VSB header file directory.
# 04l,25mar09,pee WIND00161015
# 04k,30jan09,pee WIND00153935
# 04j,06nov08,pee WIND00139818
# 04i,05nov08,mze Pass VSB_DIR down in submakes
# 04h,18sep08,pee WIND00134809.
# 04g,16sep08,pee fixing recursion problem.
# 04f,11sep08,pee more precomp...
# 04e,09sep08,pee adding variant build to precomp.
# 04d,26aug08,pee added named rule for vsb config file.
# 04c,27aug08,pee adding WV_INSTRUMENTATION def to vsbConfig.h for code
# transition.
# 04b,17jul08,pee VSB
# 04a,17jul08,pee precomp dependency on directory.
# 03z,16jul08,pee adding precomp target to build precomp only.
# 03y,15jul08,pee missing dependency for precomp
# 03x,11jul08,pee Fixing flag expansion for precomp objects.
# 03w,05jul08,jpb Fixed typo. Added ifndef in case _WRS_VX_SMP
# already defined.
# 03v,26may08,pee removing rules to build and clean files outside
# libraries such as scgen and vxbus files.
# 03u,12may08,pee deprecating top level legacy libraries lib$(CPU)$(TOOL)vx.a
# 03t,30apr08,pee more vsb.
# 03s,23apr08,pee vsb
# 03s,03mar08,pee adding lib specific flag.
# 03r,11oct07,pee cleaning up dependencies for implicit rules.
# 03q,28sep07,pee WIND00105890
# 03p,22sep07,tor move vxbUsrCmdLine.c to BSP build
# 03o,17sep07,pee WIND00101242, WIND00101957
# 03n,01aug07,tor vxbUsrCmdLine.c and vxbMethodDecl.h dependency improvements
# 03m,19jul07,tor dependency on vxbUsrCmdLine.c and vxbMethodDecl.h
# 03l,16jul07,mcm Further updates to remove unrecognized sections when files
# are compiled with GCC.
# 03k,13jul07,mcm Adding temporary rules to remove .gnu.attributes and
# .ARM.attributes sections when compiling with gnu.
# 03j,19jun07,tpw Use WRVX_COMPBASE vs. WIND_COMPONENTS correctly.
# 03i,30may07,dcc removed CC_SDA_FLAGS from asm and c++ builds.
# 03h,01jun07,tkf ipcom_ipdomain now generated in _IPCOM_OBJ_DIR.
# 03g,05may07,dcc added CC_SDA_FLAGS.
# 03f,23apr07,pee support for building project from source with multiple libs
# 03e,30mar07,mmg update for parallel make operation
# 03d,03mar07,tkf Add dependency on IPCOM include path file for .o targets.
# 03c,15nov06,jpb added TOOL parameter for scgen
# 03b,10nov06,tkf Added -include rules.ipcom
# 03a,15jun06,tfo added rule for .c files in obj path
# 02z,22may06,pee Adding support for multiple libraries
# 02y,22aug05,pee added target name to make depend rules
# 02x,05aug05,??? fix for too long expansion
# 02w,22jul05,pee cleaned precomp rules. They failed on large paths.
# 02v,07jul05,pee added opath target to help find object files.
# 02u,31may05,md,pee moved dependencies to object directory
# 02t,18apr05,pee added support for precomp objs.
# 02s,07apr05,h_a LIB_ROOT to replace $(TGT_DIR)/lib for building components
# 02r,04feb05,lei no need a dependency file for "make man"
# 02q,14may04,yvp Added LOCAL_RCLEAN rule.
# 02p,22mar04,yvp Changed rules for scgen-derived-files to match scgen ver02a.
# 02o,13mar04,dlk Support option builds.
# 02n,02mar04,yvp Added separate rule to make TGT_DIR/h/syscall.h.
# 02m,26feb04,yvp Added copy rules for syscall.h (SPR 93550).
# 02l,20feb04,c_c Added BUILD_EXT in ctdt file to allow parallel builds
# (SPR 79165).
# + merged fix for SPR #93014.
# 02k,22jan04,pch SPR 93014: unify build rules for CPUGEN_EXISTS
# and remove debug code introduced in 02e.
# 02j,16dec03,yvp Ignore error deleting scgen temp files.
# 02i,15dec03,yvp Cleanup scgen invocation rules.
# 02h,04dec03,yvp Changed options to scgen.
# 02g,03dec03,c_c Clean variant directories when invoking rclean.
# 02f,07nov03,c_c Unified build rules with WIN32 hosts.
# 02e,03nov03,pch don't try to run cpuGen if it does not exist
# 02d,10oct03,yvp Added -h (header file only) option to scgen.
# 02c,18sep03,yvp Added syscalldeps.
# 02b,14feb02,jab use LD_PARTIAL_LAST_FLAGS in last link for .out targets
# 02a,14dec01,tam made CPU variant builds automatic
# 01z,06dec01,tam added support for building CPU variant archive(s)
# 01y,04dec01,sn added BUILD_ALL_OBJS
# 01x,12nov01,tam added use of TOOL_COMMON_DIR
# 01w,09nov01,tam removed '//' in paths
# 01v,08nov01,tam fix x86-win32 build; added build of empty lib$CPU$TOOLvx.a
# 01u,01nov01,tam updated rclean rule for new archive directory hierarchy
# 01t,19oct01,pch Add rules and dependencies for generation of
# target/src/arch/Makefile and target/h/types/vxCpu.h
# 01s,01nov01,jab added LIBDIR directory creation
# 01r,24oct01,tam updated for repackaging
# 01q,23oct01,jab cleaned up
# 01p,11oct01,dbs add EXCLUDE_SUBDIRS variable as per AE
# 01o,20sep01,dat Moving make files to h/tool/
# 01n,19sep01,mem Prefix $(VX_CPU_FAMILY) to LIBDIRBASE path.
# 01m,06aug01,mem Updated for new runtime arrangement.
# 01l,25jul01,sn Add per-file CFLAGS capability for C++ files
# 01k,24jul01,r_s changing the make 'ifeq' conditional to work with 'gnu',
# 'sfgnu', 'sfgnule' etc for TOOL
# 01j,24jul01,r_s diab specific rules added
# 01j,05jun01,mem Add per-file CFLAGS_AS capability.
# 01i,12jan00,dra add per-file CFLAGS capability
# 01h,19jan99,dra use LD_PARTIAL_FLAGS for partial links with ctdt.o
# 01g,23feb99,sn removed references to $(POST_MUNCH)
# -traditional -> -fdollars-in-identifiers
# 01f,02feb99,sn added rules to build standalone "munched" C++ modules
# (useful for building test programs)
# 01e,11dec98,j_w add clean rule to remove lib$(CPU)$(TOOL).a
# 01d,11nov98,sn undid 01d
# 01c,07nov96,yp made the RM commands in implicit rules windows friendly
# 01b,17may96,yp moved clean rule to host specific stubs so Windows will work
# 01a,07may96,yp created
#
# DESCRIPTION
# This file is included by every Makefile in the run-time (not BSPs).
# This file contains makefile rules that are host independent for creating
# vxWorks libraries. It also contains implicit rules for .c .s .cpp and .cxx
# files in either the current directory or in $(LIBDIR).
#
# In each source directory, the list of source files is obtained and matched
# against the objects specified to be built in the OBJS macro. In this way
# extraneous .c and .s files are ignored and make does not fail if it doesn't
# find the source file to an object in OBJS (This is the case with most source
# customers).
#
# The MAKETAIL and CLEANTAIL macros, designed by Sott H. although obsolete
# from here on, are still available and known to work only in Unix environments.
#
# If the macro SUBDIRS is defined with directories we build the subdirectories
# before we build the current dir.
#
# INCLUDES
# $(TGT_DIR)/h/make/defs.library
# $(TGT_DIR)/h/make/rules-lib.$(WIND_HOST_TYPE)
# depend.$(BUILD_EXT)
# By default object files are installed in the toolchain independent object
# directory if LIB_BASE_NAME is set, that is when LIB_COMMON is not set.
# this is a workaround to a deficiency in make 3.80.
# will be fixed in 3.81
# eval functions in defs.library cannot be put inside coditional, so the condition
# is tested here
ifeq ($(DEFS_LIBRARY),)
include $(TGT_DIR)/h/make/defs.library
endif
# CPUGEN_EXISTS := $(shell [ -x $(BIN_DIR)/cpuGen ] && echo TRUE)
## implicit rules
%.o : %.s $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CC) $(CFLAGS_AS) $(CFLAGS_AS_$(<:.s=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $<
# do not attempt to build dependency on their own.
%.d:
- @ :
# rules to build objects in $(LIBDIR) from sources in $(LIBDIR)
$(LIBDIR)/%.o : $(LIBDIR)/%.c $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CC_WRAPPER) $(CC) $(CFLAGS) $(CC_SDA_FLAGS) $(OPTION_DEPEND_GEN_D) $(CFLAGS_$(<:.c=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $<
%.o : %.c $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CC_WRAPPER) $(CC) $(CFLAGS) $(CC_SDA_FLAGS) $(OPTION_DEPEND_GEN_D) $(CFLAGS_$(<:.c=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $<
define buildrule
# rules to build objects in $(LIBDIR)
$$(LIBDIR_$(1))/%.o : %.c $(TOOL_OPTIONS_FILES_ALL)
@ $$(RM) $$@
$$(CC_WRAPPER) $$(CC) $$(CFLAGS) $$(CFLAGS_LIB_$1) $$(CC_SDA_FLAGS) $$(OPTION_DEPEND_GEN_D) $$(CFLAGS_$$(<:.c=.o)) $$(OPTION_OBJECT_ONLY) $$(OPTION_OBJECT_NAME)$$@ $$<
@(if [ "$(TOOL_FAMILY)" = "gnu" -a "$(VX_CPU_FAMILY)" = "arm" ]; \
then \
$(OBJCPY) -R .ARM.attributes $$@; \
fi)
$$(LIBDIR_$(1))/%.o : %.s $(TOOL_OPTIONS_FILES_ALL)
@ $$(RM) $$@
$$(CC) $$(CFLAGS_AS) $$(CFLAGS_AS_LIB_$1) $$(OPTION_DEPEND_GEN_D) $$(CFLAGS_AS_$$(<:.s=.o)) $$(OPTION_OBJECT_ONLY) $$(OPTION_OBJECT_NAME)$$@ $$<
@(if [ "$(TOOL_FAMILY)" = "gnu" -a "$(VX_CPU_FAMILY)" = "arm" ]; \
then \
$(OBJCPY) -R .ARM.attributes $$@; \
fi)
# rule for munchless C++ compiles
$$(LIBDIR_$(1))/%.o : %.CPP $(TOOL_OPTIONS_FILES_ALL)
@ $$(RM) $$@
$$(CXX) $$(C++FLAGS) $$(C++FLAGS_LIB_$1) $$(OPTION_DEPEND_GEN_D) $$(CFLAGS_$$(<:.cpp=.o)) $$(OPTION_OBJECT_ONLY) $$(OPTION_OBJECT_NAME)$$@ $$<
@(if [ "$(TOOL_FAMILY)" = "gnu" -a "$(VX_CPU_FAMILY)" = "arm" ]; \
then \
$(OBJCPY) -R .ARM.attributes $$@; \
fi)
$$(LIBDIR_$(1))/%.o : %.cpp $(TOOL_OPTIONS_FILES_ALL)
@ $$(RM) $$@
$$(CXX) $$(C++FLAGS) $$(C++FLAGS_LIB_$1) $$(OPTION_DEPEND_GEN_D) $$(CFLAGS_$$(<:.cpp=.o)) $$(OPTION_OBJECT_ONLY) $$(OPTION_OBJECT_NAME)$$@ $$<
@(if [ "$(TOOL_FAMILY)" = "gnu" -a "$(VX_CPU_FAMILY)" = "arm" ]; \
then \
$(OBJCPY) -R .ARM.attributes $$@; \
fi)
endef
$(eval $(foreach base, $(LIB_BASE_NAMES), $(call buildrule,$(base))))
## Rule for standalone "munched" C++ modules.
# In general the only library modules that should be munched are
# standalone test programs. Certainly nothing in the runtime should be
# munched until BSP or Project build time. If you want your
# module to be munched, specify a .out target in $(OBJS) instead
# of a .o.
$(LIBDIR)/%.out : %.CPP $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME) $(basename $@).o $<
@ $(RM) $(LIBDIR)/__$(*F)_ctdt__.c
$(NM) $(basename $@).o | $(MUNCH_DKM) > $(LIBDIR)/__$(*F)_ctdt__.c
$(MAKE) CC_COMPILER=$(OPTION_DOLLAR_SYMBOLS) $(LIBDIR)/__$(*F)_ctdt__.o
$(LD_PARTIAL) $(LD_PARTIAL_LAST_FLAGS) $(OPTION_OBJECT_NAME)$@ $(basename $@).o $(LIBDIR)/__$(*F)_ctdt__.o
@ $(RM) $(basename $@).o $(LIBDIR)/__$(*F)_ctdt__.c $(LIBDIR)/__$(*F)_ctdt__.o $(LIBDIR)/__$(*F)_ctdt__.d
$(LIBDIR)/%.out : %.cpp $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME) $(basename $@).o $<
@ $(RM) $(LIBDIR)/__$(*F)_ctdt__.c
$(NM) $(basename $@).o | $(MUNCH_DKM) > $(LIBDIR)/__$(*F)_ctdt__.c
$(MAKE) CC_COMPILER=$(OPTION_DOLLAR_SYMBOLS) $(LIBDIR)/__$(*F)_ctdt__.o
$(LD_PARTIAL) $(LD_PARTIAL_LAST_FLAGS) $(OPTION_OBJECT_NAME)$@ $(basename $@).o $(LIBDIR)/__$(*F)_ctdt__.o
@ $(RM) $(basename $@).o $(LIBDIR)/__$(*F)_ctdt__.c $(LIBDIR)/__$(*F)_ctdt__.o $(LIBDIR)/__$(*F)_ctdt__.d
# rule for munchless C++ compiles
%.o : %.CPP $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
%.o : %.cpp $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
%.o : %.cxx $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
# C++ compile and munch
%.out : %.CPP $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
@ $(RM) $@ ctdt_$(BUILD_EXT).c
$(NM) $*.o | $(MUNCH_DKM) > ctdt_$(BUILD_EXT).c
$(MAKE) CC_COMPILER=$(OPTION_DOLLAR_SYMBOLS) ctdt_$(BUILD_EXT).o
$(LD_PARTIAL) $(LD_PARTIAL_LAST_FLAGS) $(OPTION_OBJECT_NAME)$@ $*.o ctdt_$(BUILD_EXT).o
@ $(RM) ctdt_$(BUILD_EXT).c ctdt_$(BUILD_EXT).o
%.out : %.cpp $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
@ $(RM) $@ ctdt_$(BUILD_EXT).c
$(NM) $*.o | $(MUNCH_DKM) > ctdt_$(BUILD_EXT).c
$(MAKE) CC_COMPILER=$(OPTION_DOLLAR_SYMBOLS) ctdt_$(BUILD_EXT).o
$(LD_PARTIAL) $(LD_PARTIAL_LAST_FLAGS) $(OPTION_OBJECT_NAME)$@ $*.o ctdt_$(BUILD_EXT).o
@ $(RM) ctdt_$(BUILD_EXT).c ctdt_$(BUILD_EXT).o
%.out : %.cxx $(TOOL_OPTIONS_FILES_ALL)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_OBJECT_ONLY) $<
@ $(RM) $@ ctdt_$(BUILD_EXT).c
$(NM) $*.o | $(MUNCH_DKM) > ctdt_$(BUILD_EXT).c
$(MAKE) CC_COMPILER=$(OPTION_DOLLAR_SYMBOLS) ctdt_$(BUILD_EXT).o
$(LD_PARTIAL) $(LD_PARTIAL_LAST_FLAGS) $(OPTION_OBJECT_NAME)$@ $*.o ctdt_$(BUILD_EXT).o
@ $(RM) ctdt_$(BUILD_EXT).c ctdt_$(BUILD_EXT).o
## rules to build dependencies in $(LIBDIR)
$(LIBDIR)/%.dummy_d : $(WIND_BASE)/target/h/hwif/vxbus/vxbMethodDecl.h %.c $(TOOL_OPTIONS_FILES_ALL)
@ $(MKDIR) $(LIBDIR)
@ $(RM) $@
$(CC) $(CFLAGS) $(OPTION_DEPEND) $(CFLAGS_$(<:.c=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_DEPEND_TARGET)$(@:.dummy_d=.o) $< >$(@:.dummy_d=.d)
$(LIBDIR)/%.dummy_d : %.s $(TOOL_OPTIONS_FILES_ALL)
@ $(MKDIR) $(LIBDIR)
@ $(RM) $@
$(CC) $(CFLAGS_AS) $(OPTION_DEPEND) $(CFLAGS_AS_$(<:.s=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_DEPEND_TARGET)$(@:.dummy_d=.o) $< >$(@:.dummy_d=.d)
$(LIBDIR)/%.dummy_d : %.CPP $(TOOL_OPTIONS_FILES_ALL)
@ $(MKDIR) $(LIBDIR)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_DEPEND) $(CFLAGS_$(<:.cpp=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_DEPEND_TARGET)$(@:.dummy_d=.o) $< >$(@:.dummy_d=.d)
$(LIBDIR)/%.dummy_d : %.cpp $(TOOL_OPTIONS_FILES_ALL)
@ $(MKDIR) $(LIBDIR)
@ $(RM) $@
$(CXX) $(C++FLAGS) $(OPTION_DEPEND) $(CFLAGS_$(<:.cpp=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_DEPEND_TARGET)$(@:.dummy_d=.o) $< >$(@:.dummy_d=.d)
## rules to construct object lists
# vxWorks source distribution do not always have all of the
# sources to object files specified in macro OBJS macro.
# We use GNU make functions to find what we need to build
# get the list of .c, .cpp and .s files
FILE_LIST = $(wildcard *.[cs]) $(wildcard *.cpp) $(wildcard *.CPP) $(INDIRECT_SOURCES)
# Change .c to .o in FILE_LIST and store in TMP_LIST
TMP_LIST = $(FILE_LIST:.c=.o)
# Change .cpp to .o in TMP_LIST and store in TMP1_LIST
TMP1_LIST = $(TMP_LIST:.cpp=.o) $(TMP_LIST:.CPP=.o)
# We can also build .out files from .cpp files
TMP2_LIST = $(subst .cpp,.out,$(filter %.cpp,$(FILE_LIST))) $(subst .CPP,.out,$(filter %.CPP,$(FILE_LIST)))
# Change .s to .o in TMP1_LIST, concat with TMP2_LIST, and store in
# OBJ_PRESENT. These are the objects we can build
OBJ_PRESENT := $(TMP1_LIST:.s=.o) $(TMP2_LIST)
# Find the intersection of the objects we can build and the objects we'd
# like to build
# Normally we just build objects that can be built from source
# files in this directory. However if BUILD_ALL_OBJS is non-empty
# then trust the definition of $(OBJS).
ifneq ($(OBJ_SELECTION),)
OBJS_TO_BUILD = $(filter $(OBJ_SELECTION),$(OBJS))
_cmd = OBJS_TO_BUILD_$(base) = $$(filter $$(OBJ_SELECTION),$$(OBJS_$(base)))
else
ifeq ($(BUILD_ALL_OBJS),)
OBJS_TO_BUILD = $(filter $(OBJ_PRESENT),$(OBJS))
_cmd = OBJS_TO_BUILD_$(base) = $$(filter $$(OBJ_PRESENT),$$(OBJS_$(base)))
else
OBJS_TO_BUILD = $(OBJS)
_cmd = OBJS_TO_BUILD_$(base) = $$(OBJS_$(base))
endif
endif
$(foreach base,$(LIB_BASE_NAMES),$(eval $(_cmd)))
define precompbuildrule
PRECOMP_DIRS += $(PRECOMPDIR_$(1))
$(PRECOMPDIR_$(1))/%.o : %.c $(TOOL_OPTIONS_FILES_ALL) | $(PRECOMPDIR_$(1))
@ $(RM) $$@
$$(CC) $$(CFLAGS) $$(CFLAGS_LIB_$1) $$(CC_SDA_FLAGS) $$(OPTION_DEPEND_GEN_D) $$(CFLAGS_$$(<:.c=.o)) $$(OPTION_OBJECT_ONLY) $$(OPTION_OBJECT_NAME)$$@ $$<
$(PRECOMPDIR_$(1))/%.o : %.s $(TOOL_OPTIONS_FILES_ALL) | $(PRECOMPDIR_$(1))
@ $(RM) $$@
$(CC) $$(CFLAGS_AS) $(OPTION_DEPEND_GEN_D) $(CFLAGS_AS_$(<:.s=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$$@ $$<
# rule for munchless C++ compiles
$(PRECOMPDIR_$(1))/%.o : %.CPP $(TOOL_OPTIONS_FILES_ALL) | $(PRECOMPDIR_$(1))
@ $(RM) $$@
$(CXX) $$(C++FLAGS) $(OPTION_DEPEND_GEN_D) $(CFLAGS_$(<:.cpp=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$$@ $$<
$(PRECOMPDIR_$(1))/%.o : %.cpp $(TOOL_OPTIONS_FILES_ALL) | $(PRECOMPDIR_$(1))
@ $(RM) $$@
$(CXX) $$(C++FLAGS) $(OPTION_DEPEND_GEN_D) $(CFLAGS_$(<:.cpp=.o)) $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$$@ $$<
endef
_DOBASES := $(foreach base,$(LIB_BASE_NAMES),\
$(if $(strip $(OBJS_PRECOMP_$(base))), $(if $(filter $(OBJ_PRESENT), $(OBJS_PRECOMP_$(base))),$(base),),))
$(eval $(foreach base, $(_DOBASES),$(call precompbuildrule,$(base))))
_DOBASES =
# Now we fix up where they will go once they are built
LIBOBJS_FROM_SRC = $(foreach file, $(OBJS_TO_BUILD), $(LIBDIR)/$(file))
LIBOBJS_PRECOMP = $(foreach file, $(OBJS_PRECOMP), $(LIBDIR)/$(file))
LIBOBJS = $(LIBOBJS_FROM_SRC) $(LIBOBJS_PRECOMP)
$(foreach base, $(LIB_BASE_NAMES), $(eval LIBOBJS_PRECOMP_$(base)=$$(foreach obj, $$(OBJS_PRECOMP_$(base)), $$(LIBDIR_$(base))/$$(obj))))
$(foreach base, $(LIB_BASE_NAMES), $(eval OBJ_PRESENT_$(base) = \
$$(filter $$(OBJ_PRESENT),$$(OBJS_$(base)))))
$(foreach base, $(LIB_BASE_NAMES), $(eval LIBOBJS_$(base) = \
$$(foreach obj, $$(OBJS_TO_BUILD_$(base)), $$(LIBDIR_$(base))/$$(obj)) \
$$(LIBOBJS_PRECOMP_$(base)) \
))
LIBOBJS = $(foreach base,$(LIB_BASE_NAMES),$(LIBOBJS_$(base)))
# It is safe to assume that if a subdirectory exists with a Makefile in it
# that we want to build it. If this is not the case one needs to over ride
# this definition in the Makefile for the directory in concern.
# NOTE: to over ride this definition one must define SUBDIRS before the
# include directive for this file (rules.library) in the Makefile
ifeq ($(SUBDIRS),)
ALL_SUBDIRS = $(patsubst %/,%,$(dir $(wildcard */Makefile)))
else
ALL_SUBDIRS = $(SUBDIRS)
endif
SUBDIRS_TMP = $(filter-out $(EXCLUDE_SUBDIRS), $(ALL_SUBDIRS))
override SUBDIRS := $(filter-out $(UNSUPPORTED_SUBDIRS), $(SUBDIRS_TMP))
# architecturedb, and files which are generated from it
# see the files in $(WIND_BASE)/host/src/cpuGen,
# and the comments in architecturedb, for details
# ARCH_DB = $(WIND_BASE)/host/resource/target/architecturedb
# ARCH_FILES = $(TGT_DIR)/src/arch/Makefile $(TGT_DIR)/h/types/vxCpu.h
## Default rule:
# The default rule builds directories recursively starting from the top level
# directory. For every directory, the selected archive is also created and/or
# populated with object files.
# In addition CPU variant build(s) if enabled for the current CPU/TOOL
# combinaison are started at the end of the top level directory build
# (target/src/).
ifeq ($(SKIP_LIB), true)
LIB_DEP =
else
LIB_DEP = lib
endif
ifneq ($(SKIP_DIR), true)
Default: $(LIB_DEP) subdirs
ifneq ($(CPU_VARIANT_MAKE_CMD),)
## Check if we are already in a CPU_VARIANT generated build command line, and
## avoid recursion.
ifneq ($(NO_RECURSE), TRUE)
$(CPU_VARIANT_MAKE_CMD)
endif
endif
ifneq ($(MAKETAIL),)
($(MAKE) -f Makefile CPU=$(CPU) TOOL=$(TOOL) \
$(MAKETAIL) \
MAKETAIL='')
endif
else
Default: subdirs
@echo skipping directory
endif
#######################################
#
# target opath will output a list of object target objects with full path
# the rule is implemented so that there is one file per line
# and no other blank lines or blank characters.
# The output would normally be fed to a linker. The GNU link does not like blanks.
#
%.opath:
@echo $(@:.opath=.o)
opath: $(LIBOBJS:.o=.opath)
opath: $(foreach base,$(LIB_BASE_NAMES),$(LIBOBJS_$(base):.o=.opath))
## recursive clean rule
rclean:
$(RM) $(LOCAL_RCLEAN)
ifneq ($(SUBDIRS),)
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) _WRS_CONFIG_FP=$(_WRS_CONFIG_FP) _WRS_CONFIG_ENDIAN=$(_WRS_CONFIG_ENDIAN) \
TGT_DIR=$(TGT_DIR) TARGET=rclean $(SUBDIRS)
endif
ifeq ($(SKIP_CLEAN),)
ifneq ($(CPU_VARIANT_MAKE_CLEAN),)
## Check if we are already in a CPU_VARIANT generated build command line, and
## avoid recursion.
ifneq ($(NO_RECURSE), TRUE)
$(CPU_VARIANT_MAKE_CLEAN)
endif
endif
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) _WRS_CONFIG_FP=$(_WRS_CONFIG_FP) _WRS_CONFIG_ENDIAN=$(_WRS_CONFIG_ENDIAN) TGT_DIR=$(TGT_DIR) clean
ifeq ($(CLEANLIBS),YES)
$(RM) $(wildcard $(LIB_ROOT)/lib$(CPU)$(TOOL)*.a)
$(RM) $(wildcard $(LIB_ROOT)/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL)/lib*$(OPT).a)
$(RMDIR) $(wildcard $(LIB_ROOT)/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL)/obj*$(OPT))
$(RM) $(wildcard $(LIB_ROOT)/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL_COMMON_DIR)/lib*$(OPT).a)
$(RMDIR) $(wildcard $(LIB_ROOT)/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL_COMMON_DIR)/obj*$(OPT))
$(RMDIR) $(wildcard $(LIB_ROOT)/obj$(CPU)$(TOOL)*)
endif
endif # ifneq ($(SKIP_CLEAN),)
## recursive depend rule
rdepend:
ifneq ($(SUBDIRS),)
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) TGT_DIR=$(TGT_DIR) \
TARGET=rdepend $(SUBDIRS)
endif
ifeq ($(SKIP_CLEAN),)
ifneq ($(CPU_VARIANT_MAKE_DEPEND),)
## Check if we are already in a CPU_VARIANT generated build command line, and
## avoid recursion.
ifneq ($(NO_RECURSE), TRUE)
$(CPU_VARIANT_MAKE_DEPEND)
endif
endif
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) TGT_DIR=$(TGT_DIR) depend
endif # ifneq ($(SKIP_CLEAN),)
# Make sure the object directory exists.
ifneq ($(LIBDIR),$(LIB_ROOT)/)
MAKE_LIBDIR = make_libdir
make_libdir:
-$(MKDIR) $(LIBDIR)
endif
$(LIB_ROOT) :
-$(MKDIR) $@
$(VSB_INCLUDE_DIR) $(VSB_PRIVATE_INCLUDE_DIR) :
-$(MKDIR) $@
ifneq ($(MK_VXBMETHODDECL),TRUE)
$(WIND_BASE)/target/h/hwif/vxbus/vxbMethodDecl.h:
$(MAKE) -C $(WIND_BASE)/target/src/hwif/methods $(WIND_BASE)/target/h/hwif/vxbus/vxbMethodDecl.h
endif
.PHONY: make_hwif hwifclean
MAKE_HWIF = make_hwif
make_hwif: $(WIND_BASE)/target/h/hwif/vxbus/vxbMethodDecl.h
hwifclean:
$(RM) $(WIND_BASE)/target/h/hwif/vxbus/vxbMethodDecl.h
define libdirrule
$$(LIBDIR_$(1)) :
$$(MKDIR) $$@
$$(PRECOMPDIR_$(1)) :
$$(MKDIR) $$@
endef
$(eval $(foreach base, $(LIB_BASE_NAMES), $(call libdirrule,$(base))))
#
# This section generates explicit rules to map the precomp objs.
#
define precompdep
$(LIBDIR_$(1))/$(2) : $(PRECOMPDIR_$(1))/$(2)
$(CP) $$< $$@
chmod +w $$@
endef
$(eval $(foreach base, $(LIB_BASE_NAMES), $(foreach file, $(OBJS_PRECOMP_$(base)), $(call precompdep,$(base),$(file)))))
# recursive build of all objects. The hope is that this rule will help
# with parallel builds. Calling lib and subdirs with parallel builds
# has the adverse effect of trying to create libraries from multiple
# subdirectories that tends to destroy the library.
all-objs : objs
ifneq ($(SUBDIRS),)
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) TGT_DIR=$(TGT_DIR) \
TARGET=all-objs $(SUBDIRS)
endif
# Just in case you want to build objects and not update the archives
objs: $(MAKE_HWIF) $(MAKE_LIBDIR) $(LIBOBJS)
preobjs: $(MAKE_HWIF) $(MAKE_LIBDIR)
objsonly: $(LIBOBJS)
precomp: TARGET=precomp
precomp: RECURSE_TARGET=precomp
precomp: | $(sort $(foreach base, $(LIB_BASE_NAMES),$(foreach file, $(OBJS_PRECOMP_$(base)), $(PRECOMPDIR_$(base)))))
precomp: $(foreach base, $(LIB_BASE_NAMES), $(foreach obj, $(OBJS_PRECOMP_$(base)), $(PRECOMPDIR_$(base))/$(obj))) $(SUBDIRS)
ifdef CPU_VARIANT_MAKE_CMD
ifneq ($(NO_RECURSE), TRUE)
$(CPU_VARIANT_MAKE_CMD)
endif
endif
release:
$(MAKE) CPU=$(CPU) TOOL=$(TOOL) TGT_DIR=$(TGT_DIR) \
TARGET=release
# Files which are generated from the architecturedb
# archdeps: $(ARCH_FILES)
# ifeq ($(CPUGEN_EXISTS),TRUE)
# $(TGT_DIR)/h/types/vxCpu.h: $(TGT_DIR)/h/types/vxCpu.in $(ARCH_DB)
# cpuGen -t -i $< -o $@
#
# $(TGT_DIR)/src/arch/Makefile: $(TGT_DIR)/src/arch/Makefile.in $(ARCH_DB)
# cpuGen -m -i $< -o $@
# endif
ifeq ($(wildcard $(VSB_CONFIG_DIR)),)
$(VSB_CONFIG_FILE) : $(VSB_CONFIG_DIR)
$(VSB_CONFIG_DIR) :
$(MKDIR) $@
endif
# VSB configuration file
# this file is a wrapper, and has no dependencies
vsbconfig : $(VSB_CONFIG_FILE)
$(VSB_CONFIG_FILE) :
@echo "/* this file is automatically generated */" > $@
@echo "/* Do not edit */" >> $@
@echo >> $@
@echo "#if defined _WRS_AUTOCONF_INCLUDED || defined AUTOCONF_INCLUDED" >> $@
@echo "#else" >> $@
@echo "#include \"autoconf.h\"" >> $@
@echo "#endif" >> $@
@echo >> $@
@echo "#ifndef __vsbConfig_INCLUDED" >> $@
@echo "#define __vsbConfig_INCLUDED" >> $@
@echo >> $@
@echo "/* this is a temporary wrapper " >> $@
@echo " * defined to ease transition to " >> $@
@echo " * new coding convention" >> $@
@echo " *" >> $@
@echo " * PLEASE DO NOT USE THE VARIABLE" >> $@
@echo " * _WRS_VX_SMP" >> $@
@echo " * IN SOURCE CODE" >> $@
@echo " * PLEASE USE" >> $@
@echo " * _WRS_CONFIG_SMP" >> $@
@echo " * INSTEAD" >> $@
@echo " */" >> $@
@echo "#ifdef _WRS_CONFIG_SMP" >> $@
@echo "#ifndef _WRS_VX_SMP" >> $@
@echo "#define _WRS_VX_SMP _WRS_CONFIG_SMP" >> $@
@echo "#endif /* _WRS_VX_SMP */" >> $@
@echo "#endif /* _WRS_CONFIG_SMP */" >> $@
@echo >> $@
@echo "/* this is a temporary wrapper " >> $@
@echo " * defined to ease transition to " >> $@
@echo " * new coding convention" >> $@
@echo " *" >> $@
@echo " * PLEASE DO NOT USE THE VARIABLE" >> $@
@echo " * WV_INSTRUMENTATION" >> $@
@echo " * IN SOURCE CODE" >> $@
@echo " * PLEASE USE" >> $@
@echo " * _WRS_CONFIG_SV_INSTRUMENTATION" >> $@
@echo " * INSTEAD" >> $@
@echo " */" >> $@
@echo "#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_POSIX_AEP_RT_CONTROLLER_C_SOURCE)" >> $@
@echo "#ifdef _WRS_CONFIG_SV_INSTRUMENTATION" >> $@
@echo "#ifndef WV_INSTRUMENTATION" >> $@
@echo "#define WV_INSTRUMENTATION _WRS_CONFIG_SV_INSTRUMENTATION" >> $@
@echo "#endif /* WV_INSTRUMENTATION */" >> $@
@echo "#endif /* _WRS_CONFIG_SV_INSTRUMENTATION */" >> $@
@echo "#endif /* _POSIX_xxx_SOURCE */" >> $@
@echo >> $@
@echo "#endif" >> $@
# Files that are generated from syscallNum.def, syscallApi.def etc.
# These rules are provided primarily for released products where syscallXP*.def
# and syscallUsr*.def may not be shipped by Wind River. These dummy rules will
# create a zero-length file so that make should not fail due to missing
# dependencies. The intent here is for scgen to parse syscallXPNum.def,
# syscallXPApi.def, syscallUsrNum.def and syscallUsrApi.def only if they exist.
# $(TGT_DIR)/share/h/syscallXPNum.def:
# touch $@
# $ (TGT_DIR)/share/h/syscallXPApi.def:
# touch $@
# $(TGT_DIR)/share/h/syscallUsrNum.def:
# touch $@
# $(TGT_DIR)/share/h/syscallUsrApi.def:
# touch $@
# $(TGT_DIR)/h/syscall.h: $(TGT_DIR)/share/h/syscallNum.def \
# $(TGT_DIR)/share/h/syscallXPNum.def \
# $(TGT_DIR)/share/h/syscallUsrNum.def
# scgen -h
#
# $(TGT_DIR)/h/arch/$(ARCH_DIR)/syscallArgs$(ABI_SPEC).h: \
# $(TGT_DIR)/share/h/syscallApi.def \
# $(TGT_DIR)/share/h/syscallXPApi.def \
# $(TGT_DIR)/share/h/syscallUsrApi.def
# scgen -A $(ABI_SPEC) $(CPU) $(ARCH_DIR) $(TOOL)
#
# $(TGT_DIR)/h/syscallTbl.h: $(TGT_DIR)/share/h/syscallNum.def \
# $(TGT_DIR)/share/h/syscallXPNum.def \
# $(TGT_DIR)/share/h/syscallUsrNum.def \
# $(TGT_DIR)/share/h/syscallApi.def \
# $(TGT_DIR)/share/h/syscallXPApi.def \
# $(TGT_DIR)/share/h/syscallUsrApi.def
# scgen -t
#
include $(TGT_DIR)/h/make/rules-lib.$(WIND_HOST_TYPE)
include $(TGT_DIR)/h/make/defs.base.mk
# optional rules
ifneq ($(wildcard $(TGT_DIR)/h/make/rules.library.option.*.mk),)
-include $(wildcard $(TGT_DIR)/h/make/rules.library.option.*.mk)
endif
# we don't need a dependency list if are not building objects
# or for "make man"
ifeq (, $(findstring clean, $(MAKECMDGOALS)))
ifeq (, $(findstring clean, $(TARGET)))
ifneq ($(MAKECMDGOALS), man)
# We suppress the warning message about non existent file and setting of errno
# by prepending - . GNU make allows this.
LIBOBJS_NODEP = $(foreach file, $(NODEPENDOBJS), $(LIBDIR)/$(file))
DEP_OBJS = $(filter-out $(LIBOBJS_NODEP), $(LIBOBJS))
EXISTING_OBJS = $(foreach obj, $(DEP_OBJS), $(wildcard $(obj)))
DEP_FILES = $(filter %.d , $(EXISTING_OBJS:.o=.d))
EXISTING_DEP_FILES = $(foreach obj, $(DEP_FILES), $(wildcard $(obj)))
MISSING_DEP = $(filter-out $(EXISTING_DEP_FILES), $(DEP_FILES))
ifneq ($(strip $(MISSING_DEP)),)
$(warning warning: missing dependency files $(MISSING_DEP))
$(warning run make depend to regenerate)
endif
ifneq ($(strip $(EXISTING_DEP_FILES)),)
include $(EXISTING_DEP_FILES)
endif
endif
endif
endif