# makefile for fqme
#
# SPDX-FileCopyrightText: (C) Eric S. Raymond <esr@thyrsus.com>
# SPDX-License-Identifier: BSD-2-Clause

VERSION=$(shell sed -n <NEWS.adoc '/^v[0-9]/s/:.*//p' | head -1)

# Rules

# Note: to suppress the footers with timestamps being generated in HTML,
# we use "-a nofooter".
# To debug asciidoc problems, you may need to run "xmllint --nonet --noout --valid"
# on the intermediate XML that throws an error.
.SUFFIXES: .html .adoc .1

.adoc.1:
	asciidoctor -D. -a nofooter -b manpage $<
.adoc.html:
	asciidoctor -D. -a nofooter -a webfonts! $<

.PHONY: build clean lint reflow check spellcheck version dist release refresh

# Build

build:
	go build demo/fqme-demo.go

clean:
	rm *.1 *.html

# Validate

lint:
	golint .
	go vet .

reflow:
	gofmt -w .

check: lint build

spellcheck:
	@spellcheck local.dic README.adoc NEWS.adoc

# Export

SOURCES = README.adoc LICENSE NEWS.adoc control local.dic Makefile fqme.go demo/fqme-demo.go smalleye.png

version:
	@echo $(VERSION)

# Unlikely to ever be used, tarballs aren't how Go modules are distributed.
fqme-$(VERSION).tar.gz: $(SOURCES)
	mkdir fqme-$(VERSION)
	cp -r $(SOURCES) fqme-$(VERSION)
	tar -czf fqme-$(VERSION).tar.gz fqme-$(VERSION)
	rm -fr fqme-$(VERSION)
	ls -l fqme-$(VERSION).tar.gz

dist: fqme-$(VERSION).tar.gz

release: fqme-$(VERSION).tar.gz
	shipper version=$(VERSION) | sh -e -x

refresh: fqme.html
	shipper -N -w version=$(VERSION) | sh -e -x

# end
