{"id":2126,"date":"2011-07-23T10:48:07","date_gmt":"2011-07-23T08:48:07","guid":{"rendered":"http:\/\/glandium.org\/blog\/?p=2126"},"modified":"2011-07-23T10:48:07","modified_gmt":"2011-07-23T08:48:07","slug":"debian-rules-missing-recommended-target-dh-and-dumb-make","status":"publish","type":"post","link":"https:\/\/glandium.org\/blog\/?p=2126","title":{"rendered":"debian-rules-missing-recommended-target, dh, and dumb make"},"content":{"rendered":"<p>Lintian now has a warning for <code>debian\/rules<\/code> missing <code>build-arch<\/code> and <code>build-indep<\/code> targets. As a <code>dh<\/code> user, I was surprised that some of my <code>dh<\/code>-using packages had this problem. And when looking at the source, I remembered how I came to this: GNU make is stupid.<\/p>\n<p>Considering the following excerpt of the GNU make manual:<\/p>\n<blockquote>\n<dt>.PHONY<\/dt>\n<dd>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.<\/dd>\n<\/blockquote>\n<p>And considering the following <code>debian\/rules<\/code>:<\/p>\n<blockquote><p><code><\/p>\n<pre>.PHONY: build\r\n%:\r\n        dh $@\r\n<\/pre>\n<p><\/code><\/p><\/blockquote>\n<p>What do you think happens when you run <code>debian\/rules build<\/code> in a directory containing a <code>build<\/code> file or directory?<\/p>\n<blockquote><p>make: Nothing to be done for `build'.<\/p><\/blockquote>\n<p>However, an explicit rule, like the following, works:<\/p>\n<blockquote><p><code><\/p>\n<pre>.PHONY: build\r\nbuild:\r\n        dh $@\r\n<\/pre>\n<p><\/code><\/p><\/blockquote>\n<p>It happens that many of the packages I maintain contain a <code>build<\/code> subdirectory in their source. As such, to work around the aforementioned issue, I just declared the <code>dh<\/code> rules explicitely, as in:<\/p>\n<blockquote><p><code><\/p>\n<pre>.PHONY: build binary binary-arch binary-indep (...)\r\nbuild binary binary-arch binary-indep (...):\r\n        dh $@\r\n<\/pre>\n<p><\/code><\/p><\/blockquote>\n<p>And this obviously doesn't scale for new rules such as <code>build-arch<\/code> and <code>build-indep<\/code>.<\/p>\n<p>To be future-proof, I'll use the following instead:<\/p>\n<blockquote><p><code><\/p>\n<pre>.PHONY: build\r\nbuild %:\r\n        dh $@\r\n<\/pre>\n<p><\/code><\/p><\/blockquote>\n<p>I don't know why I didn't do that the first time...<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: .PHONY [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[23],"class_list":["post-2126","post","type-post","status-publish","format-standard","hentry","category-pdo","tag-en"],"_links":{"self":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2126"}],"version-history":[{"count":8,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2126\/revisions"}],"predecessor-version":[{"id":2135,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2126\/revisions\/2135"}],"wp:attachment":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}