# makefile.detailed ... created by renner 10/10/02 # makefile.detailed is designed as a SAMPLE TEMPLATE for # making a program from multiple class definitions # To use it... you would need to substitute appropriate replacements # for 'makefile.detailed'; 'myprogram'; 'mainDriver'; 'Class1'; 'Class2' # Supply or remove comment lines (#) as desired # To execute this program after it is built by the make you would type: # 'myprogram' (no quotes) # because 'myprogram' is the executable program after running 'make' or # 'make myprogram' # To 'make myprogram', you would have all the necessary files 'myprogram' # depends on in the current directory # (unless you specify otherwise in your makefile) # rename your makefile.detailed to 'makefile' # The FIRST line of each section indicates the DEPENDENCIES # The SECOND line of each section indicates the COMMAND LINE # *** ALL COMMAND LINES MUST START WITH A TAB, NOT SPACES!!!*** # If a DEPENDENCY does not exist in the current directory, # the makefile utility will try to 'make' it by finding its # tag in the makefile and performing the related action. # IF the tag for this DEPENDENCY has dependencies of its # own, they must be checked/created first, and so on... # In this case, 'myprogram' DEPENDS on mainDriver.o, Class1.o, and Class2.o # Either they must be current and pre-existing, or the compiler # must try to 'make' them. The command to do so is written in # section 1, and links the 3 files (see Section 1): # g++ -o myprogram mainDriver.o Class1.o Class2.o # Note: the '-o' generates the 'myprogram' name for the executable # Likewise, the DEPENDENCIES for mainDriver.o are mainDriver.cxx, # Class1.h and Class2.h (all must be available in the directory to continue, # it is assumed that this will be the file that houses the 'main' function). # The command line for creating mainDriver.o is: # g++ -c mainDriver.cxx # the -c option creates an object file for mainDriver.cxx, because # it specifically chooses to compile only. (see Section 2) # Likewise, Class1.o depends on Class1.cxx and Class1.h # The command line for creating Class1.o is: (Section 3) # g++ -c Class1.cxx # Class2.o depends on Class2.cxx and Class2.h # the command line for creating Class2.o is: # g++ -c Dice.cpp (Section 4) # The 'clean' tag is there for convenience. At any time, type # 'make clean' (no quotes) at the command prompt, to remove # such things as: core files, object files, executable files,... # (see Section 5). # Section 1 myprogram: mainDriver.o Class1.o Class2.o g++ -o myprogram mainDriver.o Class1.o Class2.o # Note: Previous command line starts with a tab as ALL command lines # in the makefile must do! # Section 2 mainDriver.o: mainDriver.cxx Class1.h Class2.h g++ -Wall -c mainDriver.cxx # Section 3 Class1.o: Class1.cxx Class1.h Class2.h g++ -Wall -c Class1.cxx # Section 4 Class2.o: Class2.cxx Class2.h g++ -Wall -c Class2.cxx # Section 5 # add a 'clean' option, to remove all core or object files and free up space clean: rm -f *.o core