Advanced Exercises


7.

Modify the badtabs.c program (page 497) so that it exits cleanly (with a specific return value). Compile the program and run it using gdb or another debugger. What values does the debugger report when the program finishes executing?

8.

For the makefile

$ cat Makefile leads: menu.o users.o resellers.o prospects.o              gcc -o leads menu.o users.o resellers.o prospects.o menu.o: menu.h dialog.h inquiry.h users.o: menu.h dialog.h prospects.o: dialog.h


identify:

  1. Targets.

  2. Construction commands.

  3. Prerequisites.

9.

Refer to Makefile in exercise 8 to answer the following questions:

  1. If the target leads is up-to-date and you then change users.c, what happens when you run make again? Be specific.

  2. Rewrite the makefile to include the following macros:

    OBJECTS = menu.o users.o resellers.o prospects.o HFILES = menu.h dialog.h

10.

Review the make info page to answer the following questions:

  1. What does the t option do?

  2. If you have files named makefile and Makefile in the working directory, how can you instruct make to use Makefile?

  3. Give two ways to define a variable so that you can use it inside a makefile.

11.

Refer to the makefile for compute on page 492.

  1. Suppose that a file in the working directory is named clean. What is the effect of giving the following command? Explain.

    $ make clean

  2. The discussion on page 491 states that the following command is not normally seen in makefiles:

    cat num.h table.h > form.h

    What is the effect of removing this construction command from the makefile while retaining the dependency line?

  3. The preceding construction command works only because the file form.h is made up of num.h and table.h. More often #include directives in the target define the dependencies. Suggest a more general technique that updates form.h whenever num.h or table.h has a more recent modification date.




A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net