summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2007-11-05 23:58:51 +0100
committerJonas Smedegaard <dr@jones.dk>2007-11-05 23:58:51 +0100
commitcfd0df9f98dc6024cff516018e7b6c71707ad88c (patch)
tree1fde89bd8ca57d3c82fc7bd68bcb2bb8fbbdcd28
parent6c3a55bb6e487cb2dfa8f49a93683241d02ea526 (diff)
Major Makefile rewrite to use eval functions.
-rw-r--r--Makefile171
1 files changed, 105 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index 73ce1bd..5fb858d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
SOURCES = ikiwiki
ikiwiki_ORIGIN = http://source.jones.dk/ikiwiki_MODULE.git
-ikiwiki_MODULES = basewiki smiley templates
+ikiwiki_MODULES = templates basewiki smiley
+ikiwiki_POMODULES = basewiki smiley
ikiwiki_BRANCH = master-LOCALE
ikiwiki_LOCALES = da
@@ -9,87 +10,125 @@ ikiwiki_LOCALES = da
# Everything after this is generic
-underlays_l10n = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %,%_l10n/$(locale),$($(source)_MODULES))))
-underlays = $(foreach source, $(SOURCES), $($(source)_MODULES)) $(underlays_l10n)
-
-# FIXME: Handle translation of templates (needs po4a parser for HTML::Template markup)
-#potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$($(source)_MODULES)))
-potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$(filter-out templates,$($(source)_MODULES))))
-pofiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %.pot,%.$(locale).po,$(potfiles))))
-l10nfiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(foreach underlay,$(patsubst po/%.$(locale).po,%,$(pofiles)), $(patsubst %,$(l10ndir)/%,$(l10nfiles_in_underlay)))))
-
-source_of_underlay = $(firstword $(foreach source, $(SOURCES), $(if $(filter $(underlay),$($(source)_MODULES)),$(source))))
-origin = $(subst MODULE,$(underlay),$($(source_of_underlay)_ORIGIN))
-master = $(subst -LOCALE,$(locale:%=-$(locale)),$($(source_of_underlay)_BRANCH))
-
-masterdir = $(underlay)
-l10ndir = $(underlay)_l10n/$(locale)
-# FIXME: The po4a plugin for HTML::Template needs to be written...
-fileformat = $(if $(filter templates,$(underlay)),htmltemplate,text)
-filetype = $(if $(filter templates,$(underlay)),tmpl,mdwn)
-l10nfiles_in_underlay = $(shell cd "$(masterdir)" && find * -type f -name '*.$(filetype)')
-
-all: $(underlays) $(dummy_MODULES)
-
-$(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@))
-$(underlays): underlay=$(@:%_l10n/$(locale)=%)
-$(underlays):
- mkdir -p $@
- @if [ -d "$@/.git" ]; then \
- cd $@ && \
+# FIXME: Not all of these are used within templates
+masterdir = $(module)
+l10ndir = $(module)_l10n/$(locale)
+podir = po
+
+all: $(SOURCES)
+
+install:
+ $(error FIXME: you need to adjust ikiwiki.setup first!)
+# ikiwiki --setup ikiwiki.setup --rebuild
+
+
+
+# 1:source 2:locales
+define SOURCE_template
+$(1): $$($(1)_MODULES) $(foreach module,$$($(1)_MODULES),$(foreach locale,$(2),$(module)_l10n/$(locale))) $(dummy_MODULES)
+L10N_MODULES += $$(foreach locale,$(2),$(1)_l10n/$$(locale))
+endef
+#$(foreach source,$(SOURCES),$(eval $(call SOURCE_template,$(source),$($(source)_LOCALES))))
+
+# 1:moduledir 2:locale 3:mastermodule 4:source
+define MODULE_template
+$(4): $(1)
+
+$(1): origin = $$(subst MODULE,$(3),$$($(4)_ORIGIN))
+$(1): master = $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH))
+$(1):
+ mkdir -p $$@
+ @if [ -d "$$@/.git" ]; then \
+ cd $$@ && \
git pull; \
else \
- cd $@ && \
+ cd $$@ && \
git init && \
- git remote add -f -t $(master) -m $(master) origin $(origin) && \
+ git remote add -f -t $$(master) -m $$(master) origin $$(origin) && \
git merge origin && \
- git config remote.origin.push +refs/heads/master:refs/heads/$(master); \
+ git config remote.origin.push +refs/heads/master:refs/heads/$$(master); \
fi
-pot: $(potfiles)
-po: pot $(pofiles)
-translations: po $(l10nfiles)
-$(potfiles): underlay=$(patsubst po/%.pot,%,$@)
-$(potfiles):
- cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
+# WARNING: this may wipe unrelated files too!
+ultraclean::
+ rm -rf "$(1)"
+ifneq ($(2),)
+ rm -rf "$(dir $(1))"
+endif
+
+.PHONY: $(1)
+endef
+$(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call MODULE_template,$(masterdir),,$(module),$(source)))))
+$(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source))))))
+
+
+
+# 1:moduledir 2:locale 3:mastermodule 4:source
+define POT_template
+fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
+filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
+ALL_POTFILES += $(podir)/$(3).pot
+$(3)_L10NFILES = $$(shell cd "$(1)" && find * -type f -name '*.$$(filetype)')
+ALL_L10NFILES += $(patsubst %,$(1)/%,$(3)_L10NFILES)
+
+$(podir)/$(3).pot: $(1)
+ cd "$(1)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
+
+.PHONY: $(1)
+endef
+$(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(eval $(call POT_template,$(masterdir),,$(module),$(source)))))
+
+
+
+# 1:moduledir 2:locale 3:mastermodule 4:source
+define PO_template
+fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
+filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
+ALL_POFILES += $(podir)/$(3).$(2).po
-$(pofiles): underlay=$(basename $(patsubst po/%.po,%,$@))
-$(pofiles): locale=$(patsubst .%,%,$(suffix $(patsubst po/%.po,%,$@)))
ifeq ($(translation_mode),init)
-$(pofiles):
-# cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
- ( cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) ) \
+$(podir)/$(3).$(2).po: $(1) $(3)
+ ( cd "$(3)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) $$(patsubst %,-m %,$$($(3)_L10NFILES)) $$(patsubst %,-l $$(CURDIR)/$(1)/%,$($(3)_L10NFILES)) ) \
| grep -v '#, fuzzy' \
- > $@
-else
-$(pofiles):
- cd "$(masterdir)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
-endif
+ > $$@
-#$(error $(l10nfiles):)
-$(l10nfiles): underlay=$(patsubst %_l10n,%,$(firstword $(subst /, ,$@)))
-$(l10nfiles): locale=$(patsubst %_l10n,%,$(word 2,$(subst /, ,$@)))
-$(l10nfiles):
- mkdir -p $(l10ndir)
-ifeq ($(translation_mode),init)
- cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
+# FIXME: needs to depend also on its masterfile
+$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
+ mkdir -p $(1)
+ cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
else
- cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
+$(podir)/$(3).$(2).po: $(3)
+ cd "$(3)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
+
+$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
+ mkdir -p $(1)
+ cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
endif
-$(dummy_MODULES):
- mkdir -p $@
+.PHONY: $(1)
+endef
+$(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
-install:
- $(error FIXME: you need to adjust ikiwiki.setup first!)
-# ikiwiki --setup ikiwiki.setup --rebuild
+
+
+# 1:dummydir
+define DUMMYMODULE_template
+$(1):
+ mkdir -p $$@
# WARNING: this may wipe unrelated files too!
-ultraclean:
- rm -rf $(underlays)
- rm -rf $(dir $(underlays_l10n))
- rm -rf $(dummy_MODULES)
+ultraclean::
+ rm -rf "$(1)"
+endef
+$(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
+
+
+
+pot: $(ALL_POTFILES)
+po: $(ALL_POFILES)
+translations: $(ALL_L10NFILES)
+
-.PHONY: pot po translations $(underlays)
+.PHONY: all $(SOURCES) pot po translations