I had a directory of BMP image files that I wanted to convert to EPS (Encapsulated PostScript). Since I was planning on adding files to the directory, I did not want to hard code the names of the files into the makefile that would do the conversion. Therefore, the trick was to run a shell command inside of the makefile. The first line lists all of the BMP files and assigns it to “BMP_FILES”. The next line replaces the “bmp” extension with “eps”. The complete makefile is below.
BMP_FILES = $(shell ls *.bmp) EPS_FILES = ${BMP_FILES:%.bmp=%.eps} all: ${EPS_FILES} %.eps : %.bmp convert $*.bmp $*.eps
All that is left is to type “make” in the directory, and all of the BMP files will be converted to EPS.