- SOURCES = ikiwiki
- ikiwiki_ORIGIN = http://source.jones.dk/ikiwiki_MODULE.git
- ikiwiki_MODULES = templates basewiki smiley
- ikiwiki_POMODULES = basewiki smiley
- ikiwiki_BRANCH = master-LOCALE
- ikiwiki_LOCALES = da
- #dummy_MODULES = content_dummy
- # uncomment this when ikiwiki.setup is configured for the local environment
- #CONFIGS = ikiwiki.setup
- # Everything after this is generic
- # FIXME: Not all of these are used within templates
- masterdir = $(module)
- l10ndir = $(module)_l10n/$(locale)
- podir = po
- all: $(SOURCES)
- install::
- ifeq ($(strip $(CONFIGS)),)
- $(error Please configure ikiwiki.setup and then uncomment it at the top of the Makefile!)
- endif
- # 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 $$@ && \
- git init && \
- git remote add -f -t $$(master) -m $$(master) origin $$(origin) && \
- git merge origin && \
- git config remote.origin.push +refs/heads/master:refs/heads/$$(master); \
- fi
- # 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_MASTERFILES += $$(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 5:originmodule
- define INITPO_template
- fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
- filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
- ALL_POFILES += $(podir)/$(3).$(2).po
- ALL_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
- $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
- $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
- $(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)/$(5)/%,$($(3)_L10NFILES)) ) \
- | grep -v '#, fuzzy' \
- > $$@
- # 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 $$(patsubst $(1)/%,$(CURDIR)/$(5)/%,$$@)
- .PHONY: $(1)
- endef
- $(foreach source,$(SOURCES),$(foreach module,$(po-init-modules),$(foreach locale,$(po-init-locales),$(eval $(call INITPO_template,$(l10ndir),$(locale),$(module),$(source),$(if $(po-init-fromlocale),$(module)_l10n/$(po-init-fromlocale),$(module)))))))
- # 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
- ALL_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
- $(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)/$$@
- .PHONY: $(1)
- endef
- $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
- # 1:dummydir
- define DUMMYMODULE_template
- $(1):
- mkdir -p $$@
- # WARNING: this may wipe unrelated files too!
- ultraclean::
- rm -rf "$(1)"
- endef
- $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
- # 1:configfile
- define CONFIG_template
- $(1):
- mkdir -p $$@
- # WARNING: this may wipe unrelated files too!
- install::
- ikiwiki --setup $(1) --rebuild
- endef
- $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
- pot: $(ALL_POTFILES)
- po: $(ALL_POFILES)
- $(ALL_L10NFILES): $(ALL_MASTERFILES)
- translations: $(ALL_L10NFILES)
- .PHONY: all $(SOURCES) pot po translations install ultraclean
|