Changeset 73 for trunk/kBuild/footer.kmk


Ignore:
Timestamp:
May 31, 2004, 3:11:52 AM (21 years ago)
Author:
bird
Message:

...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r72 r73  
    3030#
    3131# Variables.
     32# (Some of these need initialization before including definitions using them.)
    3233#
    3334
     
    4748endef
    4849$(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
     50
     51# misc
     52type :=
     53
     54
     55#
     56# Basic macros
     57#
     58
     59## Figure out the tool for a source
     60# @param    $1      source file
     61# @param    $2      normalized main target
     62_SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL) )
     63
     64## Figure out where to put object files.
     65# @param    $1      source file
     66# @param    $2      normalized main target
     67_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
     68
     69## Figure out where to put object files.
     70# @param    $1      real target name.
     71# @param    $2      normalized main target
     72_TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
     73
    4974
    5075#
     
    154179#
    155180# Include SDKs
    156 #                       
     181#
    157182_SDKS := $(SDKS)
    158183define def_sdks_target_source
     
    175200$(foreach sdk, $(_SDKS), $(eval $(def_sdk)))
    176201
     202#
     203# Object processing.
     204#
     205
     206## Generic macro for processing C, C++ and Assembly sources.
     207# @param    $(target)     Normalized target name.
     208# @param    $(source)     Source file name.
     209# @param    $(type)       Source type. {C,CXX,AS}
     210#
     211# @remark   I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
     212define def_target_source_c_cpp_asm
     213#$ (warning dbg: def_target_source_c_cpp_asm: source=$(source) target=$(target) type=$(type))
     214
     215$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target)))
     216$(eval defs        :=\
     217        $($(target)_$(source)_$(type)DEFS)\
     218        $($(target)_$(source)_DEFS)\
     219        $($(source)_$(type)DEFS)\
     220        $($(source)_DEFS)\
     221        $($(target)_$(type)DEFS)\
     222        $($(target)_DEFS)\
     223        $(DEFS)\
     224        $(TOOL_$(tool)_$(type)DEFS)\
     225        )
     226$(eval incs        :=\
     227        $($(target)_$(source)_$(type)INCS)\
     228        $($(target)_$(source)_INCS)\
     229        $($(source)_$(type)INCS)\
     230        $($(source)_INCS)\
     231        $($(target)_$(type)INCS)\
     232        $($(target)_INCS)\
     233        $(INCS)\
     234        $(TOOL_$(tool)_$(type)INCS)\
     235        )
     236$(eval flags        :=\
     237        $(TOOL_$(tool)_$(type)FLAGS)\
     238        $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
     239        $($(type)FLAGS)\
     240        $($(type)FLAGS.$(BUILD_TYPE))\
     241        $($(target)_$(type)FLAGS)\
     242        $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
     243        $($(source)_$(type)FLAGS)\
     244        $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
     245        $($(target)_$(source)_$(type)FLAGS)\
     246        $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
     247        )
     248$(eval outbase     := $(call _OBJECT_BASE,$(source),$(target)))
     249$(eval dirdep      := $(dir $(outbase)).dir_created)
     250$(eval objsuff     := $(firstword $($(target)_$(source)_OBJSUFF) $($(source)_OBJSUFF) $($(target)_OBJSUFF) $(TOOL_$(tool)_$(type)OBJSUFF) $(SUFF_OBJ)))
     251$(eval obj         := $(outbase)$(objsuff))
     252$(eval depfile     := $(outbase)$(SUFF_DEP))
     253
     254#$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
     255$(eval $(TOOL_$(tool)_COMPILE_$(type)))
     256
     257$(eval _OBJS_$(target) += $(obj))
     258$(eval _DEPFILES       += $(dep))
     259
     260endef
     261
     262## Generic macro for processing all target sources.
     263# @param    $target     Normalized target name.
     264define def_target_sources
     265#$ (warning def_target_sources)
     266# C sources
     267$(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES))\
     268        ,$(eval $(def_target_source_c_cpp_asm)) ))
     269
     270# C++ sources
     271$(foreach type,CXX,$(foreach source, $(filter %.cpp, $($(target)_SOURCES)) $(filter %.cxx, $($(target)_SOURCES)) $(filter %.cc, $($(target)_SOURCES))\
     272        ,$(eval $(def_target_source_c_cpp_asm)) ))
     273
     274# ASM sources
     275$(foreach type,AS,$(foreach source, $(filter %.asm, $($(target)_SOURCES)) $(filter %.s, $($(target)_SOURCES)) $(filter %.S, $($(target)_SOURCES))\
     276        ,$(eval $(def_target_source_c_cpp_asm)) ))
     277endef
     278
    177279
    178280#
    179281# LIBRARIES
    180 #               
    181 
    182 ## Figure out the tool for a source
    183 # @param    $1      source file
    184 # @param    $2      normalized main target
    185 _SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL))
    186 ## Figure out where to put object files.
    187 # @param    $1      source file
    188 # @param    $2      normalized main target
    189 _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $1)
    190        
     282#
     283
    191284## Library (one).
    192285# @param    $(lib)  Library name
    193286define def_lib
    194 #$ (warning dbg: Processing library $(target))
    195 
    196 # C++ sources
    197 #$(foreach o, $(filter %.cpp,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
    198 #$(foreach o, $(filter %.cxx,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
    199 #$(foreach o, $(filter %.cc, $($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
    200 
    201 # C sources
    202 $(foreach source, $(filter %.c, $($(target)_SOURCES)), \
    203         $(eval $(call TOOL_$(call _SOURCE_TOOL,$(source),$(target))_COMPILE_C,$(call _OBJECT_BASE,$(source),$(target)),$(source),$(target)) ) )
    204 
    205 ## ASM sources
    206 #$(foreach o, $(filter %.asm,$($1_SOURCES)), $(eval $(call def_lib_asm,$1,$o)))
    207                                                
     287# source -> object
     288$(eval $(def_target_sources))
     289
    208290# library
    209 #$$(PATH_TARGET)/$1$(SUFF_LIB): \
    210 #               $$(PATH_TARGET) \
    211 #               $$(_OBJS_$1)
    212 #       $$(AR) $($1_ARFLAGS) $(ARFLAGS) $(AROUT)$$(@:/=\) $$(_OBJS_$1)
    213 #
    214 _OBJS += $(_OBJS_$(target))             
    215 _LIBS += $(PATH_TARGET)/$1$(SUFF_LIB)
     291$(eval tool        := $(firstword $($(target)_TOOL) $(TOOL)))
     292$(eval flags       := $($(target)_ARFLAGS) $(ARFLAGS) $(TOOL_$(tool)_ARFLAGS))
     293$(eval libsuff     := $(firstword $($(target)_LIBSUFF) $($(target)_LIBSUFF) $(TOOL_$(tool)_ARLIBSUFF) $(SUFF_LIB)))
     294## @todo prefix
     295$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
     296$(eval lib         := $(outbase)$(libsuff))
     297$(eval objs         = $(_OBJS_$(target)))
     298$(eval dirdep      := $(dir $(lib)).dir_created)
     299## @todo fix dependencies
     300$(eval deps        := )
     301
     302$(eval $(TOOL_$(tool)_LINK_LIBRARY))
     303
     304_OBJS += $(_OBJS_$(target))
     305_LIBS += $(lib)
    216306endef
    217307
     
    257347define def_createdir
    258348$(dirfile):
     349        $(call MSG_L1,Creating directory $$(@D))
    259350        $(MKDIR) -p $$(@D)
    260         echo dir_created > $$@
     351        @echo dir_created > $$@
    261352endef
    262353
     
    270361
    271362objs: $(_OBJS)
     363        echo "dbg: _OBJS = $(_OBJS)"
     364
     365libs: $(_LIBS)
     366        echo "dbg: _LIBS = $(_LIBS)"
    272367
    273368
Note: See TracChangeset for help on using the changeset viewer.