Here is another kind of example, just to show that even if make normally is used in a programming environment, it may be used in any situation with file dependencies.
To try out this example, ImageMagick is required.
The Makefile below has been tested with MSYS make on MS Windows, but should work on UNIX as well.
To create and display the images, just type
make display
The Makefile tries to "guess" if the platform is MS Windows or UNIX. Anyhow, if you are using another version of ImageMagick (on MS Windows), or ImageMagick is installed in another path (on UNIX), you should override the MAGICK_VERSION variable (MS Windows), or the MAGICK_PATH variable (UNIX) from the command line, to suite your installation:
Windows, another version:
make display MAGICK_VERSION=imagemagick-7.8.9
UNIX, alternative path:
make display MAGICK_PATH=/usr/local/bin/
Makefile:
# Makefile for ImageMagick
# For MS Windows users only:
# Change this if you are using another version of ImageMagick.
MAGICK_WIN32 = imagemagick-6.3.5-q16
# Paths, some of them platform dependent.
WIN32_SUFFIX = .exe
SHELL_SUFFIX = $(suffix$(SHELL))
ifeq ($(WIN32_SUFFIX), $(SHELL_SUFFIX))
MAGICK_PATH = /c/program\ files/$(MAGICK_WIN32)/MAGICK_DISPLAY = imdisplayelseMAGICK_PATH = /usr/bin/MAGICK_DISPLAY = displayendifMAGICK_CONVERT = convert
MAGICK_COMPOSITE = composite
# Targets
HELLOWORLD = helloworld.png
HELLOWORLD_FLAGS = $(TILE) $(LABEL) -tile -compose Overlay
LABEL = label.png
LABEL_FLAGS = -fill dodgerblue -font 'Arial' -background black \
-pointsize 72 label:'Hello, world!' -bordercolor black \
-border 30x30 \( +clone -blur 0x25 -evaluate multiply 2 \) \
-compose screen -composite
TILE = tile.png
TILE_FLAGS = -background white -fill darkblue -font 'Arial' \
-pointsize 12 -size 70x -gravity Center caption:'Hello, world!'# Create the final image
# The prerequisites for this image is the label image and the tile (background) image.
$(HELLOWORLD): $(LABEL) $(TILE)
$(MAGICK_COMPOSITE) $(HELLOWORLD_FLAGS) $@@echo Type \'make display\' to display the images.# Create the label.
# There are no prerequisites needed to create this image.
$(LABEL):
$(MAGICK_PATH)$(MAGICK_CONVERT) $(LABEL_FLAGS) $@# Create the tile (background) image.
# There are no prerequisites needed to create this image.
$(TILE):
@echo Try to create $(TILE) manually, then type \'make\'.$(MAGICK_PATH)$(MAGICK_CONVERT) $(TILE_FLAGS) $@# Remove all images.
.PHONY : clean
clean:
rm -rf $(HELLOWORLD) $(LABEL) $(TILE)# Display all images
# The prerequisites for this target is the final, composed image.
# (The composed image, in turn, has the tile and label images as prerequisites.)
.PHONY : display
display: $(HELLOWORLD)
@echo When ready with the tile image, close the window to show the label image... $(MAGICK_PATH)$(MAGICK_DISPLAY) $(TILE)@echo When ready with the label image, close the window to show the composed image... $(MAGICK_PATH)$(MAGICK_DISPLAY) $(LABEL)@echo Close the composed image window to exit... $(MAGICK_PATH)$(MAGICK_DISPLAY) $(HELLOWORLD)@echo Good bye.