Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
# http://angg.twu.net/SCANS/Makefile.html
# http://angg.twu.net/SCANS/Makefile
#         (find-angg "SCANS/Makefile")
# 2012mar20

# Obsolete. See: (find-angg "bin/djvuize")

# (find-angg "LATEX/Makefile")
# (find-node "(make)")
# (find-node "(make)Automatic Variables")
# (find-node "(make)Automatic Variables" "$@" "target of the rule")
# (find-node "(make)Automatic Variables" "$<" "first prerequisite")
# (find-node "(make)Automatic Variables" "$*" "stem")

# (find-node "(make)Recursion")
# (find-node "(make)Special Targets" ".PRECIOUS")
# (find-node "(make)Chained Rules" ".SECONDARY")

# (find-man "1 convert" "-despeckle")
# (find-es "scan" "tesseract")

# Quick index:
# «.wildcards»		(to "wildcards")
# «.all.djvu»		(to "all.djvu")
# «.pdf»		(to "pdf")
# «.extract-page»	(to "extract-page")



# «wildcards»  (to ".wildcards")
JPGS     =                        $(wildcard *.jpg)
PBMS     = $(patsubst %.jpg,%.pbm,$(wildcard *.jpg))
DJVUS    = $(patsubst %.jpg,%.djvu,$(wildcard *.jpg))
DJVU150S = $(patsubst %.jpg,%_150.djvu,$(wildcard *.jpg))
DJVU300S = $(patsubst %.jpg,%_300.djvu,$(wildcard *.jpg))
DJVU400S = $(patsubst %.jpg,%_400.djvu,$(wildcard *.jpg))
DJVU600S = $(patsubst %.jpg,%_600.djvu,$(wildcard *.jpg))
DJVUG300S = $(patsubst %.djvu,%_g_300.djvu,$(wildcard *.djvu))
djvus: $(DJVUS)
djvu150s: $(DJVU150S)
djvu300s: $(DJVU300S)
djvu400s: $(DJVU400S)
djvu600s: $(DJVU600S)
djvug300s: $(DJVUG300S)

.PRECIOUS: %_4.jpg %_4.por.txt

%_2.jpg: %.jpg
	convert $< -resize 50% $@
%_m2.jpg: %.jpg
	convert $< -median 1 -resize 50% $@
%_4.jpg: %.jpg
	convert $< -resize 25% $@
%_8.jpg: %.jpg
	convert $< -resize 12.5% $@
%_d4.jpg: %.jpg
	convert $< -despeckle -resize 25% $@
%.pgm: %.jpg
	convert $< $@
%.pbm: %.pgm
	mkbitmap -x -f 50 -t 0.4 $< -o $@
#
PNGDJVUS = $(patsubst %.png,%_200.djvu,$(wildcard *.png))
pngdjvus: $(PNGDJVUS)
%.pgm: %.png
	convert $< $@
%.pgm: %.PNG
	convert $< $@

# (find-es "scan" "tesseract")
%.tif: %.jpg
	convert $< $@
%.eng.txt: %.tif
	tesseract $< $*.eng -l eng
%.por.txt: %.tif
	tesseract $< $*.por -l por

# For Ricardo Pereira, 2011dec20
#%.pgm: %.tif
#	convert $< $@

# 2010nov04
%.pgm: %.r.pbm
	convert $< -resize 50% $@
# 2010nov17, for things scanned on the W$ machine at PURO
%.pbm: %.BMP
	convert $< $@
# (find-eeshell "cd caderno3/\nlaf\nmake -f ../Makefile caderno4_0{1,2,3,4,5,6}_600.djvu")

# The dpi count will be wrong if we shrink first (with _4)
%_1200.djvu: %.pbm
	cjb2 -dpi 1200 -lossy $< $@
%_600.djvu: %.pbm
	cjb2 -dpi 600 -lossy $< $@
%_400.djvu: %.pbm
	cjb2 -dpi 400 -lossy $< $@
%_300.djvu: %.pbm
	cjb2 -dpi 300 -lossy $< $@
%_200.djvu: %.pbm
	cjb2 -dpi 200 -lossy $< $@
%_150.djvu: %.pbm
	cjb2 -dpi 150 -lossy $< $@


# «all.djvu»  (to ".all.djvu")
# This one (all.djvu) is a dirty trick:
all.djvu:
	echo *_*.djvu
	djvm -create all.djvu *_*.djvu
# Slightly cleaner...
%.djvu: %_1.djvu
	echo $*_*.djvu
	djvm -create $@ $*_*.djvu
# (find-fline "~/SCANS/caderno3/")
# (find-eeshell "cd caderno3/\nlaf\nmake -f ../Makefile C2_subconjuntos_2010nov17.{djvu,pdf}")
# (find-eeshell "cd caderno3/\nlaf\nmake -f ../Makefile MD_sists_dedutivos_2010nov17.{djvu,pdf}")


# «pdf»  (to ".pdf")
%.pdf: %.djvu
	ddjvu -format=pdf $< $@


# A way to convert a single-page grayscale .djvu file to monochrome.
# Usage: if we have "page.djvu", then "make page_g_300.djvu" will do.
%_g.pgm: %.djvu
	ddjvu -format=pgm $< $@
%_b.pbm: %.djvu
	ddjvu -format=pbm $< $@


# «extract-page»  (to ".extract-page")
# (find-es "scan" "extract-pages")





# %.4por: %_4.jpg %_4.por.txt
#	$(MAKE) $*_4.jpg $*_4.por.txt

# (find-angg "SCANS/")
# (find-angg "SCANS/serfelizhoje/")
# (find-efunction 'find-eeshell)
# (find-eeshell "cp -v /tmp/scans/p050.jpg .\nlaf\nmake p050.4por\nlaf")





# Local Variables:
# coding:               raw-text-unix
# ee-anchor-format:     "«%s»"
# End: