# Makefile to compile and render RenderMan # program to render from .rib, # add current directory to search path for shaders RENDER = SHADERS=.:@ $(DELIGHT)/bin/renderdl # flags for compiling CFLAGS = -I$(DELIGHT)/include -g LDFLAGS = -L$(DELIGHT)/lib -g LDLIBS = -l3delight -lm # files and intermediate files we create # for those who are not familiar with make: # $(IMAGES) will be the list of images # $(IMAGES:.tif=.o) will be the list of images with each .tif changed to .o # (so square.o persp.o ...) IMAGES = square.tif persp.tif sphere.tif cube.tif cube2.tif OBJS = $(IMAGES:.tif=.o) PROGS = $(IMAGES:.tif=.gen) RIBS = $(IMAGES:.tif=.rib) # make dependency: dummy target "all" depends on all of the images # so "make all" will make all images. Also, since this is the first # target in the file, just "make" is the same as "make all" all: $(IMAGES) # rules for actually building -- ordered from final output to original # .c for no particular reason other than that the first rule is the # default # any .tif image from the .rib with the same name # in "pattern" rules like this, $@ is the target (e.g. square.tif) # while $< is the thing it is built from (e.g. target.rib) %.tif: %.rib $(RENDER) $< # .rib from program %.rib: %.gen ./$< # program from .o %.gen: %.o $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS) # .o from .c %.o: %.c $(CC) -c $(CFLAGS) $< # add to the list of file suffixes that make should automatically # figure out (rather than having to explicitly say that square.rib # can be built from square.gen, if it has a .o and it needs a .rib, # it'll figure out that it can get there by building the .gen first) .SUFFIXES: .tif .rib .gen # don't automatically remove the rib files that were created as # intermediate steps. Otherwise, if you're building the .tif from the # .c, it tries to clean up all intermediate files that it created to # get there. It WILL clean up the programs and object files, so if # you want to work with those, you should explicitly make them ("make # square.gen" to get square.gen, rather than "make square.tif" with # square.gen created as an intermediate file) .PRECIOUS: $(RIBS) # these final rules delete generated files. The first leaves the rib # and image files clean: rm -f *~ *.o $(PROGS) # this one removes everything clean does, plus the rib and image # files -- basically anything we know how to rebuild clobber: clean rm -f $(RIBS) $(IMAGES)