################################# # Generic parts of a C++ makefile ################################# CCC=/local/bin/g++ INCLUDEFLAGS= CDEBUGFLAGS=-g CCFLAGS= ${CDEBUGFLAGS} ${INCLUDEFLAGS} LDLIBS = LDDirs = LDFLAGS = ${LDDIRS} ${LDLIBS} # LINK.cc - how we link source and object files into an executable # LINK.cc=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDDIRS) $(TARGET_ARCH) # COMPILE.cc how we compile source files into .o's # COMPILE.cc=$(CCC) $(CCFLAGS) -c # This rule allows us to execute 'make file' to compile the contents of # 'file.c' using and link the executable as 'file' # .c: $(LINK.cc) -o $@ $< $(LDLIBS) # This rule allows us to execute 'make file.o' to compile the contents of # 'file.c' and leave the resulting (unlinked) object file in 'file.o' # .c.o: $(COMPILE.cc) $(OUTPUT_OPTION) $< ####################################### # Project specific part of the makefile ####################################### # This notes our two object files # OBJS = main.o card.o # This indicates that our target program, Card, depends on the object files # OBJS and that it is made by linking the two object files together # and placing the executable result in file 'Card' # Card: $(OBJS) $(LINK.cc) -o Card $(OBJS) $(LDLIBS) # This shows the dependencies for the OBJS object files # Each of the object files depends on its associated .c file and # any .h files it might include (whether directly or indirectly) # main.o: main.c card.h card.o: card.c card.h