[[build]]
=== Upstream build systems

Upstream build systems are designed to go through several steps to install generated binary files to the system from the source distribution.

TIP: Before attempting to make a Debian package, you should become familiar with the upstream build system of the upstream source code and try to build it.


[[autotools]]
==== Autotools

Autotools (*autoconf* + *automake*) has 4 steps.

1. set up the build system (``*vim configure.ac Makefile.am*'' and ``*autoreconf -ivf*'')
2. configure the build system (``*./configure*'')
3. build the source tree (``*make*'')
4. install the binary files (``*make install*'')

The upstream maintainer usually performs step 1 and builds the upstream tarball for distribution using the ``*make dist*'' command.   (The generated tarball contains not only the pristine upstream VCS contents but also other generated files.)

The package maintainer needs to take care of steps 2 to 4 at least.  This is realized by the ``*dh $@ --with autotools-dev*'' command used in the *debian/rules* file.

The package maintainer may wish to take care all steps 1 to 4.  This is realized by the ``*dh $@ --with autoreconf*'' command used in the *debian/rules* file.  This rebuilds all auto-generated files to the latest version and provides better support for porting to the newer architectures.

For *compat* level *10* or newer, the simple ``*dh $@*'' command without ``*--with autoreconf*'' option can take care all steps 1 to 4, too.

If you wish to learn more on Autotools, please see:

* https://www.gnu.org/software/automake/manual/index.html[GNU Automake documentation]
* https://www.gnu.org/software/autoconf/manual/index.html[GNU Autoconf documentation]
* https://www.lrde.epita.fr/~adl/autotools.html[Autotools Tutorial]
* https://www.dwheeler.com/autotools/introduction-autotools.pdf[Introduction to the autotools (autoconf, automake, and libtool)]
* https://autotools.io/index.html[Autotools Mythbuster]

[[cmake]]
==== CMake

CMake has 4 steps.

1. set up the build system (``*vim CMakeLists.txt config.h.in*'')
2. configure the build system (``*cmake*'')
3. build the source tree (``*make*'')
4. install the binary files (``*make install*'')

The upstream tarball contains no auto-generated files and is generated by the *tar* command after step 1.

The package maintainer needs to take care of steps 2 to 4.

If you wish to learn more on the CMake, please see:

* https://cmake.org/[CMake]
* https://cmake.org/cmake-tutorial/[CMake tutorial]

[[distutils]]
==== Python distutils

Python distutils has 3 steps.

1. set up and configure the build system (``*vim setup.py*'')
2. build the source tree (``*python setup.py build*'')
3. install the binary files (``*python setup.py install*'')

The upstream maintainer usually performs step 1 and builds the upstream tarball for distribution using the ``*python setup.py sdist*'' command.

The package maintainer needs to take care of step 2.  This is realized simply by the ``*dh $@*'' command used in the *debian/rules* file, after *jessie*.

The situation of other build systems, such as CMake, are very similar to this Python one.

If you wish to learn more on Python3 and *distutils*, please see:

* https://docs.python.org/3/[Python3]
* https://docs.python.org/3.4/library/distutils.html#module-distutils[distutils]

