# Debian packages and PPA

`debian/` builds one source package, `futile`, into mutually exclusive
binary packages. They all ship `libfutile-1.so`, the headers, the Fortran
modules (in `/usr/include`) and the `futile` Python package, built with
different accelerator backends. `debian/rules` configures, builds and
installs each variant in its own build directory (`build-<package>`).

| Package            | Features                                                                                                               | Built                                                          |
|--------------------|------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| `libfutile`        | MPI (Open MPI) and OpenMP, libyaml, BLAS/LAPACK, Python/NumPy,<br/>GLib/GObject, OpenCL interfaces (`--enable-opencl`) | always                                                         |
| `libfutile-cuda`   | `libfutile` plus CUDA (cuBLAS, device memory helpers); depends on<br/>the CUDA runtime from multiverse                 | amd64 and arm64, unless the `pkg.futile.nocuda` profile is set |
| `libfutile-kokkos` | `libfutile` plus the Kokkos buffer interfaces of `libpsolverkokkos`                                                    | only with the `pkg.futile.kokkos` profile                      |

The accelerated variants `Provides: libfutile` and conflict with it, so a
reverse dependency declares `Depends: libfutile` and accepts any variant,
and installing one variant replaces the other. CUDA is used on demand only:
`libfutile-cuda` also works on machines without an NVIDIA GPU.

`--enable-opencl` only removes Futile’s fake OpenCL entry points so that
BigDFT’s OpenCL layer can provide them; Futile itself does not link
`libOpenCL`. The packages recommend an OpenCL ICD (`pocl-opencl-icd`) for
that layer.

Not packaged:

* SimGrid shared allocators (`--enable-simgrid-shared`): buffers marked as
  shared would be allocated with `smpi_shared_malloc`, which is only valid
  in programs run by SimGrid’s `smpirun`.
* Kokkos by default: Futile’s Kokkos layer is the `psolverkokkos` adapter
  (`psolver/kokkos` in the BigDFT suite), which also needs KokkosFFT.
  Neither is in the Ubuntu archive (`libkokkos-dev` is 3.7 on noble, 5.0
  on resolute, absent on jammy), so the variant cannot be built on Launchpad.
* oneAPI/SYCL: the Intel compilers come from an external repository that
  Launchpad builders cannot use. A SYCL variant would have to be built by
  CI and published separately (future work).

## Build profiles

`pkg.futile.nocuda` skips `libfutile-cuda` and its large
`nvidia-cuda-toolkit` build dependency; `pkg.futile.kokkos` adds
`libfutile-kokkos` and requires `psolverkokkos.pc`:

```console
dpkg-buildpackage -b -us -uc -Ppkg.futile.nocuda
```

Launchpad applies no build profile, so the default set must build on every
series of the PPA. It does on all supported series:

| Series           | Default packages              |   CUDA toolkit |
|------------------|-------------------------------|----------------|
| jammy (22.04)    | `libfutile`, `libfutile-cuda` |           11.5 |
| noble (24.04)    | `libfutile`, `libfutile-cuda` |           12   |
| resolute (26.04) | `libfutile`, `libfutile-cuda` |           12.4 |

## Launchpad recipe

`packaging/launchpad/futile.recipe` is the git-build-recipe of the daily
PPA builds. It lives outside `debian/`: Launchpad reads the recipe text
pasted in its web interface, not the file, and the source package does not
need to ship it. Its base branch, `lp:futile devel`, is the Launchpad code
import of `https://gitlab.com/l_sim/futile.git` owned by
`~bigdft-developers` (`https://git.launchpad.net/futile`). The packages
are published in `ppa:bigdft-developers/bigdft`; see [Installing Futile from packages](../install.md) for
the user side. The version is
`{debupstream}+git{revtime}.{git-commit}`, to which Launchpad appends
`~ubuntuXX.YY.1` for each series. Without an upstream tarball the source
package falls back to the `3.0 (native)` format, so the version carries no
Debian revision.

The `debian-recipe` CI job runs `packaging/launchpad/check-recipe.sh` on
`ubuntu:jammy`, `ubuntu:noble` and `ubuntu:resolute`. The script
follows the Launchpad builders: it assembles the source tree with
git-build-recipe from the checked-out commit, installs exactly the declared
build dependencies, builds the source and the binary packages (no network
access is needed for the build), removes the build dependencies, then
installs each produced package in turn, checks that the variants cannot be
installed together, imports the Python package and runs a Fortran program
linked against the library. The same script can be run locally, as root,
from the root of a Futile checkout:

```console
docker run --rm -v $PWD:/futile -w /futile ubuntu:noble sh -c \
  'apt-get update && apt-get install -y --no-install-recommends \
     git-build-recipe pristine-tar devscripts equivs build-essential \
     fakeroot git ca-certificates && packaging/launchpad/check-recipe.sh'
```

`FUTILE_PROFILES` overrides the build profiles of the series.
