Debian policy manual - chapter 4
Configuring and building the programs in the package


4.1 Compilation options


4.1.1 Compilation options for binaries

Generally the following compilation parameters should be used:
CC = gcc 
CFLAGS = -O2 -g -Wall # sane warning options vary between programs 
LDFLAGS = # none 
install -s # (or use strip on the files in debian/tmp)

Note that all installed binaries should be stripped, either by using the -s flag to install, or by calling strip on the binaries after they have been copied into debian/tmp but before the tree is made into a package.

Make sure that you do not link with -g, as this makes a.out compilers produce huge statically linked binaries. The -g flag is useful on compilation so that you have available a full set of debugging symbols in your built source tree, in case anyone should file a bug report involving (for example) a core dump.

The -N flag should not be used. On a.out systems it may have been useful for some very small binaries, but for ELF it has no good effect.

It is up to the package maintainer to decide what compilation options are best for the package. Certain binaries (such as computationally-intensive programs) may function better with certain flags (-O3, for example); feel free to use them. Please use good judgment here. Don't use flags for the sake of it; only use them if there is good reason to do so. Feel free to override the upstream author's ideas about which compilation options are best - they are often inappropriate for our environment.


4.1.2 Compilation options for libraries

All libraries must have a shared version in the lib package and a static version in the lib-dev package. The shared version must be compiled with -fPIC, and the static version must not be. In other words, each *.c file is compiled twice.

You have to specify the gcc option -D_REENTRANT when building a library (either static or shared) to make the library compatible with LinuxThreads.

Note that all installed shared libraries should be stripped with

strip --strip-unneeded <your-lib>
(The option `--strip-unneeded' makes strip remove only the symbols which aren't needed for relocation processing.) Shared libraries can function perfectly well when stripped, since the symbols for dynamic linking are in a separate part of the ELF object file.

Note that under some circumstances it may be useful to install a shared library unstripped, for example when building a separate package to support debugging.

Please make sure that you use only released versions of shared libraries to build your packages; otherwise other users will not be able to run your binaries properly. Producing source packages that depend on unreleased compilers is also usually a bad idea.


4.2 Packages which can use the X shared libraries

Some programs can be configured with or without support for X Windows. Typically these binaries produced when configured for X will need the X shared libraries to run.

Such programs should be configured with X support, and should declare a dependency on xlib6 (for the X11R6 libraries). Users who wish to use the program can install just the relatively small xlib package, and do not need to install the whole of X.

Do not create two versions (one with X support and one without) of your package.


4.3 Mail processing on Debian systems

Debian packages which process electronic mail, whether mail-user-agents (MUAs) or mail-transport-agents (MTAs), must make sure that they are compatible with the configuration decisions below. Failure to do this may result in lost mail, broken From: lines, and other serious brain damage!

The mail spool is /var/spool/mail and the interface to send a mail message is /usr/sbin/sendmail (as per the FSSTND). The mail spool is part of the base system and not part of the MTA package.

Mailboxes are locked using the username.lock lockfile convention, rather than fcntl, flock or lockf.

Mailboxes are generally 660 user.mail unless the user has chosen otherwise. A MUA may remove a mailbox (unless it has nonstandard permissions) in which case the MTA or another MUA must recreate it if needed. Mailboxes must be writeable by group mail.

The mail spool is 2775 mail.mail, and MUA's need to be setgid mail to do the locking mentioned above (and obviously need to avoid accessing other users' mailboxes using this privilege).

/etc/aliases is the source file for the system mail aliases (e.g. postmaster, usenet, etc.) - it is the one which the sysadmin and postinst scripts may edit. After /etc/aliases is edited the program or human editing it must call newaliases. All MTA packages should come with a newaliases program, even if it does nothing, but older MTA packages do not do this so programs should not fail if newaliases cannot be found.

The convention of writing forward to address in the mailbox itself is not supported. Use a .forward file instead.

The location for the rmail program used by UUCP for incoming mail is /usr/sbin/rmail, as per the FSSTND. Likewise, rsmtp, for receiving batch-SMTP-over-UUCP, is in /usr/sbin/rsmtp if it is supported.

If you need to know what name to use (for example) on outgoing news and mail messages which are generated locally, you should use the file /etc/mailname. It will contain the portion after the username and @ (at) sign for email addresses of users on the machine (followed by a newline).

A package should check for the existence of this file. If it exists it should use it without comment.[8] If it does not exist it should prompt the user for the value and store it in /etc/mailname as well as using it in the package's configuration. The prompt should make it clear that the name will not just be used by that package. E.g., in this situation the INN package says:

Please enter the `mail name' of your system.  This is the hostname
portion of the address to be shown on outgoing news and mail messages.
The default is syshostname, your system's host name.
Mail name [`syshostname']:
where syshostname is the output of hostname -fqdn.

4.4 Obsolete constructs and libraries: varargs and libtermcap

<varargs.h> is provided to support end-users compiling very old software; libtermcap is provided to support the execution of software which has been linked against it (either old programs or those such as Netscape which are only available in binary form).

Debian packages should be ported to <stdarg.h> and ncurses when they are built.


Debian policy manual - Copyright ©1996 Ian Jackson.
Contents; abstract; next; back.
version 2.1.3.2 (dpkg 1.4.0.8), 5 May 1997
Ian Jackson ijackson@gnu.ai.mit.edu
revised: David A. Morris bweaver@debian.org
current maintainer: Christian Schwarz schwarz@debian.org