diff options
Diffstat (limited to 'GNUmakefile')
-rw-r--r-- | GNUmakefile | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/GNUmakefile b/GNUmakefile index 3c48127..3d7ec2c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,45 +1,71 @@ +GO := go +PORT := 8080 + cssfiles := $(shell find static -name '*.css' -not -name '*.min.css') cssfiles := $(cssfiles:.css=.min.css) gofiles := $(shell find main.go src -name '*.go') +sqlfiles := $(shell find src/dbx/sql -name '*.sql') templates := $(shell find src/templates -name '*.tmpl') -exttmpl := $(wildcard cmd/exttmpl/*.go) -mfmt := $(wildcard cmd/mfmt/*.go) +extpo := $(wildcard cmd/extpo/*.go) +extwiki := $(wildcard cmd/extwiki/*.go) -all: euro-cash.eu exttmpl mfmt +ENABLED_LANGUAGES := $(shell ./aux/enabled-languages) -euro-cash.eu: $(cssfiles) $(templates) $(gofiles) - go build +all: euro-cash.eu extpo -all-i18n: exttmpl - go generate ./src - find . -name out.gotext.json | mcp -b sed s/out/messages/ - go build +euro-cash.eu: $(cssfiles) $(templates) $(gofiles) $(sqlfiles) + $(GO) build -exttmpl: $(exttmpl) - go build ./cmd/exttmpl +extract: extpo extwiki + find . -name '*.go' -exec xgotext --foreign-user -o po/backend.pot {} + + find . -name '*.html.tmpl' -exec ./extwiki {} + \ + | gofmt >src/wikipedia/links.gen.go + find . -name '*.html.tmpl' -exec ./extpo {} + \ + | msgcat po/backend.pot - -o po/messages.pot + for bcp in $(ENABLED_LANGUAGES); \ + do \ + dir="po/$$bcp"; \ + if [ ! -d "$$dir" ]; \ + then \ + mkdir -p "$$dir"; \ + msginit -i po/messages.pot -o "$$dir/messages.po" -l$$bcp.UTF-8 \ + --no-translator; \ + fi; \ + msgmerge -UN "po/$$bcp/messages.po" po/messages.pot; \ + done + find po -name '*~' -delete -mfmt: $(mfmt) - go build ./cmd/mfmt +po: + for po in po/*/*.po; \ + do \ + msgfmt "$$po" -o "$${po%.*}.mo"; \ + done -%.min.css: %.css - lightningcss -m $< -o $@ +extpo: $(extpo) + $(GO) build ./cmd/extpo -watch: - ls euro-cash.eu | entr -r ./euro-cash.eu -no-email -port $${PORT:-8080} +extwiki: $(extwiki) + $(GO) build ./cmd/extwiki -release: all-i18n - [ -n "$$GOOS" -a -n "$$GOARCH" ] - find data static -type f \( \ - -not -name '*.css' \ - -or -name '*.min.css' \ - \) -exec tar -cf euro-cash.eu-$$GOOS-$$GOARCH.tar.gz euro-cash.eu {} + +%.min.css: %.css + if command -v lightningcss >/dev/null; \ + then \ + lightningcss -m $< -o $@; \ + else \ + cp $< $@; \ + fi clean: find . -type f \( \ -name euro-cash.eu \ - -or -name exttmpl \ - -or -name mfmt \ + -or -name extpo \ + -or -name extwiki \ -or -name '*.min.css' \ -or -name '*.tar.gz' \ \) -delete + +debug: + ./euro-cash.eu -debug -no-email -db-name :memory: -port $(PORT) + +.PHONY: clean debug extract po release |