Unix Lab 4: make

CS 245

Nov. 25, 2002

In this lab you will learn how to set up dependencies within a make file.

  1. Log into your account on black and create a directory for this lab. cd to this directory.

  2. Copy the file ~kelliher/pub/cs245/Makefile into the directory you just created and open it for editing.

  3. We want to implement this dependency graph:

    1. Note that two of the edges are redundant. Which two and why?

    2. To make a target, we will simply touch it. For example, if the target x depends upon the files y and z we need the following entry in the make file:
      x: y z
         touch x
      
      Remember, the command line must begin with a Tab character and target specifications must be separated by at least one blank line.

      Don't forget that the leaf targets must appear as targets with empty command lists.

    3. Edit the Makefile, adding the required targets.

  4. To test your set of dependencies, save your file and run the following from a shell prompt:
    make all
    
    This will create the necessary test files, run a suite of tests, and remove the test files. (Check the make file for the details.)

    For easy viewing, you may find it convenient to pipe the output to a pager:

    make all | less
    

    Notice that for each test run, the output will tell you what file was touched before a is made. Using this information, as well as the dependency graph, you should be able to determine if the correct files are being re-made and if they're being re-made in the correct order.

  5. To verify that you've correctly implemented the dependency graph run the following commands:
    make all > results
    
    diff -w ~kelliher/pub/cs245/makeResults results
    
    If diff runs without producing any output, you've passed the test. Otherwise, compare your result file with my result file then correct your make file.



Thomas P. Kelliher
Thu Nov 21 08:16:44 EST 2002
Tom Kelliher