Rev 257 | Rev 321 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: mak; tabs: 8; -*-################################################################################ Compat for older (embedded) makefiles###############################################################################SCM_ROOT = $(GBE_ROOT)SCM_TYPE = $(GBE_TYPE)SCM_BIN = $(GBE_BIN)SCM_PLATFORM = $(GBE_PLATFORM)################################################################################# Common definitions extracted from OPTIONS###############################################################################CC_PRE := @XX_PRE := @AA_PRE := @SHOWARGS := NONEUSE_FILTER := 1LEAVETMP :=SHOWENV :=ifdef OPTIONSifneq "$(findstring args,$(OPTIONS))" "" # Show arguments (default)CC_PRE :=XX_PRE :=SHOWARGS := ARGSendififneq "$(findstring noargs,$(OPTIONS))" "" # Show no argumentsCC_PRE := @XX_PRE := @SHOWARGS := NONEendififneq "$(findstring allargs,$(OPTIONS))" "" # Show ALL argumentsAA_PRE :=SHOWARGS := ALLendififneq "$(findstring filter,$(OPTIONS))" "" # Use filter (Default)USE_FILTER := 1endififneq "$(findstring nofilter,$(OPTIONS))" "" # Don't use filterUSE_FILTER :=endififneq "$(findstring leavetmp,$(OPTIONS))" "" # Leave temp filesLEAVETMP := 1endififneq "$(findstring noleavetmp,$(OPTIONS))" "" # Don't leave temp files (Default)LEAVETMP :=endififneq "$(findstring showenv,$(OPTIONS))" "" # Display env before commandsSHOWENV := 1endififneq "$(findstring noshowenv,$(OPTIONS))" "" # Don't display env before commandsSHOWENV :=endifendif################################################################################# Brain hurts stuff... $(space) becomes a macro containing 1 space# other aren't so bad. These are used to make argument lists is a few# places where we have to translate from a space seperated list to a# something else seperated list (or vicky verka).################################################################################comma := ,plus := +semicolon := ;empty :=space := $(empty) $(empty)spacealt := %20################################################################################# A little macro used within each of the rules for translating a file from# one type to another to print the environment if the variable SHOWENV has# been defined.################################################################################ifdef SHOWENVdefine show_environment$(printenv)endefelsedefine show_environmentendefendif################################################################################# Support macros#################################################################################.. Remove files contained within the specified list## Usage: $(call RmFiles,VARIABLE_NAME)#define RmFiles$(AA_PRE)(if [ "$(GBE_VERBOSE)" -gt 0 ]; then \echo Removing $($(1)); fi; \CHOWNS=; \RMS=; \for file in $($(1)); do \if [ -f $$file -o -h $$file ]; then \if [ ! -w $$file ]; then \CHOWNS="$$CHOWNS $$file"; \fi; \RMS="$$RMS $$file"; \fi; \done; \if [ -n "$$RMS" ]; then \if [ -n "$$CHOWNS" ]; then \$(chmod) -f +w $$CHOWNS; \fi; \$(rm) -f $$RMS; \fi);endef#.. Install/uninstall the specified file## Usage: $(call InstallFile,dest,file,path,fmode)# $(call UninstallFile,file)#define InstallFile$(call CopyFile,installing,$1,$2,$3,$4)endefdefine UninstallFile$(call UncopyFile,uninstalling,$1)endef#.. Package/Unpackage the specified file## Usage: $(call PackageFile,dest,file,path,fmode)# $(call UnpackageFile,file)#define PackageFile$(call CopyFile,packaging,$1,$2,$3,$4)endefdefine UnpackageFile$(call UncopyFile,unpackaging,$1)endef#.. Generic Copy/Remove the specified file## Usage: $(call CopyFile,Text,dest,file,path,fmode)# $(call UncopyFile,Text,file)## Notes:# dest, file and path# May have spaces in them# These will have been escaped with a '\' which will# need to be removed. The '\ ' is required to keep make# happy elsewhere.## May have '$' in them which we will need to escape## Windows copy has limitations.# Abs path length must < 260# Passing a relative path does not solve the problem# Moreover, if the relative path contains one or more ../# sequences, then the 'cp' command creates a complete path# before removing the zzz/.. sequences - and this must not exceed# 259 characters.## At the moment we get the most out of the windows 'cp' by# passing it a clean absolute pathname, but there is still# a limit of ~259 characters. This affects many programs, not just# cp but make, rm, chmod ...### Nice Macros# AbsName - convert a '\ ' pathname into an absolute path with plain spaces# and $ escaped with a \.# In the process 'spaces' need to be replaced with something to# keep abspath from splitting on space.# NiceName - convert a '\ ' pathname into an string with plain spaces# and $ escaped with a \.#AbsName = $(subst $$,\$$,$(subst $(spacealt),$(space),$(abspath $(subst \$(space),$(spacealt),$1))))NiceName = $(subst $$,\$$,$(subst \$(space),$(space),$1))define CopyFile$(AA_PRE)(\udest="$(call NiceName,$2)"; \dest="$(call AbsName,$2)"; \file="$(call NiceName,$3)"; \path="$(call AbsName,$4)"; \fmode="$(5)"; \echo "------ $1 $$udest"; \if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \$(rm) -f "$$dest"; \$(cp) "$$file" "$$dest" ;\if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\$(if $(5),$(chmod) -f $$fmode "$$dest") ; \if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \);endefdefine UncopyFile$(AA_PRE)(\udest="$(call NiceName,$2)"; \file="$(call AbsName,$2)"; \echo "------ $1 $$udest"; \if [ -f "$$file" ]; then \if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \$(rm) -f "$$file"; \fi);endef##