Ubuntu – Which target in debian/rules do I need to use for generating documentation

documentationpackaging

I have run into some problems creating Debian packaging for a shared library. The application contains a Doxyfile which is used to generate documentation for the library. I would like to create a libfoo-doc package which includes the documentation.

In order to generate the documentation, I have the following lines in debian/rules:

#!/usr/bin/make -f

build-indep:
    cd $(DESTDIR)/share/doc/libfoo-doc ; doxygen

%:
    dh $@

However, this target never gets built, despite what this page claims:

"The binary target must be all that is necessary for the user to build the binary package(s) produced from this source package. It is split into two parts: binary-arch builds the binary packages which are specific to a particular architecture, and binary-indep builds those which are not."

I also tried changing build-indep to installdocs but that made no difference.

What target do I need to use for generating documentation?

Best Answer

You're looking for override_dh_build-indep From the manpage for the dh command Manpage icon

OVERRIDE TARGETS
       A debian/rules file using dh can override the command that is run at
       any step in a sequence, by defining an override target.

       To override dh_command, add a target named override_dh_command to the
       rules file. When it would normally run dh_command, dh will instead call
       that target. The override target can then run the command with
       additional options, or run entirely different commands instead. See
       examples below.  (Note that to use this feature, you should Build-
       Depend on debhelper 7.0.50 or above.)

       Override targets can also be defined to run only when building
       architecture dependent or architecture independent packages.  Use
       targets with names like override_dh_command-arch and
       override_dh_command-indep.  (Note that to use this feature, you should
       Build-Depend on debhelper 8.9.7 or above.)

Regarding the Policy bit... A build-indep target is being called, just not your build-indep target.