[430] | 1 | # | |
---|
| 2 | # o---------------------------------------------------------------------o |
---|
| 3 | # | |
---|
| 4 | # | MAD makefile - utilities |
---|
| 5 | # | |
---|
| 6 | # o---------------------------------------------------------------------o |
---|
| 7 | # | |
---|
| 8 | # | Methodical Accelerator Design |
---|
| 9 | # | |
---|
| 10 | # | Copyright (c) 2011+ CERN, mad@cern.ch |
---|
| 11 | # | |
---|
| 12 | # | For more information, see http://cern.ch/mad |
---|
| 13 | # | |
---|
| 14 | # o---------------------------------------------------------------------o |
---|
| 15 | # | |
---|
| 16 | # | $Id$ |
---|
| 17 | # | |
---|
| 18 | |
---|
| 19 | # some useful variables |
---|
| 20 | EMPTY := |
---|
| 21 | SPACE := |
---|
| 22 | SPACE += |
---|
| 23 | |
---|
| 24 | # some useful functions |
---|
| 25 | eq = $(if $(patsubst $1,,$2),,t) |
---|
| 26 | neq = $(if $(patsubst $1,,$2),t,) |
---|
| 27 | |
---|
| 28 | escsp = $(subst $(SPACE),\ ,$1) |
---|
| 29 | |
---|
| 30 | first = $(word 1,$1) |
---|
| 31 | last = $(word $(words $1),$1) |
---|
| 32 | rest = $(wordlist 2,$(words $1),$1) |
---|
| 33 | chop = $(wordlist 2,$(words $1),_ $1) |
---|
| 34 | uniq = $(strip $(if $1,$(call uniq,$(call chop,$1)) \ |
---|
| 35 | $(if $(filter $(call last,$1),$(call chop,$1)),,$(call last,$1)))) |
---|
| 36 | trans = $(if $1,$(call trans,$(call rest,$1),$(call rest,$2)\ |
---|
| 37 | ,$(patsubst $(firstword $1),$(firstword $2),$3)),$3) |
---|
| 38 | find = $(if $(and $1,$2),$(if $(findstring $1,$(firstword $2)),$2,\ |
---|
| 39 | $(call find,$1,$(call rest,$2))),) |
---|
| 40 | trunc = $(if $(and $1,$2),$(if $(findstring $1,$(lastword $2)),$2,\ |
---|
| 41 | $(call trunc,$1,$(call chop,$2))),) |
---|
| 42 | |
---|
| 43 | assert = $(if $1,,$(error $2)) |
---|
| 44 | exists = $(if $(wildcard $1),,$(error $2)) |
---|
| 45 | mkdir = $(if $(wildcard $1),,$(shell mkdir $(if $(windir),,-p) $1)) |
---|
| 46 | |
---|
| 47 | # end of makefile |
---|