NAME=bulb
PAPER=a4
PHOTOS=battery_holder.jpg bulb_back.jpg bulb_front.jpg capacitor.jpg \
       led.jpg microcontroller.jpg resistor.jpg switch.jpg transistor.jpg
SYMBOLS=battery_holder.svg bulb_back.svg bulb_front.svg capacitor.svg \
        led.svg microcontroller.svg resistor.svg schematic.svg \
        smd_solder_done.svg smd_solder_pads.svg smd_solder_part.svg \
        smd_solder_start.svg smd_solder_tin.svg switch.svg \
        transistor.svg

CONVERT=convert
INKSCAPE=inkscape
LATEX=latex
BIBTEX=bibtex
DVIPS=dvips
PS2PDF=ps2pdf
PDFVIEWER=acroread

IMAGES=$(addprefix photos/,$(PHOTOS)) $(addprefix symbols/,$(SYMBOLS))
IMAGES_EPS=$(addsuffix .eps,$(IMAGES))

.PHONY: all show clean
.SUFFIXES:
.SECONDARY:

all: $(NAME).dvi $(NAME).ps $(NAME).pdf

show: $(NAME).pdf
	$(PDFVIEWER) $<

clean:
	rm -f $(NAME).{d,log,out,dvi,ps,pdf} $(IMAGES_EPS)

%.jpg.eps: %.jpg
	$(CONVERT) $< $@

%.svg.eps: %.svg
	$(INKSCAPE) -f $< -E $@

%.dvi: %.tex $(IMAGES_EPS)
	$(LATEX) $< || { rm -f $@; false; }
	$(LATEX) $< || { rm -f $@; false; }

%.ps: %.dvi
	$(DVIPS) -t$(PAPER) -Ppdf -o $@ $<

%.pdf: %.ps
	$(PS2PDF) $< $@

