Next: Protocol Scheduling
Up: Developer's Guide
Previous: Overview
The gated building process allows the compilation of
gated for different architectures using the same source tree. Each different
system can use a subdirectory of the src directory to compile
the source files into architecture dependent object files.
Moreover the list of files to be compiled, and their content are
dependent on the list of protocols the user chooses to configure in his
Config file.
The 'make config' process is in charge of configuring the object
directory with the set of files needed for a certain configuration as
well as creating certain files used during the building process.
The 'make config' process creates the following files:
- obj/defines.h contains a list of #define clauses to
be included in all the C source code. The value of those #define
are generated from the options statements in the Config
file as well as from the protocol statements.
- obj/paths.h contains a list of paths for different files gated
uses, like the config file, dump file, etc... It is generated
from src/paths.h by substitution (C.f. section 7.2.4).
- obj/version.c contains a list of version numbers for each source
file as well as for the gated release. The version numbers
are embedded in C string constants to be hardcoded in the gated
binary.
- obj/parser.y is the real yacc source file to generate
the parser for gated. It is generated from src/parser.y
by substitution (C.f. section 7.2.4).
- obj/signames.c is the C declaration of the sys_signame[]
variable if the system does not support it. signames.c is
generated from <signal.h> only if the NEED_SIGNAME option
is defined in the Config file.
- obj/Makefile is the make rule file used to build
gated. It is generated from util/Makefile.temp by
substitution (C.f. section 7.2.4) and contains only the rule
for the configured source files.
- obj/*.c obj/*.h obj/*.y obj/*.l A set of symbolic link to
the source files in src/.
The files needed for this configuration process are
- util/configure.pl A perl script doing the configuration.
- util/Makefile.templ A template for the Makefile.
- util/files The list of files to compile. The list is sorted by
protocols.
- parser.y is the full yacc source file with support for all
protocols.
- *.c *.h All the source files in the scr/ directory.
To summarize, when executing make config the
util/configure.pl script is first ran. This script will
- find out about the current directory and the object directory used
for that system,
- generate all the files previously listed in the object directory.
Then a make config will be executed in the object directory.
This process will
- clean up the object directory,
- create parser.c and parser.h by running yacc/bison
on parser.y.
- create the symbolic links,
- compute the file dependencies by running the mkdep command.
The object directory Makefile defines the following target
for any program to be built. Other can be added on a case by case rule.
- all:: Default target when executing make.
- lint:: Used when checking the code with lint(1).
- install:: Used to install the software's executable.
- install-man:: Used to install the software's manual pages and
documentation
- clean:: Used to clean up the directory.
- cleanall:: A better clean than clean::. clean::
removes only object files. cleanall:: removes any file which
can be generated from the original distribution.
Some files in the distribution package are run through a filter
to obtain a version with only the support of the user configured protocols.
For example if only rip and bgp are needed then the resulting
file will only contain the code for RIP and BGP, which makes the final
binary smaller. The general syntax for filtering in or out some part of
the code is similar to the C processor. The syntax is:
@BEGIN [NOT] SYMBOL [| SYMBOL2...]
text...
@END
The text in between @BEGIN and @END will be kept if
the symbol SYMBOL (or SYMBOL2...) is defined. Those symbols
are any variable, protocol or option defined in the Config file. They include
program names ( cc, lex...), directory or file names (
path_config, mandir, ...), options ( NEED_STRERROR,
POSIX_SIGNALS, ...) and protocols ( bgp, rip, ...). For the
later the symbol to add after @BEGIN is PROTO_BGP for bgp,
PROTO_RIP for rip, etc... (See the %proto definition
in util/configure.pl for the equivalence between protocol names
and symbols).
Also some generic name (as the dump file name, configuration file
name, etc...) are replaced by they real value chosen by the user.
If the source file contain the tokens @(symbol) then this
token will be replaced by the value of symbol defined in the Config
file. For instance, if the Config file contains
path_config /etc/\%s.conf
and the file paths.h contains
#define _PATH_DUMPDIR "@(_path_dumpdir)"
then the resulting file will be
#define _PATH_DUMPDIR "/etc/\%s.conf"
[ Note: trailing '_' are ignored and substitution is
case insensitive.]
The following are recommendations to install a new protocol support into
gated:
- Define a name for the protocol be be used in the Config file,
and add this name the the %proto definition
in util/configure.pl. Also if any new option is needed in
the Config file add the default value to the %options table.
You also may want to look at the %dirPath (directories
and files used to configure the Makefile), runtimePath
(directories and files to be hardcoded in paths.h),
%miscParam (some more parameters for the Makefile),
%unixCmd (Unix commands for the Makefile),
%cmdFlags (flags for the Unix commands).
- Add all the new source files (C, yacc, etc... code) into the
util/files file using the syntax defined in section 7.2.4.
- Modify util/Makefile.temp to add any new target.
- Update parser.y to add support for the new protocol configuration
into the gated parser. Conditional compilation can be done by
using the syntax defined in section 7.2.4.
Next: Protocol Scheduling
Up: Developer's Guide
Previous: Overview
Blair Zajac
Thu Mar 14 16:01:37 PST 1996