X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=rules%2Fprograms.mk;h=bd5b85033da5e69fe80403d78cd88a8fcc57c55c;hp=d706d3fc0d27ac7e24c38471d4748e807e4b6a94;hb=ac47d3137a6a3dc618afe9bf1a6ca860e117942a;hpb=2854030a3f699188676f19ba16a5400c4976f23c diff --git a/rules/programs.mk b/rules/programs.mk index d706d3f..bd5b850 100644 --- a/rules/programs.mk +++ b/rules/programs.mk @@ -9,5 +9,24 @@ UNZIP = unzip $(UNZIPFLAGS) ZIP = zip $(ZIPFLAGS) ifneq ($(OS),Windows_NT) - WINE ?= wine +WINE ?= wine endif + +find-files = $(shell find $1 -type f $2 -print $3) + +rmdir-r = [ ! -e $1 ] || find -d $1 -type d -delete + +# Use to find the best command to execute out of a series of possible +# equivalent ones, or provide a fallback. If a second argument is +# supplied it is used as the fallback, otherwise the first element of +# the checked executables is used. e.g. +# PYLINTER := $(call command-v,flake8 pyflakes,python -mpy_compile) +# will pick flake8 if it's installed, or pyflakes if it isn't, +# or python -mpy_compile (a syntax check) if neither is +# installed. +command-v = $(firstword $(shell command -v $1) $2 $1) + +# Use in place of 'mkdir -p' to avoid littering every other line of +# output with a redundant mkdir call; the downside is that it can't be +# silenced itself. +MKDIR = @$(SHELL) -c '[ -d "$$0" ] || echo mkdir -p "$$0" && mkdir -p "$$0"'