OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Examining The Source Tree

Unpacking the tar file results in the creation of a new directory, named diction-1.11. This directory contains the source tree. Let’s look inside:


[me@linuxbox src]$ cd diction-1.11

[me@linuxbox diction-1.11]$ ls

[me@linuxbox src]$ cd diction-1.11

[me@linuxbox diction-1.11]$ ls


config.guess diction.c

config.h.in diction.pot config.sub diction.spec configure diction.spec.in configure.in diction.texi.in COPYING en

de en_GB

de.po en_GB.po diction.1.in getopt1.c

getopt.c

getopt.h getopt_int.h INSTALL

install-sh Makefile.in misc.c misc.h NEWS

nl

nl.po README

sentence.c sentence.h style.1.in style.c test

config.guess diction.c

config.h.in diction.pot config.sub diction.spec configure diction.spec.in configure.in diction.texi.in COPYING en

de en_GB

de.po en_GB.po diction.1.in getopt1.c


image

In it, we see a number of files. Programs belonging to the GNU Project, as well as many others, will supply the documentation files README, INSTALL, NEWS, and COPYING. These files contain the description of the program, information on how to build and in- stall it, and its licensing terms. It is always a good idea to carefully read the README and INSTALL files before attempting to build the program.


The other interesting files in this directory are the ones ending with .c and .h:


[me@linuxbox diction-1.11]$ ls *.c

diction.c getopt1.c getopt.c misc.c sentence.c style.c [me@linuxbox diction-1.11]$ ls *.h

getopt.h getopt_int.h misc.h sentence.h

[me@linuxbox diction-1.11]$ ls *.c

diction.c getopt1.c getopt.c misc.c sentence.c style.c [me@linuxbox diction-1.11]$ ls *.h

getopt.h getopt_int.h misc.h sentence.h


The .c files contain the two C programs supplied by the package (style and dic- tion), divided into modules. It is common practice for large programs to be broken into smaller, easier to manage pieces. The source code files are ordinary text and can be ex- amined with less:


[me@linuxbox diction-1.11]$ less diction.c

[me@linuxbox diction-1.11]$ less diction.c


The .h files are known as header files. These, too, are ordinary text. Header files contain descriptions of the routines included in a source code file or library. In order for the com - piler to connect the modules, it must receive a description of all the modules needed to complete the entire program. Near the beginning of the diction.c file, we see this line:



#include "getopt.h"

#include "getopt.h"


This instructs the compiler to read the file getopt.h as it reads the source code in diction.c in order to “know” what’s in getopt.c. The getopt.c file supplies routines that are shared by both the style and diction programs.

Above the include statement for getopt.h, we see some other include statements such as these:



#include <regex.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <regex.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>


These also refer to header files, but they refer to header files that live outside the current source tree. They are supplied by the system to support the compilation of every program. If we look in /usr/include, we can see them:


[me@linuxbox diction-1.11]$ ls /usr/include

[me@linuxbox diction-1.11]$ ls /usr/include


The header files in this directory were installed when we installed the compiler.


Top OS Cloud Computing at OnWorks: