summaryrefslogtreecommitdiff
path: root/webgen
diff options
context:
space:
mode:
authorPhilipp Schafft <lion@lion.leolix.org>2016-06-19 11:27:14 +0000
committerPhilipp Schafft <lion@lion.leolix.org>2017-03-27 02:11:20 +0000
commitaf8b482dfc507ad6580643c341c5c61aa7036ae5 (patch)
tree1e4e00d60271f3524a0bb09aaf61f245397ceedf /webgen
parentb28a185a48985ff72d50ea96804fc93e1d0da882 (diff)
Feature: --setup now also writes a basic Makefile.
Diffstat (limited to 'webgen')
-rwxr-xr-xwebgen56
1 files changed, 56 insertions, 0 deletions
diff --git a/webgen b/webgen
index 050bb10..472160f 100755
--- a/webgen
+++ b/webgen
@@ -70,6 +70,62 @@ setup() {
echo ' </body>'
echo '</html>'
} > ./-end
+ cat > ../Makefile <<'EOL'
+# (mostly) Universal Makefile for webgen.
+
+# Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2016
+#
+# This file is part of webgen,
+# a small template engine for easy management of small websites.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3
+# as published by the Free Software Foundation.
+#
+# webgen is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this software; see the file COPYING. If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Settings:
+# This is the list of languages you want to generate output for.
+# Use 'default' for default rendering.
+# Examples: 'default', 'default en de'.
+# Note: Files are only generated in non-default language if
+# there is a translation (tpl/#translate$TPL.$LANG).
+LANGUAGES=default
+
+
+# Code:
+
+# Get list of all templates first:
+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)
+clean:
+ rm -f $(TARGETS)
+new: clean all
+distclean: clean
+
+# Declare them as phony:
+.PHONY: all clean new distclean
+
+# Actual rule to run webgen and calculation of all prerequisites:
+.SECONDEXPANSION:
+$(TARGETS): $$(shell webgen --list-dependencies $$@)
+ webgen $@
+
+#ll
+EOL
}
list_tpls() {