Advanced Exercises

 < Day Day Up > 


Modify the badtabs.c program (page 409) 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?


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 


  1. Targets.

  2. Construction commands.

  3. Prerequisites.


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 


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.


Refer to the makefile for compute on page 402.

  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 401 states that the following command is not normally seen in makefiles:

     cat num.h table.h > form.h 

    Discuss 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.

     < Day Day Up > 

    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213 © 2008-2017.
    If you may any questions please contact us: