Ignore:
Timestamp:
Dec 15, 2006, 6:18:47 AM (19 years ago)
Author:
bird
Message:

Partial implementation of a _PATH target property for resolving relative paths. It's primarily intended for sub-makefile mode where we apply it to all targets automatically. TODOs: INCS, DEPs (source level) and SUBDIRS*.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r723 r725  
    185185no-root-slash=$(patsubst /%,%,$(1))
    186186
     187ifneq ($(filter abspathex,$(KMK_FEATURES)),abspathex) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
     188## Converts an relative path to an absolute path using the given CWD.
     189# @returns absolute path.
     190# @param    $1      The path to fixup.
     191# @param    $2      The CWD to use.
     192abspathex = $(foreach _fix_path,$1\
     193,$(if $(subst :$(call no-root-slash,$(call no-drive,$(_fix_path))):,,:$(_fix_path):),$(_fix_path),$(abspath $2/$(_fix_path))))
     194endif
     195
    187196## Figure out where to put object files.
    188197# @param    $1      source file
     
    11271136## Generic macro for processing all target sources.
    11281137# @param    $(target)   Normalized target name.
     1138# @param    $(defpath)
     1139# @param    much-more...
    11291140define def_target_sources
     1141
     1142# Apply any default path on the sources first.
     1143ifneq ($(defpath),)
     1144 ifdef $(target)_SOURCES
     1145  $(target)_SOURCES := $(call abspathex,$($(target)_SOURCES),$(defpath))
     1146 endif
     1147 ifdef $(target)_SOURCES.$(bld_trg)
     1148  $(target)_SOURCES.$(bld_trg) := $(call abspathex,$($(target)_SOURCES.$(bld_trg)),$(defpath))
     1149 endif
     1150 ifdef $(target)_SOURCES.$(bld_trg).$(bld_trg_arch)
     1151  $(target)_SOURCES.$(bld_trg).$(bld_trg_arch) := $(call abspathex,$($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),$(defpath))
     1152 endif
     1153 ifdef $(target)_SOURCES.$(bld_trg_arch)
     1154  $(target)_SOURCES.$(bld_trg_arch) := $(call abspathex,$($(target)_SOURCES.$(bld_trg_arch)),$(defpath))
     1155 endif
     1156 ifdef $(target)_SOURCES.$(bld_trg_cpu)
     1157  $(target)_SOURCES.$(bld_trg_cpu) := $(call abspathex,$($(target)_SOURCES.$(bld_trg_cpu)),$(defpath))
     1158 endif
     1159 ifdef $(target)_SOURCES.$(bld_type)
     1160  $(target)_SOURCES.$(bld_type) := $(call abspathex,$($(target)_SOURCES.$(bld_type)),$(defpath))
     1161 endif
     1162endif
     1163
    11301164#$ (warning def_target_sources)
    11311165# C sources
     
    12171251TARGET_$(target) := $(out)
    12181252$(target)_OBJS_ :=
     1253defpath := $($(target)_PATH)
    12191254
    12201255# source -> object
     
    12541289deps        := $($(target)_DEPS)
    12551290
     1291# Adjust paths if we got a default path.
     1292ifneq ($(defpath),)
     1293 objs := $(call abspathex,$(objs),$(defpath))
     1294 deps := $(call abspathex,$(deps),$(defpath))
     1295endif
     1296
    12561297# dependency file
    12571298dep := $(out)$(SUFF_DEP)
     
    13281369TARGET_$(target) := $(out)
    13291370$(target)_OBJS_  :=
     1371defpath := $($(target)_PATH)
    13301372
    13311373# source -> object
     
    14551497deps        := $($(target)_DEPS)
    14561498
     1499# Adjust paths if we got a default path.
     1500ifneq ($(defpath),)
     1501 libpath := $(call abspathex,$(libpath)def $(target)_PATH)
     1502 objs := $(call abspathex,$(objs),$(defpath))
     1503 deps := $(call abspathex,$(deps),$(defpath))
     1504 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
     1505endif
     1506
    14571507## @todo this stuff can't be working.
    14581508custom_pre  := $(strip $(firstword \
     
    16621712# _INSTFUN
    16631713ifdef $(srcsrc)_INSTFUN
    1664 instfun := $(srcsrc)_INSTFUN
     1714 instfun := $(srcsrc)_INSTFUN
    16651715else
    1666 ifdef $(target)_INSTFUN
    1667 instfun := $(target)_INSTFUN
    1668 else
    1669 instfun := _INSTALL_FILE
    1670 endif
     1716 ifdef $(target)_INSTFUN
     1717  instfun := $(target)_INSTFUN
     1718 else
     1719  instfun := _INSTALL_FILE
     1720 endif
    16711721endif
    16721722
    16731723# _INST
    16741724ifdef $(srcsrc)_INST
    1675 inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
     1725 inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
    16761726else
    1677 ifdef $(target)_INST
    1678 inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
    1679 else
    1680 inst := $(dir $(srcdstdir))
    1681 endif
     1727 ifdef $(target)_INST
     1728  inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
     1729 else
     1730  inst := $(dir $(srcdstdir))
     1731 endif
    16821732endif
    16831733
     
    17361786        $($(target)_GID))
    17371787
     1788
     1789# Adjust the source if we got a default PATH. (This must be done this late!)
     1790ifdef $(target)_PATH
     1791 srcsrc := $(call abspathex,$(srcsrc),$($(target)_PATH))
     1792endif
     1793
    17381794# create the command
    17391795ifdef $(srcsrc)_INSTALLER
    1740 inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
     1796 inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
    17411797else
    1742 ifdef $(target)_INSTALLER
    1743 inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
    1744 else
    1745 inscmd := $$(INSTALL)\
     1798 ifdef $(target)_INSTALLER
     1799  inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
     1800 else
     1801  inscmd := $$(INSTALL)\
    17461802                $(if $(uid),-o $(uid))\
    17471803                $(if $(gid),-g $(gid))\
    17481804                $(if $(mode),-m $(mode))\
    17491805                $(srcsrc) $(insdst)
    1750 endif
     1806 endif
    17511807endif
    17521808
     
    17881844# _INST
    17891845ifdef $(symlnk)_INST
    1790 inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
     1846 inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
    17911847else
    1792 ifdef $(target)_INST
    1793 inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
    1794 else
    1795 inst := $(dir $(symlnk))
    1796 endif
     1848 ifdef $(target)_INST
     1849  inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
     1850 else
     1851  inst := $(dir $(symlnk))
     1852 endif
    17971853endif
    17981854
     
    18281884# _INST
    18291885ifdef $(directory)_INST
    1830 inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
     1886 inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
    18311887else
    1832 ifdef $(target)_INST
    1833 inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
    1834 else
    1835 inst := $(PATH_INS)
    1836 endif
     1888 ifdef $(target)_INST
     1889  inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
     1890 else
     1891  inst := $(PATH_INS)
     1892 endif
    18371893endif
    18381894
     
    21422198endif # __footer_kmk__
    21432199
     2200
Note: See TracChangeset for help on using the changeset viewer.