converters using make-files

I sometimes need to convert a lot of files from one format to another. When the task is a one-time task, it's better to use the "for" loop in shell, but when the task is repeating, it's better to use a make file. Here is one of such make files.

dvi_files := $(wildcard *.dvi)
eps_files = $(patsubst %.dvi,%.eps,$(dvi_files))

all: $(eps_files)

%.eps: %.dvi
  dvips -E -f $<  >$@

The first line gets a list of all the source files. The second line creates a list of the target files. The first rule says that the default goal "all" requires all the target files. The final rule speficies how to convert from a source file to the correspoding target file.

Categories:

Updated: