[next] [prev] [prev-tail] [tail] [up]

### 5.2 Using the configuration file

Using the configuration file fpc.cfg is an alternative to command line options. When a configuration file is found, it is read, and the lines in it are treated like you typed them on the command line. They are treated before the options that you type on the command line.

You can specify comments in the configuration file with the # sign. Everything from the # on will be ignored.

The algorithm to determine which file is used as a configuration file is decribed in 3.1 on page 50.

When the compiler has finished reading the configuration file, it continues to treat the command line options.

One of the command-line options allows you to specify a second configuration file: Specifying @foo on the command line will open file foo, and read further options from there. When the compiler has finished reading this file, it continues to process the command line.

The configuration file allows some kind of preprocessing. It understands the following directives, which you should place on the first column of a line :

#IFDEF
#IFNDEF
#ELSE
#ENDIF
#DEFINE
#UNDEF
#WRITE
#INCLUDE
#SECTION

They work the same way as their {$...} counterparts in Pascal. All the default defines used to compile source code are also defined while processing the configuration file. For example, if the target compiler is an intel 80x86 compatile linux platform, both cpu86 and linux will be defined while interpreting the configuration file. For the possible default defines when compiling, consult Appendix G of the Programmers guide.

What follows is a description of the different directives.

#### #IFDEF

Syntax:

     #IFDEF name

Lines following #IFDEF are skipped read if the keyword name following it is not defined.

They are read until the keywords #ELSE or #ENDIF are encountered, after which normal processing is resumed.

Example :

     #IFDEF VER0_99_5
     -Fu/usr/lib/fpc/0.99.5/linuxunits
     #ENDIF

In the above example, /usr/lib/fpc/0.99.5/linuxunits will be added to the path if you’re compiling with version 0.99.5 of the compiler.

#### #IFNDEF

Syntax:

     #IFNDEF name

Lines following #IFNDEF are skipped read if the keyword name following it is defined.

They are read until the keywords #ELSE or #ENDIF are encountered, after which normal processing is resumed.

Example :

     #IFNDEF VER0_99_5
     -Fu/usr/lib/fpc/0.99.6/linuxunits
     #ENDIF

In the above example, /usr/lib/fpc/0.99.6/linuxunits will be added to the path if you’re NOT compiling with version 0.99.5 of the compiler.

#### #ELSE

Syntax:

     #ELSE

#ELSE can be specified after a #IFDEF or #IFNDEF directive as an alternative. Lines following #ELSE are skipped read if the preceding #IFDEF or #IFNDEF was accepted.

They are skipped until the keyword #ENDIF is encountered, after which normal processing is resumed.

Example :

     #IFDEF VER0_99_5
     -Fu/usr/lib/fpc/0.99.5/linuxunits
     #ELSE
     -Fu/usr/lib/fpc/0.99.6/linuxunits
     #ENDIF

In the above example, /usr/lib/fpc/0.99.5/linuxunits will be added to the path if you’re compiling with version 0.99.5 of the compiler, otherwise /usr/lib/fpc/0.99.6/linuxunits will be added to the path.

#### #ENDIF

Syntax:

     #ENDIF

#ENDIF marks the end of a block that started with #IF(N)DEF, possibly with an #ELSE between it.

#### #DEFINE

Syntax:

     #DEFINE name

#DEFINE defines a new keyword. This has the same effect as a -dname command-line option.

#### #UNDEF

Syntax:

     #UNDEF name

#UNDEF un-defines a keyword if it existed. This has the same effect as a -uname command-line option.

#### #WRITE

Syntax:

     #WRITE Message Text

#WRITE writes Message Text to the screen. This can be useful to display warnings if certain options are set.

Example:

     #IFDEF DEBUG
     #WRITE Setting debugging ON...
     -g
     #ENDIF

if DEBUG is defined, this will produce a line

     Setting debugging ON...

and will then switch on debugging information in the compiler.

#### #INCLUDE

Syntax:

     #INCLUDE filename

#INCLUDE instructs the compiler to read the contents of filename before continuing to process options in the current file.

This can be useful if you want to have a particular configuration file for a project (or, under L I N U X, in your home directory), but still want to have the global options that are set in a global configuration file.

Example:

     #IFDEF LINUX
       #INCLUDE /etc/fpc.cfg
     #ELSE
       #IFDEF GO32V2
         #INCLUDE c:\pp\bin\fpc.cfg
       #ENDIF
     #ENDIF

This will include /etc/fpc.cfg if you’re on a linux machine, and will include c:\pp\bin\fpc.cfg on a dos machine.

#### #SECTION

Syntax:

     #SECTION name

The #SECTION directive acts as a #IFDEF directive, only it doesn’t require an #ENDIF directive. the special name COMMON always exists, i.e. lines following #SECTION COMMON are always read.

[next] [prev] [prev-tail] [front] [up]