## Filename: Ambidxtr.mk ## Last modified: Sun Jun 1 16:03:18 UTC 2008 ## Author: Soren Andersen (somian/intrepid) ## ------------------------------------------- # CVS Data: # # $Author: intrepid $ # $Date: 2008/06/02 12:40:55 $ # $Revision: 1.2 $ # # Some utility functions # SWAPS turns canonical proper slashes into backslashes for WinDOS SWAPS = $1 # Neg inverts the 'trueness' of the argument (for use as first arg # to $(if ...) for example) Neg = $(if $1,,TRUE) # -===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===- # First, make sure SHELL is sane for cygwin and ms windows _starting_SHELL = boguscommandthatwillneverexist ifeq "" "$(ComSpec)$(COMSPEC)$(comspec)" _starting_SHELL = /bin/sh SHELL := $(_starting_SHELL) _TellAbout_SHELL := $(warning We detect no COMSPEC. If this is MS Windows you are screwed.)echo 'The SHELL is $(SHELL)' # we're done, nothing else to worry about with non-mswindwoes platform else # we're on an mswindwoes platform as far as we can tell _starting_SHELL = $(if $(findstring default,$(origin SHELL)),\ boguscommandthatwillneverexist,$(SHELL)) ifeq "command line" "$(origin SHELL)" _starting_SHELL = $(SHELL) else ifeq "environment" "$(origin SHELL)" _starting_SHELL = $(SHELL) else _starting_SHELL = $(firstword $(ComSpec) $(COMSPEC) $(comspec)) endif endif _colonseek := $(firstword $(subst :,$(NADA): ,$(_starting_SHELL))) _colonseek := $(patsubst %:,:,$(_colonseek)) _mswexe_ext := .exe # Do we have a ms-windows / DOS -style pathname? If so, correct that to canonical. ifneq "" "$(findstring \,$(_starting_SHELL))" _starting_SHELL := $(subst \,/,$(_starting_SHELL)) endif # _DUMMYVAR := $(if $(call Neg,$(findstring :,$(_colonseek))),\ # $(warning There was no colon seen in _starting_SHELL [${_starting_SHELL}]),\ # $(warning There was a colon seen in _starting_SHELL [${_starting_SHELL}] - colonseek is $(_colonseek))) ifeq ":" "$(_colonseek)" # _starting_SHELL := $(_starting_SHELL) _starting_SHELL := $(warning SHELL is going to be //./$(_starting_SHELL))//./$(_starting_SHELL) else # XXX this is fairly broken and useless. ifneq "" "$(HOMEDRIVE)" _starting_SHELL := $(strip $(shell ${CYGROOT}\bin\cygpath -m "$(_starting_SHELL)")) endif endif _TellAbout_SHELL = echo 'The SHELL is $(SHELL)' endif SHELL := $(_starting_SHELL) export SHELL export _TellAbout_SHELL ifeq "YAY" "$(patsubst %sh$(_mswexe_ext),YAY,$(SHELL))" SHELL_is_SHish := yes else SHELL_is_SHish := SWAPS = $(subst /,\,$1) endif # -===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===- define builtin_linkstem @echo the make rule is:' $(value LINK.o)' @echo which evaluates to:' $(LINK.o)' endef define builtin_costem @echo the make rule is:' $(value COMPILE.c)' @echo which evaluates to:' $(COMPILE.c)' endef # -===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===- ifeq "yes" "$(SHELL_is_SHish)" define Cond_DirCreate if [ ! -d $1 ]; then mkdir $(strip $1) && echo "Created $1"; fi endef else define Cond_DirCreate $(SHELL) /c IF NOT EXIST $(strip $(call SWAPS,$1)) MKDIR $(strip $(call SWAPS,$1)) endef endif # -===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===-===- ifneq (USE_PIPE_DIRECTIVE_GIVEN, \ $(findstring USE_PIPE_DIRECTIVE_GIVEN, \ $(subst -pipe, USE_PIPE_DIRECTIVE_GIVEN,${CFLAGS}))) CFLAGS += -pipe endif ifneq (OPTIMIZATION_DIRECTIVE_GIVEN, \ $(findstring OPTIMIZATION_DIRECTIVE_GIVEN, \ $(patsubst -O%, OPTIMIZATION_DIRECTIVE_GIVEN,${CFLAGS}))) CFLAGS += -O2 endif ifneq (MACH_TUNING_DIRECTIVE_GIVEN, \ $(findstring MACH_TUNING_DIRECTIVE_GIVEN, \ $(patsubst -mtune=%, MACH_TUNING_DIRECTIVE_GIVEN,${CFLAGS}))) CFLAGS += -mtune=pentium3 endif