debian-rules-missing-recommended-target, dh, and dumb make

Lintian now has a warning for debian/rules missing build-arch and build-indep targets. As a dh user, I was surprised that some of my dh-using packages had this problem. And when looking at the source, I remembered how I came to this: GNU make is stupid.

Considering the following excerpt of the GNU make manual:

The prerequisites of the special target .PHONY are considered to be phony targets. When it is time to consider such a target, make will run its recipe unconditionally, regardless of whether a file with that name exists or what its last-modification time is.

And considering the following debian/rules:

.PHONY: build
        dh $@

What do you think happens when you run debian/rules build in a directory containing a build file or directory?

make: Nothing to be done for `build’.

However, an explicit rule, like the following, works:

.PHONY: build
        dh $@

It happens that many of the packages I maintain contain a build subdirectory in their source. As such, to work around the aforementioned issue, I just declared the dh rules explicitely, as in:

.PHONY: build binary binary-arch binary-indep (...)
build binary binary-arch binary-indep (...):
        dh $@

And this obviously doesn’t scale for new rules such as build-arch and build-indep.

To be future-proof, I’ll use the following instead:

.PHONY: build
build %:
        dh $@

I don’t know why I didn’t do that the first time…

2011-07-23 10:48:07+0900


You can leave a response, or trackback from your own site.

One Response to “debian-rules-missing-recommended-target, dh, and dumb make”

  1. Paul Smith Says:

    The GNU make documentation says:

    The implicit rule search (see Implicit Rules) is skipped for .PHONY targets.

    That’s why you’re seeing this behavior. Use the FORCE method to force pattern rules to always rebuild, not .PHONY ( ).

    However creating match-anything pattern rules like this is generally to be avoided as it causes performance issues.

Leave a Reply