make - Directory independent target in Makefile -
i'm trying create rule generate files regarding names regardless of directory.
i'm starting makefile (see a previous question of mine):
targets:=$(patsubst %_tpl,%,$(wildcard *_tpl)) .phony: all: $(targets) .secondexpansion: $(targets): %: $$(wildcard %*_tpl) ./generate $@_tpl > $@
with this, can do, instance, make foo.xml
. looks if set of foo.xml*_tpl
files there, consider them prerequisites , phone call generate
script generate target.
what is, example, make ../ressources/foo.xml
, have create utilize rule create foo.xml
creating in ../ressources/
directory, without having explicitely specify directory in makefile.
what have tried moment adding makefile:
../ressources/%: $(notdir %) mv $< $@
which works, avoid creating file in current directory before moving destination folder. not having specify possible destination folders in makefile (but less important).
but first of all, create sense? or want conceptually wrong?
edit: precisions regarding _tpl
files , generate
script avoid confusions:
each target has main template ($@_tpl
) includes others ($@-part1_tpl
, $@-part2_tpl
...) , generate
script takes main template argument. templates written jinja2 (the subparts included {% include %}
jinja directive).
if want targets in directory, so.
targets:=$(patsubst %_tpl,../resources/%,$(wildcard *_tpl)) .phony: all: $(targets) .secondexpansion: $(targets): ../resources/%: $$(wildcard %*_tpl) ./generate $@_tpl > $@
i'm not sure if should have generate $^ >$@
instead; superficially, create more sense.
if there multiple *_tpl
files each target (i.e. there more tpl
files xml
files), targets
definition isn't correct; don't have plenty info prepare it.
on other hand, if target directory can alter lot, sane way forwards might cd
target directory , utilize make -f ../path/to/makefile
-- create sure vpath
set source files can found.
makefile make
No comments:
Post a Comment