############################################################################## # # Sample Makefile for C++ applications # Works for single and multiple file programs. # for use with Unix/Linux and # "A Computer Science Tapestry: # Exploring Programming and Computer Science with C++" (second edition) # Owen Astrachan/McGraw-Hill # ############################################################################## # For use with multiple file projects consider # using 'make depend' to generate dependencies # # ############################################################################## # Application specific variables # EXEC is the name of the executable file # SRC_FILES is a list of all source code files that must be linked # to create the executable ############################################################################## EXEC = huff SRC_FILES = plainhuff.cpp apstring.cpp bitops.cpp globals.cpp ############################################################################## # Where to find course related files # for CS machines # COURSE_DIR = . ############################################################################## # Compiler specifications # These match the variable names given in /usr/share/lib/make/make.rules # so that make's generic rules work to compile our files. # gmake prefers CXX and CXXFLAGS for c++ programs ############################################################################## # Which compiler should be used CCC = g++ CXX = $(CCC) # What flags should be passed to the compiler # # DEBUG_LEVEL = -g EXTRA_CCFLAGS = -Wall CCFLAGS = $(VERBOSE) $(DEBUG_LEVEL) $(EXTRA_CCFLAGS) CXXFLAGS = $(CCFLAGS) # What flags should be passed to the C pre-processor # In other words, where should we look for files to include - note, # you should never need to include compiler specific directories here # because each compiler already knows where to look for its system # files (unless you want to override the defaults) CPPFLAGS = -I. \ -I$(COURSE_DIR) # What flags should be passed to the linker # In other words, where should we look for libraries to link with - note, # you should never need to include compiler specific directories here # because each compiler already knows where to look for its system files. LDFLAGS = -L. \ -L$(COURSE_DIR) # add \ to end of line above and # uncomment the line below on suns with shared libraries # -R $(LIBDIR):$(COURSE_DIR) # What libraries should be linked with #LDLIBS = -ltapestry LDLIBS = # All source files have associated object files LIBOFILES = $(LIB_FILES:%.cpp=%.o) OFILES = $(SRC_FILES:%.cpp=%.o) .SUFFIXES: .cpp .cpp.o: $(LINK.cc) -c $< .cpp: $(LINK.cc) $< -o $@ $(LDLIBS) ########################################################################### # Additional rules make should know about in order to compile our files ########################################################################### # exec depends on the object files $(EXEC) : $(OFILES) $(LINK.cc) -o $(EXEC) $(OFILES) $(LDLIBS) # to use 'makedepend', the target is 'depend' # uncomment the two lines below depend: makedepend -- $(CXXFLAGS) -- -Y $(SRC_FILES) libtapestry.a: $(LIBOFILES) rm -f $@ ar cq $@ $(LIBOFILES) # clean up after you're done clean : $(RM) $(OFILES) $(EXEC) core *.rpo # DO NOT DELETE THIS LINE -- make depend depends on it.