Changeset 743


Ignore:
Timestamp:
Dec 17, 2006, 9:12:30 AM (19 years ago)
Author:
bird
Message:

set PATH_target early (i.e. in subheader/subfooter).

Location:
trunk/kBuild
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r741 r743  
    143143        $(TOOL) \
    144144        ))
    145 
    146 ## Removes the drive letter from a path (if it has one)
    147 # @param        $1              the path
    148 no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
    149 
    150 ## Removes the root slash from a path (if it has one)
    151 # @param        $1              the path
    152 no-root-slash=$(patsubst /%,%,$(1))
    153 
    154 ifneq ($(filter abspathex,$(KMK_FEATURES)),abspathex) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
    155 ## Converts an relative path to an absolute path using the given CWD.
    156 # @returns absolute path.
    157 # @param    $1      The path to fixup.
    158 # @param    $2      The CWD to use.
    159 abspathex = $(foreach _fix_path,$1\
    160 ,$(if $(subst :$(call no-root-slash,$(call no-drive,$(_fix_path))):,,:$(_fix_path):),$(_fix_path),$(abspath $2/$(_fix_path))))
    161 endif
    162 
    163 ## Figure out where to put object files.
    164 # @param    $1      real target name.
    165 # @param    $2      normalized main target
    166 _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
    167 
    168145
    169146## Figure out the actual name of an installed file.
     
    887864$(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
    888865        $$(QUIET)$$(RM) -f $$@
    889         $$(call MSG_L1,$$(if $$(wildcard $(out).lst),$$(if $$(_TARGET_$(target)_DIGEST),Re-fetching,Removing),Fetching) $(target)...)
     866        $$(call MSG_L1,$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst),Re-fetching,Fetching),Removing) $(target)...)
    890867        $$(QUIET)$$(if $$(wildcard $(out).lst      ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
    891868        $$(QUIET)$$(if  $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@))
     
    11721149$(error kBuild: Library target $(target) does not have a tool defined!)
    11731150endif
    1174 outbase     := $(call _TARGET_BASE,$(target),$(target))
    1175 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
     1151outbase     := $(call TARGET_BASE,$(target),$(target))
     1152ifndef PATH_$(target)
     1153 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
     1154else
     1155 ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
     1156  $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
     1157 endif
     1158endif
    11761159suff        := $(firstword\
    11771160        $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
     
    11921175# library linking
    11931176tool        := $(call _TARGET_TOOL,$(target),AR)
    1194 outbase     := $(call _TARGET_BASE,$(target),$(target))
     1177outbase     := $(call TARGET_BASE,$(target),$(target))
    11951178flags       :=\
    11961179        $(TOOL_$(tool)_ARFLAGS)\
     
    12941277
    12951278tool        := $(call _TARGET_TOOL,$(target),LD)
    1296 outbase     := $(call _TARGET_BASE,$(target),$(target))
     1279outbase     := $(call TARGET_BASE,$(target),$(target))
     1280ifndef PATH_$(target)
     1281 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
     1282else
     1283 ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
     1284  $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
     1285 endif
     1286endif
    12971287suff        := $(firstword \
    12981288        $($(target)_$(EXT)SUFF) \
     
    13011291        $($(EXTPRE)SUFF_$(EXT)))
    13021292out         := $(outbase)$(suff)
    1303 PATH_$(target)   := $(patsubst %/,%,$(dir $(outbase)))
    13041293TARGET_$(target) := $(out)
    13051294$(target)_OBJS_  :=
     
    13111300# more library stuff.
    13121301tool        := $(call _TARGET_TOOL,$(target),LD)
    1313 outbase     := $(call _TARGET_BASE,$(target),$(target))
     1302outbase     := $(call TARGET_BASE,$(target),$(target))
    13141303flags       :=\
    13151304        $(TOOL_$(tool)_LDFLAGS)\
  • trunk/kBuild/gnumake-header.kmk

    r723 r743  
    3333$(warning kBuild: Using vanilla GNU make isn't safe for anything but kBuild bootstrapping!)
    3434
     35##
     36# Pushes an item onto a 'stack' variable.
     37# @param    $1   The stack variable name
     38# @param    $2   What to push.
     39stack-push = $(eval $1 +=$2)
     40
     41##
     42# Removes the top element from a 'stack' variable.
     43# @returns  The popped element
     44# @param    $1   The stack variable name
     45stack-pop  = $(call stack-top,$1)$(call stack-popv,$1)
     46
     47##
     48# Removes the top element from a 'stack' variable.
     49# This does *NOT* return the top element, use
     50# @param    $1   The stack variable name
     51# @remark This ain't very fast (that's why it's implemented in functions.c in kmk).
     52stack-popv = $(eval $1:=$(wordlist 1,$(words $(wordlist 2,9999,$($1))),$($1)))
     53
     54##
     55# Retrieves the top element from the 'stack' variable.
     56# @param    $1   The stack variable name
     57stack-top  = $(lastword $($1))
     58
    3559
    3660#
    37 # Default variables.
     61# Fix some default variables.
    3862#
    3963ifeq ($(MAKEFLAGS),$(MAKEFLAGS:R=x))
     
    5478
    5579#
    56 # Suffixes.
     80# Zap suffixes.
    5781#
    5882.SUFFIXES:
     
    6084
    6185#
    62 # Implicit rules
     86# Zap implicit rules
    6387#
    6488ifeq ($(MAKEFLAGS),$(MAKEFLAGS:r=x))
  • trunk/kBuild/header.kmk

    r742 r743  
    441441LN_SYMLINK  := $(LN) -s
    442442
     443
     444#
     445# Some Functions.
     446# The lower cased ones are either fallbacks or candidates for functions.c.
     447#
     448
    443449## ABSPATH - make paths absolute.
    444450# This implementation is clumsy and doesn't resolve '..' and '.' components.
     
    453459DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
    454460
    455 
    456461## Cygwin kludge.
    457462# This converts /cygdrive/x/% to x:%.
     
    460465# @remark       This macro is pretty much obsolete since we don't use cygwin base make.
    461466ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
    462 CYGPATHMIXED = $(foreach path,$(1)\
     467 CYGPATHMIXED = $(foreach path,$(1)\
    463468   ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
    464469else
    465 CYGPATHMIXED = $(1)
    466 endif
    467 
    468 
    469 ifneq ($(filter stack,$(KMK_FEATURES)),stack) ## @todo retire this to gnumake-header.kmk when all the programs have been recompiled.
    470 ##
    471 # Pushes an item onto a 'stack' variable.
    472 # @param    $1   The stack variable name
    473 # @param    $2   What to push.
    474 stack-push = $(eval $1 +=$2)
    475 
    476 ##
    477 # Removes the top element from a 'stack' variable.
    478 # @returns  The popped element
    479 # @param    $1   The stack variable name
    480 stack-pop  = $(call stack-top,$1)$(call stack-popv,$1)
    481 
    482 ##
    483 # Removes the top element from a 'stack' variable.
    484 # This does *NOT* return the top element, use
    485 # @param    $1   The stack variable name
    486 # @remark This ain't very fast (that's why it's implemented in functions.c in kmk).
    487 stack-popv = $(eval $1:=$(wordlist 1,$(words $(wordlist 2,9999,$($1))),$($1)))
    488 
    489 ##
    490 # Retrieves the top element from the 'stack' variable.
    491 # @param    $1   The stack variable name
    492 stack-top  = $(lastword $($1))
    493 endif
     470 CYGPATHMIXED = $(1)
     471endif
     472
     473ifneq ($(filter abspathex,$(KMK_FEATURES)),abspathex) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
     474## Converts an relative path to an absolute path using the given CWD.
     475# @returns absolute path.
     476# @param    $1      The path to fixup.
     477# @param    $2      The CWD to use.
     478abspathex = $(foreach _fix_path,$1\
     479,$(if $(subst :$(call no-root-slash,$(call no-drive,$(_fix_path))):,,:$(_fix_path):),$(_fix_path),$(abspath $2/$(_fix_path))))
     480endif
     481
     482## Removes the drive letter from a path (if it has one)
     483# @param        $1              the path
     484no-drive    = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
     485
     486## Removes the root slash from a path (if it has one)
     487# @param        $1              the path
     488no-root-slash = $(patsubst /%,%,$(1))
     489
     490## Figure out where to put object files.
     491# @param    $1      real target name.
     492# @param    $2      normalized main target
     493TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
     494
     495## Figure out where to put object files.
     496# @param    $1      normalized main target
     497TARGET_PATH = $(PATH_TARGET)/$(1)
    494498
    495499
  • trunk/kBuild/subfooter.kmk

    r742 r743  
    2929#
    3030ifdef __footer_kmk__
    31 $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!)
     31 $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!)
    3232endif
    3333
     
    3636#
    3737define def_subheader
    38 ifndef $(target)_PATH
    39 $(target)_PATH := $(PATH_SUB_CURRENT)
    40 endif
    41 ifndef $(target)_MAKEFILE
    42 $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
    43 endif
     38 ifndef $(target)_PATH
     39  $(target)_PATH := $(PATH_SUB_CURRENT)
     40 endif
     41 ifndef $(target)_MAKEFILE
     42  $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
     43 endif
     44 ifndef PATH_$(target)
     45  PATH_$(target) := $(call TARGET_PATH,$(target))
     46 endif
    4447endef
    4548
  • trunk/kBuild/subheader.kmk

    r742 r743  
    4646 #
    4747 define def_subfooter
    48  ifndef $(target)_PATH
    49  $(target)_PATH := $(PATH_SUB_CURRENT)
    50  endif
    51  ifndef $(target)_MAKEFILE
    52  $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
    53  endif
     48  ifndef $(target)_PATH
     49   $(target)_PATH := $(PATH_SUB_CURRENT)
     50  endif
     51  ifndef $(target)_MAKEFILE
     52   $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
     53  endif
     54  ifndef PATH_$(target)
     55   PATH_$(target) := $(call TARGET_PATH,$(target))
     56  endif
    5457 endef
    5558
Note: See TracChangeset for help on using the changeset viewer.