CIS 330 Home Page Last updated 2008/02/08 11:08:51

CIS 330 Assignment 4

Makefiles

Use the web service e-turnin to submit your work electronically. You may turn in revisions of your homework up to the time it is due.


  1. Write a Makefile to build all of the programs for Assignment 2. The default target in the Makefile should make all of the programs. Be sure to specify proper dependencies so that if any source is changed, only the dependent targets are re-built. Your Makefile should have the following high level targets:
    all
    Builds the programs for the assignment. You should also include separate targets for each problem program
    clean
    Removes intermediate objects - leaving only source and final products
    clobber
    Removes all created objects - leaving only source
    test1, test2, test3, test4
    Each of these should run a test or tests for the indicated problem
    test
    Run all of the tests

    Naturally, the tests are dependent on their corresponding problem program.

    Use makefile macros to parameterize your Makefile appropriately. For example, you should be able to switch between the Solaris and Gnu compilers without editing the Makefile.

    Use the published Assignment 2 solution source along with the driver code from the assignment for checking your solution. Note that the array3d code in the published solution uses the array2d solution. The drivers for the first three problems should be named ilistTest, array2dTest, and array3dTest with the corresponding source files named similarly. The fourth problem solution should consist of just one source file named quicksortTest.c and the resulting executable named quicksortTest.


  2. Write a high level Makefile that can build all of the assignment solutions for the course. That is, the default target should be to descend into each assignment subdirectory and build that assignment's solution, using a makefile in the subdirectory. Assume the assignment directories are named hw1, hw2, hw3, etc. Your high level Makefile should have targets all, clean, clobber, and test.

    Test your solution with two assignment subdirectories, but be sure it will work with additional directories with a minimum of editing of the makefile.

    See if you can use the special makefile macros for current dependent and target and so avoid duplication in the makefile for different assignments.


  3. Write a shell script that can rename a set of JPG files in a directory. The script should take two arguments: the pattern of the name of the files to be renamed, and the new base name for the renaming. The new names should consist of the the new base name given followed by a two digit sequence number (and then the suffix ".jpg"). The sequencing should reflect the chronological ordering of the files, i.e., it should be the same order as the modification times of the files.

    Here is an example scenario for this script. Suppose I have a directory of digital photos. When I unload pictures from my camera into this directory, the file names are not very useful since my camera names the files as CIMG0005.JPG, CIMG0006.JPG, etc. The pictures are from a trip to Yosemite, so I would like them all to be named yosemite01.jpg, yosemite02.jpg, etc. I can do this with my shell script by executing it as follows:

    rename.sh 'CIMG*' yosemite
    
    If there were N jpg files beginning with CIMG, this should produce a set of N files named yosemite01.jpg, yosemite02.jpg, ..., yosemiteNN.jpg Note that the N CIMG files need not have been a continuous sequence numbered 1 through N since I may have deleted files on the camera, creating holes in the numbering sequence. But I do want the renamed files to be a continuous numbering sequence from 1 to N.

    Note - it is safest to work on this shell script in an empty directory so that you don't inadvertenly remove or rename files as you work the bugs out of your script.

    Your shell script should work with the standard Unix shell /bin/sh.