Makefile

.SUFFIXES: .md .html

HEAD_TITLE_MARKER = __HEAD_TITLE

LOWDOWN_FLAGS = -thtml --html-no-skiphtml --html-no-escapehtml

ROOT_HTML_FILES = index.html registration.html vendors.html hosts.html

FONT_FILES = DM-Serif-Display.woff2 poppins.woff2 caveat.woff2

# Make sure the required tools are available
check-tools:
	@command -v lowdown >/dev/null 2>&1 || \
{ echo "lowdown command not found. Please pkg_add lowdown." >&2; exit 1; }


# General rule for .md to .html
.md.html: check-tools header footer
	lowdown $< $(LOWDOWN_FLAGS) | cat header - footer > $@
	PAGE_TITLE=`grep -m 1 '^# ' $< | sed "s/# //"` ; \
	sed -i "s/$(HEAD_TITLE_MARKER)/$$PAGE_TITLE/" $@

# .PHONY rules
.PHONY: all dist dist-clean clean show-html-files subdirs

# Default rule
all: $(ROOT_HTML_FILES) $(FONT_FILES) style.css

# Create dist directory and copy all files into it
dist: all
	mkdir -p dist
	cp -R assets/ dist/
	cp -R files/ dist/
	cp style.css dist/
	cp $(ROOT_HTML_FILES) dist/
	cp $(FONT_FILES) dist/
	find dist -name "*.md" -type f -delete

# Remove dist directory
dist-clean:
	rm -rf dist

# Remove generated HTML files
clean:
	rm $(ROOT_HTML_FILES)