Next: , Previous: , Up: Distributing   [Contents][Index]

6.4.3 The dist Hook

Occasionally it is useful to be able to change the distribution before it is packaged up. If the dist-hook rule exists, it is run after the distribution directory is filled, but before the actual distribution archives are created.

Two variables that are available when writing dist-hook rules are ‘$(distdir)’ and ‘$(top_distdir)’:

One use of the dist_hook rule is for removing unnecessary files that get recursively included by specifying a directory in EXTRA_DIST:

EXTRA_DIST = doc
dist-hook:
        rm -rf `find $(distdir)/doc -type d -name .svn`

Note that the dist-hook recipe shouldn’t assume that the regular files in the distribution directory are writable; this might not be the case if one is packaging from a read-only source tree, or when a make distcheck is being done. For similar reasons, the recipe shouldn’t assume that the subdirectories put into the distribution directory due to being listed in EXTRA_DIST are writable. So, if the dist-hook recipe wants to modify the content of an existing file (or EXTRA_DIST subdirectory) in the distribution directory, it should explicitly to make it writable first:

EXTRA_DIST = README doc
dist-hook:
        chmod u+w $(distdir)/README $(distdir)/doc
        echo "Distribution date: `date`" >> README
        rm -f $(distdir)/doc/HACKING

Note that when packages are nested using AC_CONFIG_SUBDIRS (see Subpackages), then ‘$(distdir)’ and ‘$(top_distdir)’ are relative to the package where ‘make dist’ was run, not to any sub-packages involved.

Next: , Previous: , Up: Distributing   [Contents][Index]