Makefile
author František Kučera <franta-hg@frantovo.cz>
Sun, 06 Oct 2019 22:12:47 +0200
branchv_0
changeset 55 fe39d6940821
parent 54 9f5de01bfd30
child 67 78eca0b3ab5f
permissions -rw-r--r--
clean-up and update of chapters: Testable Safe code and sustainability Small code footprint Sane dependencies Easily auditable Reproducible builds Trustworthy packages and sources

# Sane software manifesto helper tools
# Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

VERSION_PARAMS := $(shell hg log -r '.' --template '--stringparam versionTag {latesttag} --stringparam versionDistance {latesttagdistance} --stringparam versionHash {node|short}') "--stringparam" "versionChangedFiles" $(shell hg status | wc -l) 

all: validate xhtml txt pdf logo-png statistics

validate:
	xmllint --noout --schema schema/ssm.xsd text/ssm.en.xml

xhtml:
	mkdir -p build
	xsltproc $(VERSION_PARAMS) --output build/index.xhtml --nonet templates/ssm.xhtml.xsl text/ssm.en.xml
	cp templates/*.css build
	cp templates/*.woff build

pdf:
	mkdir -p build
	xsltproc $(VERSION_PARAMS) --output build/ssm.en.fodt --nonet templates/ssm.odt.xsl text/ssm.en.xml
	libreoffice --convert-to pdf --outdir build build/ssm.en.fodt

# TODO: better line wrapping
txt:
	mkdir -p build
	xsltproc $(VERSION_PARAMS) --nonet templates/ssm.txt.xsl text/ssm.en.xml | fmt -w 74 -s | sed -E 's/(  +)([^- ])/\1  \2/g' > build/ssm.en.txt

logo-png:
	mkdir -p build
	inkscape -z -e build/sane-software-logo-circle.png logo/sane-software-logo-circle.svg
	inkscape -z -e build/sane-software-logo-rectangle.png logo/sane-software-logo-rectangle.svg

clean:
	rm -rf build

publish:
	scp build/*     globalcode.info:/var/www/sane-software.globalcode.info/v_0/
	scp license/*   globalcode.info:/var/www/sane-software.globalcode.info/license/


# Described at: https://relational-pipes.globalcode.info/v_0/examples-in-xmltable-ssm-gui.xhtml
build/statistics.rp: text/ssm.en.xml
	mkdir -p build
	cat text/ssm.en.xml \
		| relpipe-in-xmltable \
			--namespace "m" "tag:globalcode.info,2019:sane-software/manifesto" \
			--relation "chapter" \
				--records "//m:chapter" \
				--attribute "name" string "m:name" \
				--attribute "requirements" integer "count(descendant::m:item[m:type='requirement'])" \
				--attribute "recommendations" integer "count(descendant::m:item[m:type='recommendation'])" \
				--attribute "informations" integer "count(descendant::m:item[m:type='information'])" \
				--attribute "items_total" integer "count(descendant::m:item)" \
		> build/statistics.rp

# Prints a table with number of items in particular chapters:
statistics: build/statistics.rp
	cat build/statistics.rp | relpipe-out-tabular
	
statistics-chart: build/statistics.rp
	cat build/statistics.rp | relpipe-tr-cut ".*" "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types"