#! /usr/bin/make

# Makefile to convert svg, jpg and png files to PDF

SVGFILES = $(wildcard *.svg)
JPGFILES = $(wildcard *.jpg)
PNGFILES = $(wildcard *.png)
TARGETS = $(patsubst %.svg, %.pdf, $(SVGFILES)) \
          $(patsubst %.jpg, %.pdf, $(JPGFILES)) \
          $(patsubst %.png, %.pdf, $(PNGFILES))

all: $(TARGETS)

%.pdf: %.png
	@echo "PNG -> $@"
	convert $< -background white -alpha remove -alpha off  $<.png
	img2pdf $<.png --pagesize 960x720 -o $@
	rm -f $<.png
	convert $< -resize 960x720 $@

%.pdf: %.jpg
	img2pdf $< --pagesize 960x720 -o $@

%.pdf: %.svg
	rsvg-convert -f pdf $< --width 960 -o $@

clean:
	rm -f $(TARGETS)

.PHONY: all clean
