Wednesday, March 10, 2010
ディレクトリが存在している場合だけ処理する方法, ifでフロー制御 ( GNU Make ) 改良
ディレクトリが存在している場合だけ処理する方法 でも書いたのだが、もっとスマートな方法があったので追記。
Makefile で、 あるディレクトリが存在しているかどうかで処理を分岐させる方法。
→ if と シェルのコマンドを組み合わせて解決する。
Makefile
$(targetdir) が存在する場合だけ do-something を実行する。
targetdir := /usr/share/groovy/lib
targetdirexists := $(shell if test -d $(targetdir); then echo 'exists'; fi )
default :
$(if $(targetdirexists) ,$(do-something))
define do-something
@echo '$(targetdir) dir exists'
endef
