From 46eff719d7183ea57e8d858971b3c81a8ee74b0f Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Mon, 27 Mar 2017 02:39:01 +0000 Subject: Feature: Added limited DESTDIR support This adds DESTDIR support to webgen. However this only works if the destination dir already exists. Also detection on which targets need rebuild does not work. All targets are remade. --- webgen | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'webgen') diff --git a/webgen b/webgen index 8751c80..499964c 100755 --- a/webgen +++ b/webgen @@ -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 -- cgit v1.2.3