Building from source
--------------------

1) Check out the Git repository

2) Build using git buildpackage, i.e.
   `gbp buildpackage`

Importing new source tarball
----------------------------

1) Download new LDC release tarball

2) Repackage the LDC release tarball, fixing line endings:
   (needs dos2unix installed)
   ```
   tar -xzf <ldc-release>.tar.gz
   find ldc-<version>-src/ -type f -exec dos2unix {} \;
   tar -czf ldc_<version>.orig.tar.gz ./ldc-<version>-src
   ```

   This silliness is needed because of two issues: LDC containing
   files with CRLF lineendings, and gbp dropping them unconditionally,
   leading to a pristine-tar conflict later.

   For reference see the following issues:
   https://github.com/ldc-developers/ldc/issues/2402
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719363

3) Import the new sources: `gbp import-orig /path/to/ldc_<version>.orig.tar.gz`

4) Refresh and adjust all patches, commit changes

5) Update phobos/druntime library package names to the new SONAMEs, add
   Conflicts: entry on old phobos library to make the transition safer for users,
   do any other necessary changes.

6) Update changelog (`gbp dch`), manual edits

7) Build package the way you like (e.g. `gbp buildpackage --git-builder='debspawn build sid --sign'`)

8) Regenerate the manual pages from the freshly built ldc2/ldmd2 if upstream
   changed any driver options (see "Regenerating the manual pages" below);
   rebuild if they changed.

9) Run lintian before uploading, make especially sure LDC did not sneak in a statically linked
    copy of any library (like zlib):
    `lintian -IE --pedantic *.changes`

10) Upload.

Regenerating the manual pages
-----------------------------

Upstream LDC does not ship manual pages, so debian/ldc2.1 and debian/ldmd2.1
are maintained here as static files generated from the compilers' own --help
output with help2man. They must be refreshed whenever upstream adds, removes
or renames driver options.

Regenerate them against the ldc2/ldmd2 of the version being packaged (e.g.
inside the build chroot, or after installing the freshly built .deb):

   ```
   V=$(ldc2 --version | sed -n '1s/.*(\([0-9.]*\)).*/\1/p')
   D=$(date +'%B %Y')

   help2man --no-info -N -n "LLVM D Compiler" ldc2 > debian/ldc2.1
   sed -i "2s/.*/.TH LDC2 \"1\" \"$D\" \"LDC $V\" \"LLVM D Compiler\"/" debian/ldc2.1
   sed -i '/^.SH NAME/{n;s/^LDC /LDC2 /}' debian/ldc2.1

   help2man --no-info -N -n "LLVM D Compiler (DMD-compatible driver)" ldmd2 > debian/ldmd2.1
   sed -i "2s/.*/.TH LDMD2 \"1\" \"$D\" \"LDC $V\" \"LLVM D Compiler\"/" debian/ldmd2.1
   sed -i '/^.SH NAME/{n;s/^LDC /LDMD2 /}' debian/ldmd2.1
   ```

The .TH and NAME rewrites are needed because help2man derives those fields
from the LDC --version banner, which is shared by both binaries and carries a
trailing colon. Check the result renders cleanly with `man --warnings -l`.
