summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile75
1 files changed, 54 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 8cf4232..b3b4d30 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,6 @@ DATE = 1970-01-01
VERSION = 0.1.0
NAME = cracha
NAME_UC = $(NAME)
-LANGUAGES = en
## Installation prefix. Defaults to "/usr".
PREFIX = /usr
BINDIR = $(PREFIX)/bin
@@ -20,45 +19,58 @@ DESTDIR =
LDLIBS = --static -lscrypt-kdf -lsqlite3 -lm
GOCFLAGS = -I $(GOLIBDIR)
GOLDFLAGS = -L $(GOLIBDIR)
+N = `nproc`
.SUFFIXES:
-.SUFFIXES: .go .a .bin .bin-check
+.SUFFIXES: .go .a .bin .bin-check .adoc .po .mo
.go.a:
go tool compile -I $(@D) $(GOCFLAGS) -o $@ -p $(*F) \
`find $< $$(if [ $(*F) != main ]; then \
- echo src/$(NAME).go src/version.go; fi) | uniq`
+ echo src/$(NAME).go src/meta.go; fi) | uniq`
.a.bin:
go tool link -L $(@D) $(GOLDFLAGS) -o $@ --extldflags '$(LDLIBS)' $<
+.adoc:
+ asciidoctor -b manpage -o $@ $<
+
+.po.mo:
+ msgfmt -cfv -o $@ $<
+
all:
include deps.mk
-libs.a = $(libs.go:.go=.a)
-mains.a = $(mains.go:.go=.a)
-mains.bin = $(mains.go:.go=.bin)
-functional-tests/lib.a = $(functional-tests/lib.go:.go=.a)
-fuzz-targets/lib.a = $(fuzz-targets/lib.go:.go=.a)
-benchmarks/lib.a = $(benchmarks/lib.go:.go=.a)
+libs.a = $(libs.go:.go=.a)
+mains.a = $(mains.go:.go=.a)
+mains.bin = $(mains.go:.go=.bin)
+functional/lib.a = $(functional/lib.go:.go=.a)
+fuzz/lib.a = $(fuzz/lib.go:.go=.a)
+benchmarks/lib.a = $(benchmarks/lib.go:.go=.a)
+manpages.N.adoc = $(manpages.en.N.adoc) $(manpages.XX.N.adoc)
+manpages.N = $(manpages.N.adoc:.adoc=)
+sources.mo = $(sources.po:.po=.mo)
sources = \
src/$(NAME).go \
- src/version.go \
+ src/meta.go \
src/main.go \
derived-assets = \
- src/version.go \
+ src/meta.go \
$(libs.a) \
$(mains.a) \
$(mains.bin) \
$(NAME).bin \
+ $(manpages.XX.N.adoc) \
+ $(manpages.N) \
+ $(sources.mo) \
side-assets = \
$(NAME).db* \
@@ -74,19 +86,24 @@ all: $(derived-assets)
$(libs.a): Makefile deps.mk
-$(libs.a): src/$(NAME).go src/version.go
+$(libs.a): src/$(NAME).go src/meta.go
-$(fuzz-targets/lib.a):
+$(fuzz/lib.a):
go tool compile $(GOCFLAGS) -o $@ -p $(NAME) -d=libfuzzer \
- $*.go src/$(NAME).go src/version.go
+ $*.go src/$(NAME).go src/meta.go
-src/version.go: Makefile
- echo 'package $(NAME); const Version = "$(VERSION)"' > $@
+src/meta.go: Makefile
+ echo 'package $(NAME)' > $@
+ echo 'const Version = "$(VERSION)"' >> $@
+ echo 'const Name = "$(NAME)"' >> $@
+ echo 'const LOCALEDIR = "$(LOCALEDIR)"' >> $@
$(NAME).bin: src/main.bin
ln -fs src/main.bin $@
+$(manpages.XX.N.adoc): po/doc/po4a.cfg
+ po4a --no-update --translate-only $@ po/doc/po4a.cfg
.PRECIOUS: tests/queries.sql
@@ -95,7 +112,7 @@ tests/queries.sql: tests/main.bin ALWAYS
tests.bin-check = \
tests/main.bin-check \
- $(functional-tests/main.go:.go=.bin-check) \
+ $(functional/main.go:.go=.bin-check) \
$(tests.bin-check):
$(EXEC)$*.bin
@@ -125,12 +142,12 @@ check: check-unit check-integration
FUZZSEC=1
-fuzz-targets/main.bin-check = $(fuzz-targets/main.go:.go=.bin-check)
-$(fuzz-targets/main.bin-check):
- $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s \
+fuzz/main.bin-check = $(fuzz/main.go:.go=.bin-check)
+$(fuzz/main.bin-check):
+ $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s --test.parallel=$N \
--test.fuzz='.*' --test.fuzzcachedir=tests/fuzz/corpus
-fuzz: $(fuzz-targets/main.bin-check)
+fuzz: $(fuzz/main.bin-check)
@@ -144,6 +161,17 @@ bench: $(benchmarks/main.bin-check)
+i18n-doc:
+ po4a po/doc/po4a.cfg
+
+i18n-code:
+ gotext src/$(NAME).go > po/$(NAME)/$(NAME).pot
+ po4a po/$(NAME)/po4a.cfg
+
+i18n: i18n-doc i18n-code
+
+
+
## Remove *all* derived artifacts produced during the build.
## A dedicated test asserts that this is always true.
clean:
@@ -161,6 +189,8 @@ install: all
cp $(NAME).bin '$(DESTDIR)$(BINDIR)'/$(NAME)
cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)'
cp $(sources) '$(DESTDIR)$(SRCDIR)'
+ instool '$(DESTDIR)$(MANDIR)' install man $(manpages.N)
+ instool '$(DESTDIR)$(LOCALEDIR)' install mo $(sources.mo)
## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror
## of the "install" target, and removes *all* that was installed.
@@ -171,6 +201,9 @@ uninstall:
'$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \
'$(DESTDIR)$(SRCDIR)' \
+ instool '$(DESTDIR)$(MANDIR)' uninstall man $(manpages.N)
+ instool '$(DESTDIR)$(LOCALEDIR)' uninstall mo $(sources.mo)
+
ALWAYS: