diff options
| -rwxr-xr-x | webgen | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -105,29 +105,41 @@ setup() { # there is a translation (tpl/#translate$TPL.$LANG). LANGUAGES=default +# This is the webgen binary to use. +# Default (using webgen in $PATH): webgen +WEBGEN=webgen # Code: +ifdef DESTDIR +WEBGEN += --destdir $(DESTDIR) +endif + # Get list of all templates first: -TEMPLATES=$(shell webgen --list) +TEMPLATES=$(shell $(WEBGEN) --list) # Now calculate the list of targets. Better don't!: TARGETS = $(patsubst =%,%,$(filter =%,$(TEMPLATES))) $(foreach tpl,$(filter-out =%,$(TEMPLATES)),$(foreach lang,$(LANGUAGES),$(if $(findstring default,$(lang)),$(patsubst +%,%,$(tpl:~%=%)).html,$(if $(wildcard tpl/\#translate$(tpl).$(lang)),$(patsubst +%,%,$(tpl:~%=%)).$(lang).html)))) # Common phony targets: -all: $(TARGETS) +all: prep-dirs $(TARGETS) clean: rm -f $(TARGETS) new: clean all distclean: clean +prep-dirs: +ifdef DESTDIR + mkdir -vp "$(DESTDIR)" +endif + # Declare them as phony: -.PHONY: all clean new distclean +.PHONY: all clean new distclean prep-dirs # Actual rule to run webgen and calculation of all prerequisites: .SECONDEXPANSION: -$(TARGETS): $$(shell webgen --list-dependencies $$@) - webgen $@ +$(TARGETS): prep-dirs $$(shell $(WEBGEN) --list-dependencies $$@) + $(WEBGEN) $@ #ll EOL @@ -217,6 +229,12 @@ do fi shift ;; + '--destdir') + pushd "$2" > /dev/null + OUT=`pwd` + popd > /dev/null + shift; + ;; '--setup') setup exit 0 |
