# Linux Vulnerability Mitigation

# Copyright (C) 2026 Daniel Baumann <daniel@debian.org>
#
# SPDX-License-Identifier: PD
#
# This program is free software: you have unlimited permission
# to copy, distribute and modify it.
#
# 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.

# Depends: python3-docutils

RST2MAN = rst2man \
	--no-datestamp \
	--no-generator \
	--strict \
	--strip-comments \
	--tab-width=4 \
	--verbose

VERSION := $(shell cat ../VERSION.txt)

SHELL := sh -e

all: build

build: man

rebuild: clean build

man: man.in *.rst
	@echo -n "Creating manpages... "

	@for FILE in *.rst; \
	do \
		cp man.in $$(basename $${FILE} .rst); \
		$(RST2MAN) $${FILE} | \
		sed	-e '/^.\\" Man page generated/d' \
			-e '/^.\\" Generated by/d' \
			-e "s|^\(.TH .*\) \(\"\" \"\"\) |\1 $${VERSION} linux-vulnerability-mitigation |" \
		>> $$(basename $${FILE} .rst); \
		echo -n "."; \
	done

	@echo " done."

clean:
	rm -f *.[0-9]

.PHONY: all clean build rebuild man
