GNOME Bugzilla – Bug 444960
srcdir vs. builddir fixes for out-of-source-tree builds
Last modified: 2007-06-07 13:29:25 UTC
Please describe the problem: I am building GIMP with a build tree that is separate from the source tree. Several rules in the GIMP makefiles are a bit mixed up w.r.t. the builddir vs. srcdir distinction. For example, many rules specify a generated-file target with an $(srcdir) prefix (e.g. "$(srcdir)/gimpmarshal.c" instead of just "gimpmarshal.c"), but will then write the file to $(@F), in builddir. This is problematic because GNU Make will generate the files in builddir, but then pass srcdir paths to the compiler, which errors out on not finding the file there. If there is a checked-in copy of the generated file, then GNU Make tends to end up regenerating the file every time, because timestamps are compared on an old copy of the file (in srcdir) instead of the latest one (in builddir). The correct thing to do is for the rules to consistently specify and create targets in builddir (i.e. no srcdir prefix), so that (1) the above problems are avoided, (2) files are not written to a potentially read-only build tree, and (3) GNU Make's VPATH feature can do the job it was intended to do. Elsewhere, xlstproc invocations were failing due to missing .xsl files; these were not specified with the necessary $(srcdir) prefix. For the rule that generates authors.h, I also put in a fallback for the benefit of users without xsltproc. Finally, the libgimpwidgets makefile was specifying gimpwidgets-private.c: gimp-wilber-pixbufs.h when what it actually meant is gimpwidgets-private.lo: gimp-wilber-pixbufs.h This was causing GNU Make to act strangely, looking for gimpwidgets-private.c in the wrong location. Steps to reproduce: Just pull down GIMP from SVN, autogen it, and build it outside of the source tree. This will fail horribly. I did further checking by doing the same thing, but with a read-only source tree. This revealed that pdbgen was writing temp files in srcdir (bad!), among other things.... Actual results: Expected results: Does this happen every time? Other information:
Created attachment 89525 [details] [review] Patch against current SVN This patch restores the ability to build outside of a freshly autogen'ed SVN source tree, with the tree marked read-only, and such that invoking make(1) a second time does not rebuild/regenerate anything. In other words, Correct Behavior(tm).
We regularily use 'make distcheck' to build the development releases. 'make distcheck' builds gimp with srcdir != builddir and a read-only srcdir and it succeeds. But I will nevertheless examine your patch and check if there's anything that should be applied.
I have done two minor changes inspired by your patch: 2007-06-07 Sven Neumann <sven@gimp.org> * app/dialogs/Makefile.am: bail out with an error if xsltproc is missing and authors.h needs to be regenerated. * libgimpwidgets/Makefile.am: let gimpwidgets-private.lo, not the C file, depend on gimp-wilber-pixbufs.h. From the patch attached to bug #444960. I don't believe though that the other changes are correct. The generated files are all considered part of the srcdir and are supposed to be part of the tarball. They will only ever be generated in a developer build. Building with srcdir != builddir is supported but only for a build from the tarball, not for building from an SVN checkout. I will careful check the other changes in your patch, perhaps we can apply a few more. But for example for the files generated by pdbgen, the proposed changes are wrong.
2007-06-07 Sven Neumann <sven@gimp.org> * app/dialogs/Makefile.am * menus/Makefile.am: when calling xsltproc, use the stylesheet from $(srcdir). From the patch attached to bug #444960.
Created attachment 89535 [details] [review] patch without the parts that have already been applied
I've run lots of tests and it appears that my concerns were not justified. The tree seems to build fine with these changes and still passes 'make distcheck'. I have thus committed all changes to SVN now: 2007-06-07 Sven Neumann <sven@gimp.org> * app/text/Makefile.am * app/core/Makefile.am * app/tools/Makefile.am * app/display/Makefile.am * app/widgets/Makefile.am * app/base/Makefile.am * app/paint/Makefile.am * app/plug-in/Makefile.am * libgimp/Makefile.am * libgimpthumb/Makefile.am * tools/pdbgen/Makefile.am * libgimpwidgets/Makefile.am: applied the remaining parts of the patch from Daniel Richard G. to fix out-of-source-tree builds (bug #444960).
I was about to submit a comment to the effect that VPATH makes it all work :-) I'm noticing that "make dist" isn't quite working yet in the "build tree off clean SVN tree" case (can't find the i18n message files), so I'll file another bug for that one once I have a patch.