summaryrefslogtreecommitdiff
path: root/webgen
diff options
context:
space:
mode:
authorPhilipp Schafft <lion@lion.leolix.org>2017-03-27 02:39:01 +0000
committerPhilipp Schafft <lion@lion.leolix.org>2017-03-27 02:39:01 +0000
commit46eff719d7183ea57e8d858971b3c81a8ee74b0f (patch)
tree452e9be89460c5b62e9f4fd92fa2b0c3abcee769 /webgen
parent05e46be23be32027828bda09c3406f78681da300 (diff)
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.
Diffstat (limited to 'webgen')
-rwxr-xr-xwebgen28
1 files changed, 23 insertions, 5 deletions
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