Comp 2673, Spring 2002
April 1, lecture notes

Recall from last week:
  We learned about g++ and some of its flags:
  % g++ foo.cpp
    compiles and links the source in foo.cpp, creates executable called a.out
  % g++ -o foo foo.cpp
    compiles and links foo.cpp, giving the executable the name foo
  % g++ -c foo.cpp
    does a separate compilation of foo.c, creating object file foo.o
  % g++ -o foo foo1.o foo2.o foo3.o 
    links all listed object files into an executable called foo
Now it's a pain to keep typing in these commands, so we use the program
called "make" along with a "makefile" to keep track of which files depends
on which files, and how to build the final program(s).  Let's look at the
simplest possible makefile: Makefile00.
(If you want to try running this yourself, then copy all files from makestuff.
These files can also be found in the directory ~ftl/public_html/courses/2673s02/makestuff)
The program "make" by default uses the file called "makefile" or "Makefile".
So we'll move Makefile00 to makefile.  To build the program greetme, we type
  % make greetme
Note:  if you want to specify a makefile to use other than the default, use
the -f flag for the program make, as in
  % make -f Makefile00 greetme
Now let's take separate compilation into account.  Look at and run
Makefile0
Now say that I have a program "gold" that depends on 5 .cpp files and
4 .h files.  How do I recompile?  What if a header changes?>
For this more complicated situation handled with make, look at Makefile1
And to add header dependencies, look at Makefile2