Man Page

Manual Section... (1) - page: dpkg-buildpackage



dpkg-buildpackage - build binary or source packages from sources  


dpkg-buildpackage [options]  


dpkg-buildpackage is a program that automates the process of building a Debian package. It consists of the following steps:
It prepares the build environment by setting various environment variables (see ENVIRONMENT VARIABLES).
It checks that the build-dependencies and build-conflicts are satisfied (unless -d is specified).
If a specific target has been selected with the -T or --target option, it calls that target and stops here. Otherwise it calls fakeroot debian/rules clean to clean the build-tree (unless -nc is specified).
It calls dpkg-source to generate the source package (unless a binary-only build has been requested with -b, -B or -A).
It calls debian/rules build followed by fakeroot debian/rules binary-target (unless a source-only build has been requested with -S). Note that binary-target is either binary (default case, or if -b is specified) or binary-arch (if -B is specified) or binary-indep (if -A is specified).
It calls gpg to sign the .dsc file (if any, unless -us is specified).
It calls dpkg-genchanges to generate a .changes file. Many dpkg-buildpackage options are forwarded to dpkg-genchanges.
It calls gpg to sign the .changes file (unless -uc is specified).
If -tc is specified, it will call fakeroot debian/rules clean again.


Specifies a binary-only build, no source files are to be built and/or distributed. Passed to dpkg-genchanges.
Specifies a binary-only build, limited to architecture dependent packages. Passed to dpkg-genchanges.
Specifies a binary-only build, limited to architecture independent packages. Passed to dpkg-genchanges.
Specifies a source-only build, no binary packages need to be made. Passed to dpkg-genchanges.

--target target

Calls debian/rules target after having setup the build environment and stops the package build process here. If --as-root is also given, then the command is executed as root (see -r). Note that official targets that are required to be run as root by the Debian policy do not need this option.
Only meaningful together with --target. Requires that the target be run with root rights.


Passed unchanged to dpkg-genchanges. See its manual page.
Specify the Debian architecture we build for. The architecture of the machine we build on is determined automatically, and is also the default for the host machine.

If the host architecture differs from the build architecture (as is the case for a cross-compilation), and if the environment variable PKG_CONFIG_LIBDIR is not set, then it is set to a value suitable for cross-compilation ("/usr/gnu-system-type/lib/pkgconfig/:/usr/share/pkgconfig").

Specify the GNU system type we build for. It can be used in place of -a or as a complement to override the default GNU system type of the target Debian architecture.
Number of jobs allowed to be run simultaneously, equivalent to the make(1) option of the same name. Will add itself to the MAKEFLAGS environment variable, which should cause all subsequent make invocations to inherit the option. Also adds parallel=jobs to the DEB_BUILD_OPTIONS environment variable which allows debian/rules files to use this information for their own purposes. The parallel=jobs in DEB_BUILD_OPTIONS environment variable will override the -j value if this option is given.
Check build dependencies and conflicts; abort if unsatisfied. This is the default behavior.
Do not check build dependencies and conflicts.
Do not clean the source tree (implies -b if nothing else has been selected among -B, -A or -S).
Clean the source tree (using gain-root-command debian/rules clean) after the package has been built.
When dpkg-buildpackage needs to execute part of the build process as root, it prefixes the command it executes with gain-root-command if one has been specified. Otherwise, if none has been specified, fakeroot will be used by default, if the command is present. gain-root-command should start with the name of a program on the PATH and will get as arguments the name of the real command to run and the arguments it should take. gain-root-command can include parameters (they must be space-separated) but no shell metacharacters. gain-root-command might typically be fakeroot, sudo, super or really. su is not suitable, since it can only invoke the user's shell with -c instead of passing arguments individually to the command to be run.
Building a Debian package usually involves invoking debian/rules as a command with several standard parameters. With this option it's possible to use another program invocation to build the package (it can include space separated parameters). Alternatively it can be used to execute the standard rules file with another make program (for example by using /usr/local/bin/make -f debian/rules as rules-file).
When dpkg-buildpackage needs to execute GPG or PGP to sign a source control (.dsc) file or a .changes file it will run sign-command (searching the PATH if necessary) instead of gpg. sign-command will get all the arguments that pgp would have gotten. If sign-command takes its arguments in GPG rather than PGP style, you should give the -sgpg option. sign-command should not contain spaces or any other shell metacharacters.
Specify a key-ID to use when signing packages.
Do not sign the source package.
Do not sign the .changes file.

-z, -Z

Passed unchanged to dpkg-source. See its manual page.

--admindir dir

Change the location of the dpkg database. The default location is /var/lib/dpkg.
-h, --help
Show the usage message and exit.
Show the version and exit.



Variables set by dpkg-architecture

dpkg-architecture is called with the -a and -t parameters forwarded. Any variable that is output by its -s option is integrated in the build environment.  

Compiler flags

Some environment variables defining compiler and linker options are set to default values unless already present in the environment. Note that this mechanism was only introduced in version 1.14.17 of dpkg-dev and not all rules files and build tools will honour these variables, yet. See for the details.
Optimization options which are passed to the Debian build system and can/should be overriden by the package build if needed (default value: -g -O2, or -g -O0 if noopt is specified in DEB_BUILD_OPTIONS). Overriding options can be used to explicitely set a higher optimization level, or work around compiler bugs, which only can be seen with some optimization levels (the last opt level "wins").
Optimization options appended to the compiler flags, which must not be overwritten by the package (mostly used to for test builds). Default value: empty.
Same as CFLAGS for C++ sources.
Same as CFLAGS_APPEND for C++ sources.
Same as CFLAGS for Fortran sources.
Same as CFLAGS_APPEND for Fortran sources.
Preprocessor flags which are passed to the Debian build system and can/should be overriden by the package build if needed (default: empty). This macro is seldom used (most build systems just use CFLAGS instead of CPPFLAGS).
Preprocessor flags appended to the preprocessor flags, which must not be overwritten by the package (mostly used to for test builds). Default value: empty.
Options passed to the compiler when linking executables or shared objects (if the linker is called directly, then -Wl and , have to be stripped from these options). Default value: empty.
Optimization options appended to the compiler flags when linking code, which must not be overwritten by the package (mostly used to for test builds). Default value: empty.
As indicated above, noopt will disable optimation. Additionally, when used with the hardening-wrapper package, the values hardening and nohardening will be converted into their respective DEB_BUILD_HARDENING values. The hardening option can also include (optionally prefixed with no ) the following sub-options: stackprotector format fortify pie relro For example, DEB_BUILD_OPTIONS=hardening=nopie would cause DEB_BUILD_HARDENING_PIE=0 to be set, or DEB_BUILD_OPTIONS=nohardening would cause DEB_BUILD_HARDENING=0 to be set. See for further details.


It should be possible to specify spaces and shell metacharacters in and initial arguments for gain-root-command and sign-command.  


dpkg-source(1), dpkg-architecture(1), dpkg-genchanges(1), fakeroot(1), gpg(1).  


Copyright © 1995-1996 Ian Jackson
Copyright © 2000 Wichert Akkerman
Copyright © 2007 Frank Lichtenheld
Copyright © 2008 Raphaël Hertzog

This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO WARRANTY.



Variables set by dpkg-architecture
Compiler flags

This document was created by man2html, using the manual pages.
Time: 15:26:08 GMT, June 11, 2010

Leave a Reply

You must be logged in to post a comment.