PKGS = array avl graph heap list sparse st util var_set MAKEINCLUDES = \ $(foreach package, $(PKGS), \ $(package)/$(package).make ) include $(MAKEINCLUDES) INCLUDEDIRS = $(foreach package, $(PKGS), -I./$(package)) #---------------------------------------------------------------------- # The value of the make variable VPATH specifies a list of directories # that make should search. # http://www.gnu.org/software/make/manual/make.html#General-Search #---------------------------------------------------------------------- VPATH = $(foreach package, $(PKGS), $(package)) #---------------------------------------------------------------------- # The directory where the object files (.o files) will be kept #---------------------------------------------------------------------- objectdir = obj #---------------------------------------------------------------------- # Define the set of all object files. # # For details on the addprefix function refer to # http://www.gnu.org/software/make/manual/make.html#File-Name-Functions # # For details on the substitution $(CSRC:.c=.o) refer to # http://www.gnu.org/software/make/manual/make.html#Substitution-Refs # #---------------------------------------------------------------------- OBJECTS = $(addprefix $(objectdir)/,$(CSRC:.c=.o)) #---------------------------------------------------------------------- # The name of the product and its version #---------------------------------------------------------------------- PRODUCT = glu VERSION = 2.1 #---------------------------------------------------------------------- # Name of the library to create #---------------------------------------------------------------------- LIBRARY = lib$(PRODUCT)-$(VERSION).a #---------------------------------------------------------------------- # Compiler/lib creation/archiver tools #---------------------------------------------------------------------- CC = gcc RANLIB = ranlib AR = /usr/bin/ar #---------------------------------------------------------------------- # C compiler flags #---------------------------------------------------------------------- CFLAGS = -g $(INCLUDEDIRS) #---------------------------------------------------------------------- # For compiling a source file into the object directory # # The % sign below is a wildcard. For details on this construct see # http://www.gnu.org/software/make/manual/make.html#Pattern-Rules # # The command uses the automatic variables `$@' and `$<' to substitute # the names of the target file and the source file in each case # where the rule applied. For details see # http://www.gnu.org/software/make/manual/make.html#Pattern-Rules # #---------------------------------------------------------------------- $(objectdir)/%.o : %.c $(CC) -c $(CFLAGS) -o $@ $< #---------------------------------------------------------------------- # Create a library (which is just a set of object files, created by ar, # and an index into the functions in these files, created by ranlib # # The $^ variable is all the pre-requisites. For details see # http://www.gnu.org/software/make/manual/make.html#Automatic-Variables #---------------------------------------------------------------------- %.a : rm -f $@ umask 2; $(AR) cq $@ $^ $(RANLIB) $@ #---------------------------------------------------------------------- # The library we are trying to create depends on the object files. # We don't need to specify the build process because that's specified # automatically above. #---------------------------------------------------------------------- $(LIBRARY) : $(OBJECTS) #---------------------------------------------------------------------- # clean - remove all object files, libraries #---------------------------------------------------------------------- clean: rm $(OBJECTS) *.a #---------------------------------------------------------------------- # debug - Print a list of Makefile variables, useful for # debugging the make process #---------------------------------------------------------------------- DEBUG_VARS = CSRC HEADERS objectdir CC CFLAGS RANLIB AR \ PRODUCT LIBRARY OBJECTS MAKEINCLUDES VPATH debug: @$(foreach var, $(DEBUG_VARS), echo $(var)=$($(var)) ; )