makefile - GNU Make: Building multiple source files without targets -
i'm using makefile check configuration files before checking version control. having difficulty 1 of rules, needs run
/usr/local/bin/check-program config/file1.conf /usr/local/bin/check-program config/file2.conf [...] the check-program not accept multiple arguments, each config file needs checked individually. configuration files in 1 subdirectory , end in .config.
as there no source/dependency relationship haven't been able find correct makefile syntax run. work-around, for-loop check me, neither exit on failure nor skip file has been checked.
here cut-down version of have far:
shell := /bin/sh wd := $(shell pwd) host := $(shell hostname -s) bpcfg := $(wildcard config/*.conf) : check-bp check-bp : $(bpcfg) file in $(bpcfg); \ /usr/local/bin/check-program $$file; \ echo ""; \ done
you can sentinel files. each .conf file, have check step create .conf.checked file if succeeds.
shell := /bin/sh wd := $(shell pwd) host := $(shell hostname -s) bpcfg := $(wildcard config/*.conf) : $(bcfg:%=%.checked) %.conf.checked: %.conf /usr/local/bin/check-program $< && touch $@ as for loop not exiting on failure—that’s way shell works. try
for ((i = 0; < 10; i++)); if (( $i < 9 )); false; else true; fi; done the command fail 9 times out of ten, counts the exit status of last run through loop.
to fix this, change shell line shell = /bin/sh -e make shell’s default behaviour abort scripts when command fails. since make shell commands abort when don’t mind things return non-zero exit statues, may have add || true end of commands grep warning error.log.
Comments
Post a Comment