# Makefile to convert SVG files to PDF and compile a LaTeX Beamer presentation

# Variables
SVG_DIR := svg
TEX_FILE := yocto-kernel-hardening.tex
PDF_OUTPUT := $(basename $(TEX_FILE)).pdf

# Find all SVG files in the SVG_DIR
SVG_FILES := $(wildcard $(SVG_DIR)/*.svg)
# Generate corresponding PDF files
PDF_FILES := $(patsubst $(SVG_DIR)/%.svg,$(SVG_DIR)/%.pdf,$(SVG_FILES))

# Default target
all: $(PDF_OUTPUT)

# Rule to convert SVG to PDF
$(SVG_DIR)/%.pdf: $(SVG_DIR)/%.svg
	echo "Converting $< to $@"
	rsvg-convert --format=Pdf --output=$@ $<

# Rule to compile the LaTeX presentation
$(PDF_OUTPUT): $(TEX_FILE) $(PDF_FILES)
	echo "Compiling $< to $@"
	lualatex -interaction=nonstopmode --shell-escape -halt-on-error $<

# Clean intermediate files
clean:
	rm -rf $(SVG_DIR)/*.pdf *.aux *.log *.nav *.out *.snm *.toc *.vrb _minted*

# Clean all output, including final PDF
cleanall: clean
	rm -f $(PDF_OUTPUT)

.PHONY: all clean cleanall
