fpc.cfg(5)

πŸŽ€ fpc.cfg β€” the Free Pascal Compiler config file, bestie πŸŽ€

okay so welcome to fpc.cfg(5), the manual page for the file that runs the whole vibe of your Free Pascal builds. she's lowkey the main character of your compiler setup and nobody talks about her. let's fix that. πŸ’…


✨ NAME ✨

fpc.cfg β€” the Free Pascal Compiler (FPC) configuration file. and the name? it's literally derived from "Free Pascal Compiler". that's it. that's the lore. 🫢


πŸ’– DESCRIPTION πŸ’–

This is the main configuration file of the Free Pascal Compiler (FPC). iconic behavior.

Every single command line option of the compiler β€” and yes, all of them are described over in fpc(1), go read her β€” can be specified inside fpc.cfg. no cap.

When the configuration file gets found, it is read, and the lines it contains are treated like you typed them straight onto the command line, see fpc(1), with some extra condtional possibilities on top. it's giving "command line but make it a file". πŸ’«


🌸 SYNTAX 🌸

You can drop comments in the configuration file with the # sign. Everything from that # onward gets ignored β€” unless it happens to be one of the keywords (see below, they're special like that). πŸ™ˆ

πŸ¦‹ where the compiler goes looking for fpc.cfg πŸ¦‹

The compiler hunts for the fpc.cfg file in these places:

  • Under Linux and unix
    • The current directory.
    • Home directory, looks for .fpc.cfg
    • The directory specified in the environment variable PPC_CONFIG_PATH, and if it's not set, under compilerdir/../etc.
    • If it is not yet found: in /etc.
  • Under all other OSes:
    • The current directory.
    • The directory specified in the environment variable PPC_CONFIG_PATH.
    • The directory where the compiler binary is.

Once the compiler has finished reading the configuration file, it continues on and treats the command line options. she's not done with you yet. 😌


🌈 the @foo situation 🌈

One of the command-line options lets you specify a second configuration file. If you specify @foo on the command line, it will use file foo instead of fpc.cfg and read further options from there. And when the compiler has finished reading that file, it continues to process the command line. chain reaction, slay. πŸ”₯


🧚 preprocessing, because she's fancy 🧚

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 $... directive counterparts in Pascal. yes bestie, same energy, different syntax. πŸ’œ


πŸ’« #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_12
-Fu/usr/lib/fpc/0.99.12/rtl
#ENDIF

In the above example, /usr/lib/fpc/0.99.12/rtl will be added to the path if you're compiling with version 0.99.12 of the compiler. periodt.


🌟 #IFNDEF 🌟

Syntax: #IFNDEF name

Lines following #IFDEF are skipped read if the keyword name following it is defined. (yes, the opposite of the last one, she's the plot twist ✨)

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

Example

#IFNDEF VER0_99_12
-Fu/usr/lib/fpc/0.99.13/rtl
#ENDIF

In the above example, /usr/lib/fpc/0.99.13/rtl will be added to the path if you're NOT compiling with version 0.99.12 of the compiler. got it? good. 🫢


πŸŽ€ #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 #IFNDEF was accepted.

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

Example

#IFDEF VER0_99_12
-Fu/usr/lib/fpc/0.99.12/rtl
#ELSE
-Fu/usr/lib/fpc/0.99.13/rtl
#ENDIF

In the above example, /usr/lib/fpc/0.99.12/rtl will be added to the path if you're compiling with version 0.99.12 of the compiler, otherwise /usr/lib/fpc/0.99.13/rtl will be added to the path. choose your fighter. πŸ’…


πŸ¦‹ #ENDIF πŸ¦‹

Syntax: #ENDIF

#ENDIF marks the end of a block that started with #IF(N)DEF, possibly with an #ELSE between it. she closes what she opens. πŸ”’


πŸ“ #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. bye bestie, you're undefined now. πŸ‘‹


πŸ”₯ #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. iconic warning system honestly. πŸ’œ


πŸ‘‘ #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 Unix like systems (such as Linux), in your home directory), but still want to have the global options that are set in a global configuration file. best of both worlds fr fr. 🌸

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 unix like machine (like linux), 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. she said "no closing tag needed, I'm built different". πŸ’…


🌈 Example 🌈

A standard block often used in (the Linux version of) fpc.cfg is

-vwhin
#IFDEF VER0_99_12
 #IFDEF FPC_LINK_STATIC
  -Fu/usr/lib/fpc/0.99.12/rtl/static
  -Fu/usr/lib/fpc/0.99.12/units/static
 #ENDIF
 #IFDEF FPC_LINK_DYNAMIC
  -Fu/usr/lib/fpc/0.99.12/rtl/shared
  -Fu/usr/lib/fpc/0.99.12/units/shared
 #ENDIF
 -Fu/usr/lib/fpc/0.99.12/rtl
 -Fu/usr/lib/fpc/0.99.12/units
#ENDIF

The block is copied into the fpc.cfg file for each version you use (normally the latest release and the lastest developpers snapshot. 🫢


πŸ’œ SEE ALSO πŸ’œ


okay that's the whole page bestie, go forth and configure. ✨ and just so you have the receipts: this was FPC, dated 22 february 2002. vintage but she still ate. πŸŽ€πŸ’–πŸ¦‹