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
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
obj/parser.y is the real yacc source file to generate
the parser for gated for the selected protocols. 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
rules 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 is a perl script doing the configuration.
util/Makefile.templ is a template for the Makefile.
util/files is the list of files to compile. The list is sorted by
parser.y is the full yacc source file with support for all
*.c *.h are all the source files in the scr/ directory.
To summarize, when executing make config the
util/configure.pl script is first run. 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 or
bison on parser.y.
create the symbolic links,
compute the file dependencies by running the mkdep command.
Some files in the distribution package are run through a filter
to obtain a version which only supports 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...]
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
Also some generic names (as the dump file name, configuration file
name, etc...) are replaced by their real value chosen by the user.
If the source file contains 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
and the file paths.h contains
#define _PATH_CONFIG "@(_path_config)"
then the resulting file will be
#define _PATH_CONFIG "/etc/\%s.config"
[ Note: trailing '_' are ignored and substitution is
The following are recommendation to install a new protocol into
Define a name for the protocol to be used in the Config file,
and add this name to 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.