Women in Technology

Hear us Roar

  Making Packager-Friendly Software
Subject:   Patching Makefiles?!
Date:   2005-05-10 10:31:21
From:   aristotle
Uhm, okay, most of this article is good stuff.

But what is this… sorry, but there’s no way to call it other than “tripe”… so what is this tripe about patching and seding Makefiles? If a Makefile defines a PREFIX variable, and you want to install to a PREFIX other than the default, you say make install PREFIX=/do/it/my/way and away it goes. make is so wonderful. Why do you want to twist it into something awful like a patched and sedded mess?

Apparently due to this same misunderstanding of make, there is also a grave ommision in the article: all Makefiles should always, always define and use a DESTDIR variable for their install target. This is not the same as the prefix. This is prepended to the entire path including the prefix when installing, which allows a packager to install the package into an isolated tree like /tmp/pkg-foo-0.12. The files would then end up in places like /tmp/pkg-foo-0.12/usr/bin/foo and /tmp/pkg-foo-0.12/usr/share/doc/foo-0.12/README. This makes easy to tar the whole thing up, as opposed to piecing together a mess of files spammed all over the root partition.

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Patching Makefiles?!
    2005-05-10 11:20:41  jmmv [View]

    I knew the "make VAR=value" trick, and I use it wherever possible to avoid patching Makefiles (which is a maintenance nightmare). But it's not always useful.

    For example, you may want to just change a part of the variable (i.e., to remove some flags), or you may want to append a value to it. Anyway, despite Makefiles were used to describe this technique, it is applicable to any other kind of file, such as configuration files, manual pages, scripts (as described in the #!/usr/bin/perl example), etc. Therefore, the same problems and solutions arise.

    About the DESTDIR thing, yes, you are right. I'd have mentioned it, as it makes things nice with staged installations (and certainly helps some packaging systems). I forgot because we don't use it in pkgsrc ;)

    Thanks for your comments.
    • Patching Makefiles?!
      2005-05-10 12:36:33  aristotle [View]

      Ah. Well, that is why it’s good to write Makefiles such that large aggregate values like CFLAGS are concatenated from many different partial variables. :) A typical example might be MAN1DIR=$(PREFIX)/$(MANDIR)/man1 which gives maximum flexibility in how to influence the final destination of manpages from section 1. Well written Makefiles aren’t difficult to write, it just takes a bit of thought and work, and small projects without too much optional functionality don’t really need any additional build system scaffolding.