After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 624910 - Mutter does not build out-of-tree.
Mutter does not build out-of-tree.
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Owen Taylor
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2010-07-21 10:01 UTC by Thierry Reding
Modified: 2016-06-27 21:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix out-of-tree build. (1.46 KB, patch)
2010-07-21 10:01 UTC, Thierry Reding
needs-work Details | Review
Fix out-of-tree build. (1.46 KB, patch)
2010-08-13 13:17 UTC, Thierry Reding
none Details | Review
Fix out-of-tree build. (3.45 KB, patch)
2010-08-16 05:35 UTC, Thierry Reding
accepted-commit_now Details | Review
Fix out-of-tree build. (3.93 KB, patch)
2010-08-17 06:27 UTC, Thierry Reding
none Details | Review
Fix out-of-tree build. (4.77 KB, patch)
2010-08-18 13:45 UTC, Thierry Reding
reviewed Details | Review
Fix out-of-tree build. (4.79 KB, patch)
2010-08-19 07:23 UTC, Thierry Reding
committed Details | Review
build: Modernize enum build rules (2.26 KB, patch)
2011-07-10 17:54 UTC, Colin Walters
rejected Details | Review

Description Thierry Reding 2010-07-21 10:01:27 UTC
Created attachment 166263 [details] [review]
Fix out-of-tree build.

The problem is that mutter-enum-types.h and mutter-enum-types.c targets
have dependencies on the respective .in files in the build directory
instead of the source directory.

A patch is attached that fixes this issue.
Comment 1 Owen Taylor 2010-08-12 16:06:38 UTC
Review of attachment 166263 [details] [review]:

This patch looks half-right to me; the changes to remove $(srcdir) from:

--template $(srcdir)/mutter-enum-types.h.in

are right ... the srcdir is extraneous since the code changes to $(srcdir) anyways and breaks the srcdir != builddir case. 

But the changes to the dependencies look wrong to me... see the docs for VPATH in the make manual. Could use a more descriptive git commit message.
Comment 2 Thierry Reding 2010-08-13 13:17:25 UTC
Created attachment 167809 [details] [review]
Fix out-of-tree build.

