# # This is a more sophisticated makefile for qdp applications. # This version generates dependencies automatically, rather # than having to list them explicitly in the makefile. # # # First we need to tell the makefile where to find the libraries. # For this example, we are specifying that qdp is in a subdirectory of # the user's home directory; in an installed version, it would be under # /usr/local/lib # LDFLAGS=-L${HOME}/qcd/src/qdp++/lib -lqdp # # Here we specify the additional path for include files. Again we # have it under the user's home directory, but an installed version # would place things under /usr/local/include # CXXFLAGS=-I${HOME}/qcd/src/qdp++/include/ # # Here we list the source routines; note that I keep the sources # for the main programs separately, denoted by main_src sources= mesplq.cc main_src= t_mesplq.cc # # Now the derived files: # # First the object files objects = $(sources:.cc=.o) # # The various rules for producing derived files # # The dependency files, containing a list of dependencies that will be # included in the makefile below. This is the modern equivalent of # makedepend. %.d: %.cc @ $(CXX) -MM $(CXXFLAGS) $< -o $@ # # The object files %.o: %.cc $(CXX) ${CXXFLAGS} -c $< -o $@ # # The main programs all: t_mesplq .PHONY: all clean t_mesplq: t_mesplq.o ${objects} $(CXX) $(CXXFLAGS) -o $@ $< ${objects} ${LDFLAGS} # Yes, cleanup clean: rm -f t_mesplq *.o *.d # # Now list the dependencies. This is the "modern" equivalent # of the old "makedepend" command that avoids us having to specify # the header files explicitly. We have one dependency file for # each source file -include $(sources:.cc=.d) $(main_src:.cc=.d)