tcc
's behaviour, namely tcc
environments.
An environment is just a file consisting of lines of the form:
*IDENTIFIER "text"where
*
stands for one of the environment prefixes, +
,
<
and >
(in fact ?
is also a valid environment prefix. It is
used to query the values represented by environmental identifiers.
If tcc
is invoked with the -Ystatus command-line option it
will print the values of all the environmental identifiers it recognises).
Any line in the environment not beginning with one of these characters
is ignored. IDENTIFIER
will be one of the environmental
identifiers recognised by tcc
, the environment prefix
will tell tcc
how to modify the value given by this identifier,
and text
what to modify it by.
The simplest environmental identifiers are those which are used to
pass flags to tcc
and the various components of the compilation
system. The line:
+FLAG "text"causes
text
to be interpreted by tcc
as
if it was a command-line option. Similarly:
+FLAG_TDFC "text"causes
text
to be passed as an option to tdfc
.
There are similar environmental identifiers for each of the components
of the compilation system (see 7.6 for a complete list).The second class of environmental identifiers are those corresponding to simple string variables. Only the form:
+IDENTIFIER "text"is allowed. This will set the corresponding variable to
text
.
The permitted environmental identifiers and the corresponding variables
are:ENVDIR
the default environments directory (see section
4.1),
MACHINE the target machine type (see section 4.2), PORTABILITY the producer portability table (see section 5.1.3), TEMP the default temporary directory (see section 6.4), VERSION the target machine version (Mips only, see section 5.3.4).The final class of environmental identifiers are those corresponding to lists of strings. Firstly
text
is transformed into
a list of strings, b say, by splitting at any spaces, then the list
corresponding to the identifier, a say, is modified by this value.
How this modification is done depends on the environment prefix:
+
then a = b,
>
then a = a + b,
<
then a = b + a,
TDFC
, TLD
, etc. (see 7.6 for
a complete list). The other lists can be divided between those affecting
the producer, the TDF linker, and the system linker respectively (see
sections 5.1, 5.2 and 5.5 for more details):
INCL list of default producer include file directories (as -I options), STARTUP list of default producer start-up files (as -f options), STARTUP_DIR list of default producer start-up directories (as -I options), LIB list of default TDF libraries (as -l options), LINK list of default TDF library directories (as -L options), CRT0 list of default initial .o files, CRT1 second list of default initial .o files, CRTN list of default final .o files, SYS_LIB list of default system libraries (as -l options), SYS_LIBC list of default standard system libraries (as -l options), SYS_LINK list of default system library directories (as -L options).
tcc
to read the environment env. If env is not a full pathname
then it is searched for along the environment search path. This consists
of a colon-separated list of directories, the initial segment of which
is given by the system variable TCCENV
(we use the term "system variable" to describe TCCENV
rather than the more normal "environmental variable" to
avoid confusion with tcc
environments) if this is defined,
and the final segment of which consists of the default environments
directory, which is built into tcc
at compile-time, and the current working directory. The option -show_env
causes tcc
to print this environment search path. If
the environment cannot be found, then a warning is issued.). There is an important distinction
to be made between base APIs (for example, POSIX) and extension APIs
(for example, X11 Release 5). The command-line option -Yposix
sets the API to be precisely POSIX, whereas the option -Yx5_lib
sets it to the existing API plus the X11 Release 5 basic X library.
This is done by using +INCL
etc. in the posix
environment to set the various variables corresponding to these environmental
identifiers to precisely the values for POSIX, but <INCL
etc. in the x5_lib
environment to extend these variables
by the values for X11 Release 5. Thus, to specify the API POSIX plus
X11 Release 5, the command-line options -Yposix -Yx5_lib are
required (in that order).
All the standard API environments provided also contain lines which
set, or modify, the INFO
environmental identifier. This
contains textual information on the API, including API names and version
numbers. This information can be printed by invoking tcc
with the -info command-line option. For example, the command-line
options:
> tcc -info -Yposix -Yx5_libcause the message:
tcc: API is X11 Release 5 Xlib plus POSIX (1003.1).to be printed.
As was mentioned above, the default API is ANSI. Thus invoking tcc
without specifying an API environment is equivalent to giving the
-Yansi command-line option. On the basis that, when it comes
to portability, explicit decisions are better than implicit ones,
the use of -Yansi is recommended.
An important example is the -g flag, which causes the generation
of information for symbolic debugging. Depending on the target machine,
different flags may need to be passed to the assembler and system
linker when -g is specified, or the default
For a complete list of those options which are implemented by means
of environments, see 7.74.4. Using Environments to Implement tcc Options
Another use to which environments are put is to implement certain
tcc
command-line options. In particular, some options
require different actions depending on the target machine. It is far
easier to implement these by means of an environment, which can be
defined differently on each target machine, rather than by trying
to build all the alternative definitions into tcc
..o
files and libraries used by the linker may need to be changed. For
this reason tcc
uses a standard environment, tcc_diag
,
to implement the -g option.tcc
will issue a warning to that
effect.
Part of the TenDRA Web.4.5. User-Defined Environments
The tcc
user can also set up and use environments. It
is anticipated that this facility will be used mainly to group a number
of tcc
command-line options into an environment using
the FLAG
environmental identifier and to set up environments
corresponding to user-defined APIs.
Crown
Copyright © 1998.