# | # o---------------------------------------------------------------------o # | # | MAD makefile - utilities # | # o---------------------------------------------------------------------o # | # | Methodical Accelerator Design # | # | Copyright (c) 2011+ CERN, mad@cern.ch # | # | For more information, see http://cern.ch/mad # | # o---------------------------------------------------------------------o # | # | $Id$ # | # some useful variables EMPTY := SPACE := SPACE += # some useful functions eq = $(if $(patsubst $1,,$2),,t) neq = $(if $(patsubst $1,,$2),t,) escsp = $(subst $(SPACE),\ ,$1) first = $(word 1,$1) last = $(word $(words $1),$1) rest = $(wordlist 2,$(words $1),$1) chop = $(wordlist 2,$(words $1),_ $1) uniq = $(strip $(if $1,$(call uniq,$(call chop,$1)) \ $(if $(filter $(call last,$1),$(call chop,$1)),,$(call last,$1)))) trans = $(if $1,$(call trans,$(call rest,$1),$(call rest,$2)\ ,$(patsubst $(firstword $1),$(firstword $2),$3)),$3) find = $(if $(and $1,$2),$(if $(findstring $1,$(firstword $2)),$2,\ $(call find,$1,$(call rest,$2))),) trunc = $(if $(and $1,$2),$(if $(findstring $1,$(lastword $2)),$2,\ $(call trunc,$1,$(call chop,$2))),) assert = $(if $1,,$(error $2)) exists = $(if $(wildcard $1),,$(error $2)) mkdir = $(if $(wildcard $1),,$(shell mkdir $(if $(windir),,-p) $1)) # end of makefile