5.3 Variable substitution in paths

To avoid having to edit your configuration files too often, the compiler allows you to insert some variables in the paths that you specify for the compiler. They are specified as follows:

$VARNAME

The above will be replaced with the value of the variable VARNAME.

Normally, only a set of compiler-defined variable names are recognized. In addition to these compiler-defined variable names, the following notation can be used

$ENVVAR$

to substitute the value of an environment variable. The compiler will fetch the value of ENVVAR from the environment, and replace the $ENVVAR$ with this value.

The compiler defines the following variable names:

FPCFULLVERSION

is replaced by the compiler’s version string.

FPCVERSION

is replaced by the compiler’s version string.

FPCDATE

is replaced by the compiler’s date.

FPCTARGET

is replaced by the compiler’s target (combination of CPU-OS)

FPCCPU

is replaced by the compiler’s target CPU.

FPCOS

is replaced by the compiler’s target OS.

Additionally, under windows the following special variables are recognized:

LOCAL_APPDATA

Usually the directory ”Local settings/Application Data” under the user’s home directory.

APPDATA

Usually the directory ”Application Data” under the user’s home directory.

COMMON_APPDATA

Usually the directory ”Application Data” under the ’All users’ directory.

PERSONAL

Usually the ”My documents” directory of the user.

PROGRAM_FILES

Usually ”program files” directory on the system drive

PROGRAM_FILES_COMMON

Usually the ”Common files” directory under the program files directory.

PROFILE

The user’s home directory.

The values of these can vary based on the installation, they are fetched from the operating system.

If none of the pre-defines variable names were matched, and the template name ends on $, then the environment variable with the same name is used:

-Fu$HOME$/FPC/currentversion/

This will refer to the directory FPC/currentversion under the user’s home directory on Unix (HOME is the environment variable that contains the location of the user’s directory).

So, have one of the above variables substituted, just insert them with a $ prepended, as follows:

-Fu/usr/lib/fpc/$FPCVERSION/rtl/$FPCOS

This is equivalent to

-Fu/usr/lib/fpc/2.6.2/rtl/linux

if the compiler version is 2.6.2 and the target OS is linux.

These replacements are valid on the command line and also in the configuration file.

On the linux command line, you must be careful to escape the $ since otherwise the shell will attempt to expand the variable for you, which may have undesired effects.