(debian-policy.info)debian/rules and DEB_BUILD_OPTIONS
4.9.1 ‘debian/rules’ and ‘DEB_BUILD_OPTIONS’
--------------------------------------------
Supporting the standardized environment variable ‘DEB_BUILD_OPTIONS’ is
recommended. This variable can contain several flags to change how a
package is compiled and built. Each flag must be in the form flag or
flag=options. If multiple flags are given, they must be separated by
whitespace. (1) flag must start with a lowercase letter (‘a-z’) and
consist only of lowercase letters, numbers (‘0-9’), and the characters
‘-’ and ‘_’ (hyphen and underscore). options must not contain
whitespace. The same tag should not be given multiple times with
conflicting values. Package maintainers may assume that
‘DEB_BUILD_OPTIONS’ will not contain conflicting tags.
The meaning of the following tags has been standardized:
‘nocheck’
This tag says to not run any build-time test suite provided by the
package.
‘nodoc’
This tag says to skip any build steps that only generate package
documentation. Files required by other sections of Debian Policy,
such as copyright and changelog files, must still be generated and
put in the package, but other generated documentation such as
help2man-generated pages, Doxygen-generated API documentation, or
info pages generated from Texinfo sources should be skipped if
possible. This option does not change the set of binary packages
generated by the source package, but documentation-only binary
packages may be nearly empty when built with this option.
‘noopt’
The presence of this tag means that the package should be compiled
with a minimum of optimization. For C programs, it is best to add
‘-O0’ to ‘CFLAGS’ (although this is usually the default). Some
programs might fail to build or run at this level of optimization;
it may be necessary to use ‘-O1’, for example.
‘nostrip’
This tag means that the debugging symbols should not be stripped
from the binary during installation, so that debugging information
may be included in the package.
‘parallel=n’
This tag means that the package should be built using up to ‘n’
parallel processes if the package build system supports this. (2)
If the package build system does not support parallel builds, this
string must be ignored. If the package build system only supports
a lower level of concurrency than n, the package should be built
using as many parallel processes as the package build system
supports. It is up to the package maintainer to decide whether the
package build times are long enough and the package build system is
robust enough to make supporting parallel builds worthwhile.
‘terse’
This tag means that the package build will be less verbose than
default. For example, ‘debian/rules’ might pass options to the
package’s configure script that cause the compiler to produce less
output.
Unknown flags must be ignored by ‘debian/rules’.
The following makefile snippet is an example of how one may implement
the build options; you will probably have to massage this example in
order to make it work for your package.
CFLAGS = -Wall -g
INSTALL = install
INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif
build:
# ...
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Code to run the package test suite.
endif
---------- Footnotes ----------
(1) Some packages support any delimiter, but whitespace is the
easiest to parse inside a makefile and avoids ambiguity with flag values
that contain commas.
(2) Packages built with ‘make’ can often implement this by passing
the ‘-j’n option to ‘make’.
automatically generated by info2www version 1.2.2.9