Rev 245 | Rev 261 | 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################################################################################# Verbose versions of specific commands################################################################################ifdef VERBOSEGBE_RM =$(rm)GBE_RMDIR =$(rmdir)elseGBE_RM =@$(rm)GBE_RMDIR =@$(rmdir)endif################################################################################# Support macros#################################################################################.. Remove files contained within the specified list## Usage: $(call RmFiles,VARIABLE_NAME)#define RmFiles@(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)## Note: dest, file and path# may have spaces in them# These will have been escaped with a'\' which will# need to be removed.## May have '$' in themwhich we will need to escape#define CopyFile@(dest="$(subst \$(space),$(space),$(subst $$,\$$,$(2)))"; \file="$(subst \$(space),$(space),$(subst $$,\$$,$(3)))"; \path="$(subst \$(space),$(space),$(subst $$,\$$,$(4)))"; \fmode="$(5)"; \echo ------ "$1 $$dest"; \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@(file="$(subst \$(space),$(space),$(subst $$,\$$,$(2)))"; \echo ------ $1 "$$file"; \if [ -f "$$file" ]; then \if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \$(rm) -f "$$file"; \fi);endef##