You are right, the dependencies are correct. I've come across another issue
with generating gobject-introspection data when building out-of-tree. I'm
attaching a patch which fixes both issues and has a more verbose commit
message.
Comment 3 Owen Taylor 2010-08-13 18:51:44 UTC
You attached the original patch again. (http://fishsoup.net/software/git-bz/ makes it easy to avoid this kind of mistake, which otherwise is really easy to do :-)
Comment 4 Thierry Reding 2010-08-16 05:35:05 UTC
Created attachment 167931 [details] [review]
Fix out-of-tree build.

This patch fixes two issues encountered when building mutter
out-of-tree:

  * When generating mutter-enum-types.[ch], the glib-mkenums command is
    executed from $(srcdir), so it is wrong to prepend $(srcdir) to the
    template file.

  * When generating gobject-introspection data, the g-ir-scanner command
    is executed from $(srcdir) and fails to find generated source file
    which reside in the build directory.

    To fix this, g-ir-scanner is run from the build directory, and
    $(srcdir) is prepended to non-generated source and header files.
Comment 5 Owen Taylor 2010-08-16 17:43:16 UTC
Review of attachment 167931 [details] [review]:

Looks good, let me know if you don't have a GNOME git account and I'll push it for you.

::: src/Makefile.am
@@ +207,3 @@
 # so that libgirepository looks for symbols in the executable instead
 Meta-$(api_version).gir: $(G_IR_SCANNER) mutter $(libmutterinclude_HEADERS) $(mutter_SOURCES)
+	$(AM_V_GEN)$(G_IR_SCANNER)			\

space after $(AM_V_GEN)

@@ +221,3 @@
+		$(addprefix $(srcdir)/,$(filter %.c,	\
+		  $(filter-out $(mutter_built_sources),	\
+		    $(mutter_SOURCES))))		\

Ouch. But don't have particularly better ways of doing this (you could split apart mutter_SOURCES into mutter_sources and mutter_built_sources, and save the filter-out, but not a ton better.)

So, OK.
Comment 6 Thierry Reding 2010-08-17 06:27:41 UTC
Created attachment 168028 [details] [review]
Fix out-of-tree build.

This patch fixes two issues encountered when building mutter
out-of-tree:

  * When generating mutter-enum-types.[ch], the glib-mkenums command is
    executed from $(srcdir), so it is wrong to prepend $(srcdir) to the
    template file.

  * When generating gobject-introspection data, the g-ir-scanner command
    is executed from $(srcdir) and fails to find generated source file
    which reside in the build directory.

    To fix this, g-ir-scanner is run from the build directory, and
    $(srcdir) is prepended to non-generated source and header files.
Comment 7 Thierry Reding 2010-08-17 06:31:49 UTC
I've reworked the patch according to your comments and I think splitting
off mutter_SOURCES into mutter_sources and mutter_built_sources is a bit
better.

I do not have a GNOME git account, so I won't be able to push it.
Comment 8 Dan Winship 2010-08-17 12:19:37 UTC
(In reply to comment #6)
>   * When generating gobject-introspection data, the g-ir-scanner command
>     is executed from $(srcdir) and fails to find generated source file
>     which reside in the build directory.
> 
>     To fix this, g-ir-scanner is run from the build directory, and
>     $(srcdir) is prepended to non-generated source and header files.

You shouldn't need to do any prepending. It can all be made to work via $VPATH magic. In particular, if you port it to use "include $(INTROSPECTION_MAKEFILE)" and then use the rules from there (as explained in $(prefix)/share/gobject-introspection-1.0/Makefile.introspection) rather than constructing the g-ir-scanner command line yourself, then you don't need to prefix $(srcdir) to anything.
Comment 9 Thierry Reding 2010-08-18 13:45:46 UTC
Created attachment 168202 [details] [review]
Fix out-of-tree build.

This patch fixes two issues encountered when building mutter
out-of-tree:

  * When generating mutter-enum-types.[ch], the glib-mkenums command is
    executed from $(srcdir), so it is wrong to prepend $(srcdir) to the
    template file.

  * Generate gobject-introspection data using Makefile.introspection as
    suggested by Dan Winship.
Comment 10 Dan Winship 2010-08-18 16:00:36 UTC
Comment on attachment 168202 [details] [review]
Fix out-of-tree build.

assuming that works, it seems right to me (the $(api_version) mangling is a bit ugly, but...)
Comment 11 Owen Taylor 2010-08-18 17:10:44 UTC
Review of attachment 168202 [details] [review]:

::: src/Makefile.am
@@ +197,3 @@
+INTROSPECTION_GIRS = Meta-$(api_version).gir.tmp
+
+Meta_$(subst .,_,$(api_version))_INCLUDES = \

This is really hard to read.

Does it work to do:

api_version_ := $(subst .,_,$(api_version))

Meta_$(api_version_)_INCLUDES = \

?
Comment 12 Thierry Reding 2010-08-19 07:20:54 UTC
That won't work, unfortunately, because automake will complain about bad
characters in the variable name. The closest I can get to what you are
proposing is something like this:

api_version_ := $(subst .,_,$(api_version))

Meta_$(value api_version_)_INCLUDES = \

I will follow up with a patch that implements that approach, so you can
see if you like it any better.
Comment 13 Thierry Reding 2010-08-19 07:23:05 UTC
Created attachment 168267 [details] [review]
Fix out-of-tree build.

This patch fixes two issues encountered when building mutter
out-of-tree:

  * When generating mutter-enum-types.[ch], the glib-mkenums command is
    executed from $(srcdir), so it is wrong to prepend $(srcdir) to the
    template file.

  * Generate gobject-introspection data using Makefile.introspection as
    suggested by Dan Winship.
Comment 14 Owen Taylor 2011-07-08 19:59:35 UTC
Review of attachment 168267 [details] [review]:

Sorry for the delay in handling this. The instrospection Makefile stuff was landed independently eventually:

commit a66ae4ad551b6b9778d790dd66842a186cae129a
Author: Dan Winship <danw@gnome.org>
Date:   Sat Mar 5 15:01:33 2011 -0500

    Use standard introspection configure/Makefile bits
    
    This changes the introspection configure flag from
    --with/--without-introspection to --enable/--disable-introspection,
    and changes it so that trying to enable introspection when g-i is not
    installed results in an error, rather than being silently ignored.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=643959

(with a configure.in substitution for the API version.) I'll extract out the rest of it and commit it. (It sneaked through the srcdir != builddir building for make distcheck because:

 builddir = mutter/mutter-3.1.3.1/_build/src
 srcdir = ../../src
 in srcdir, ../../src points to mutter/src/

So, it finds the files *outside* the test build tree)
Comment 15 Owen Taylor 2011-07-08 20:34:00 UTC
Committed relevant parts of patch

Attachment 168267 [details] pushed as 8033184 - Fix out-of-tree build.
Comment 16 Colin Walters 2011-07-10 17:54:30 UTC
Created attachment 191645 [details] [review]
build: Modernize enum build rules

The current rules are broken if srcdir != builddir, but this patch
also kills off the the stamp files.  They're a relic of an earlier
age; there's no reason not to depend on GLib tools at build time now.

I also use $@.tmp and $@ instead of the semi-random xgen-foo which
have been subject to copy-paste error before.

Note these rules depend on GNU Make, but the introspection build does
anyways.
Comment 17 Colin Walters 2011-07-10 17:55:32 UTC
I ran into this recently too, and had written this patch before I updated.  

I think my patch is better, for the reasons mentioned in the commit message.
Comment 18 Dan Winship 2011-07-10 18:47:04 UTC
i think you meant to reopen this, not mark it verified

(In reply to comment #16)
> The current rules are broken if srcdir != builddir, but this patch
> also kills off the the stamp files.  They're a relic of an earlier
> age; there's no reason not to depend on GLib tools at build time now.

No, that relic does exist in some packages (--disable-rebuild in glib and gtk at least), but that's different from this. The stamp files are so that mutter-enum-types.h only gets regenerated when you add/remove/change an enum, rather than being regenerated any time you make *any* change to a header file, thereby saving you from unnecessary recompiles of the files that depend on mutter-enum-types.h.
Comment 19 Colin Walters 2011-07-10 19:25:16 UTC
(In reply to comment #18)
> i think you meant to reopen this, not mark it verified
> 
> (In reply to comment #16)
> > The current rules are broken if srcdir != builddir, but this patch
> > also kills off the the stamp files.  They're a relic of an earlier
> > age; there's no reason not to depend on GLib tools at build time now.
> 
> No, that relic does exist in some packages (--disable-rebuild in glib and gtk
> at least), but that's different from this. The stamp files are so that
> mutter-enum-types.h only gets regenerated when you add/remove/change an enum,
> rather than being regenerated any time you make *any* change to a header file,
> thereby saving you from unnecessary recompiles of the files that depend on
> mutter-enum-types.h.

Ah, right.  Well, in my patch, it looks like in that case we'll run glib-mkenums on every invocation of "make" since we use 'cmp' to avoid updating the header file.

I dunno; most nontrivial projects end up having a lot of internal header inclusion, so in practice, you need to rebuild a lot if any header files change.

The solution to this IMO is ccache; it is a *large* compilation speed win in many cases, and as a huge bonus it's 99% transparent.  The stamp file hack here is a relative micro-optimization.

Bottom line then I guess, we should either:

1) Remove the cmp in my patch, and unconditionally run glib-mkenums on header file changes (and I bet no one notices)
2) Not take my patch
Comment 20 Owen Taylor 2011-07-11 14:07:35 UTC
Review of attachment 191645 [details] [review]:

I do like being able to change a header file without recompiling everything from scratch. The stamp file approach is the best way we found to achieve that.

The rest of the changes? 

 - Use GNU make $(addprefix ...) rather than cd'ing to srcdir. Meh.
 - Use temporary names based on $@ rather than xgen-<whatever. Sure, that's better, a patch to just do that would be fine.