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 581317 - libwnck fails to build outside source tree
libwnck fails to build outside source tree
Status: RESOLVED FIXED
Product: libwnck
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: libwnck maintainers
libwnck maintainers
: 605410 (view as bug list)
Depends on:
Blocks: 569778
 
 
Reported: 2009-05-04 14:22 UTC by Theppitak Karoonboonyanan
Modified: 2010-03-09 01:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use auto vars in make rules (1.33 KB, patch)
2009-05-04 14:34 UTC, Theppitak Karoonboonyanan
none Details | Review
Updated patch for auto vars method (1.24 KB, patch)
2009-07-29 04:16 UTC, Theppitak Karoonboonyanan
committed Details | Review

Description Theppitak Karoonboonyanan 2009-05-04 14:22:03 UTC
libwnck fails to build outside source tree, with following error:

---8<---
Making all in libwnck
  GEN   wnck-enum-types.h
Can't open libwnck.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open pager.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open application.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open class-group.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open screen.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open selector.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open tasklist.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open util.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open window.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open window-action-menu.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open workspace.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
  GEN   wnck-enum-types.c
Can't open libwnck.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open pager.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open application.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open class-group.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open screen.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open selector.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open tasklist.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open util.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open window.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open window-action-menu.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
Can't open workspace.h: No such file or directory at /home/gnome2/bin/glib-mkenums line 259.
  CC    wnck-enum-types.o
  GEN   wnck-marshal.h
  GEN   wnck-marshal.c
  CC    wnck-marshal.o
  CC    application.o
  CC    class-group.o
  CC    pager.o
  CC    screen.o
  CC    selector.o
  CC    tasklist.o
  CC    util.o
/home/thep/vcs/gnome_git/libwnck/libwnck/util.c: In function ‘wnck_init_resource_usage’:
/home/thep/vcs/gnome_git/libwnck/libwnck/util.c:122: warning: unused variable ‘error’
/home/thep/vcs/gnome_git/libwnck/libwnck/util.c:122: warning: unused variable ‘event’
  CC    window.o
/home/thep/vcs/gnome_git/libwnck/libwnck/window.c: In function ‘wnck_window_class_init’:
/home/thep/vcs/gnome_git/libwnck/libwnck/window.c:343: error: ‘WNCK_TYPE_WINDOW_STATE’ undeclared (first use in this function)
/home/thep/vcs/gnome_git/libwnck/libwnck/window.c:343: error: (Each undeclared identifier is reported only once
/home/thep/vcs/gnome_git/libwnck/libwnck/window.c:343: error: for each function it appears in.)
/home/thep/vcs/gnome_git/libwnck/libwnck/window.c:393: error: ‘WNCK_TYPE_WINDOW_ACTIONS’ undeclared (first use in this function)
make[2]: *** [window.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
---8<---

Apparently, the rules to generate source files still try to reference their sources directly rather than through VPATH.
Comment 1 Theppitak Karoonboonyanan 2009-05-04 14:34:22 UTC
Created attachment 133923 [details] [review]
Use auto vars in make rules
Comment 2 Vincent Untz 2009-07-28 22:23:47 UTC
Hrm, looking at some other uses of glib-mkenums (gnome-panel, gtk+, glib), nearly everybody is doing it this way. So why is it only broken for libwnck?

(also, the second part of the patch is wrong: we don't want to pass wnck-enum-types.h to glib-mkenums)
Comment 3 Theppitak Karoonboonyanan 2009-07-29 03:07:35 UTC
For gnome-panel, the header files are referenced with $(top_srcdir)/... prefix. So, it's OK for invoking from builddir. For example:

libpanel-applet/Makefile.am:

---8<---
panel_applet_enum_headers = $(top_srcdir)/libpanel-applet/panel-applet.h

panel-applet-enums.c: @REBUILD@ $(panel_applet_enum_headers)
        $(AM_V_GEN)glib-mkenums \
                     --fhead "#include <glib-object.h>\n" \
                     --fhead "#include \"panel-applet-enums.h\"\n\n" \
                     --fprod "\n/* enumerations from \"@filename@\" */" \
                     --fprod "\n#include \"@filename@\"\n" \
                     --vhead "static const G@Type@Value _@enum_name@_values[] = {" \
                     --vprod "  { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
                     --vtail "  { 0, NULL, NULL }\n};\n\n" \
                     --vtail "GType\n@enum_name@_get_type (void)\n{\n" \
                     --vtail "  static GType type = 0;\n\n" \
                     --vtail "  if (!type)\n" \
                     --vtail "    type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \
                     --vtail "  return type;\n}\n\n" \
                $(panel_applet_enum_headers) > $@
---8<---

$(panel_applet_enum_headers) refers to a header file in the source dir. So, it works.

Similarly for applets/clock/Makefile.am:

---8<---
clock_enum_headers =                                    \
        $(top_srcdir)/applets/clock/clock-utils.h
---8<---

and gnome-panel/Makefile.am:

---8<---
panel_enum_headers =                                    \
        $(top_srcdir)/gnome-panel/panel-enums.h         \
        $(top_srcdir)/gnome-panel/panel-types.h         \
        GNOME_Panel.h
---8<---

GNOME_Panel.h here is a file generated from $(ORBIT_IDL) command under the $(CORBA_SRCLIST) target. So, it's already in the build dir, and can be referenced without dirname prefix.

For glib, gio/Makefile.am in particular:

---8<---
gioenumtypes.h: $(gio_headers) gioenumtypes.h.template
        ( top_builddir=`cd $(top_builddir) && pwd`; \
          cd $(srcdir) && $$top_builddir/gobject/glib-mkenums --template gioenumtypes.h.template $(gio_headers) ) > \
            gioenumtypes.h.tmp && mv gioenumtypes.h.tmp gioenumtypes.h

gioenumtypes.c: $(gio_headers) gioenumtypes.c.template
        ( top_builddir=`cd $(top_builddir) && pwd`; \
          cd $(srcdir) && $$top_builddir/gobject/glib-mkenums --template gioenumtypes.c.template $(gio_headers) ) > \
            gioenumtypes.c.tmp && mv gioenumtypes.c.tmp gioenumtypes.c
---8<---

It works because the glib-mkenums command is invoked under the source dir!

Now come to libwnck itself:

---8<---
wnck_headers=                   \
        libwnck.h               \
        pager.h                 \
        application.h           \
        class-group.h           \
        screen.h                \
        selector.h              \
        tasklist.h              \
        util.h                  \
        window.h                \
        window-action-menu.h    \
        workspace.h
---8<---

There is no dirname prefix for the headers. So, the following make rules try to access them in the current directory, the build directory:

---8<---
wnck-enum-types.h: $(wnck_headers)
        $(AM_V_GEN)glib-mkenums \
                --fhead "#ifndef __WNCK_ENUM_TYPES_H__\n" \
                --fhead "#define __WNCK_ENUM_TYPES_H__\n\n" \
                --fhead "G_BEGIN_DECLS\n\n" \
                --ftail "G_END_DECLS\n\n" \
                --ftail "#endif /* __WNCK_ENUM_TYPES_H__ */\n" \
                --fprod "\n/* enumerations from \"@filename@\" */\n" \
                --eprod "#define WNCK_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \
                --eprod "GType @enum_name@_get_type (void);\n" \
                $(wnck_headers) > $@

wnck-enum-types.c: $(wnck_headers) wnck-enum-types.h
        $(AM_V_GEN)glib-mkenums \
                --fhead "#include <libwnck/libwnck.h>\n" \
                --fprod "\n/* enumerations from \"@filename@\" */" \
                --vhead "static const GEnumValue _@enum_name@_values[] = {" \
                --vprod "  { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
                --vtail "  { 0, NULL, NULL }\n};\n\n" \
                --vtail "GType\n@enum_name@_get_type (void)\n{\n" \
                --vtail "  static GType type = 0;\n\n" \
                --vtail "  if (!type)\n" \
                --vtail "    type = g_enum_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \
                --vtail "  return type;\n}\n\n" \
                $(wnck_headers) > $@
---8<---

A possible fix can be:

1. add $(top_srcdir)/... prefixes to the header files, just like what's done in gnome-panel, or

2. cd to $(srcdir) and invoking gtk-mkenums there, just like what glib does, or

3. refer to the headers with automatic make variables $^, which will be replaced with the rule's dependencies as found via VPATH search, as I proposed in the patch.

As I did't see the code in other packages when I prepared the fix, I chose the one with minimum change. Honestly speaking, solution 2, glib's method, was out of my imagination at that time, and I don't think it's suitable for libwnck, as the generated enum header is listed under the CLEANFILES. It will be out of reach of 'make clean' as it appeared to be originally designed.

> (also, the second part of the patch is wrong: we don't want to pass
> wnck-enum-types.h to glib-mkenums)

You're right. So, solution 1 may be the best in this case.
Comment 4 Theppitak Karoonboonyanan 2009-07-29 03:28:06 UTC
(In reply to comment #3)
> > (also, the second part of the patch is wrong: we don't want to pass
> > wnck-enum-types.h to glib-mkenums)
> 
> You're right. So, solution 1 may be the best in this case.

Or alternatively, why not just remove wnck-enum-types.h from wnck-enum-types.c dependencies? Is wnck-enum-types.h expected to be manually changed?

Just a little note about style: $(wnck_headers) is also used in libwnckinclude_HEADERS, unlike other packages examined here. If adding dirname prefixes is also OK in that place, solution 1 is OK.
Comment 5 Theppitak Karoonboonyanan 2009-07-29 04:16:17 UTC
Created attachment 139447 [details] [review]
Updated patch for auto vars method

Updated patch for solution 3 (auto vars method), without passing wnck-enum-types.h to glib-mkenums. $(wnck_built_headers) is added to $(libwnck_1_la_OBJECTS) dependencies to guarantee the built headers are still built.
Comment 6 paul 2010-02-04 02:25:56 UTC
*** Bug 605410 has been marked as a duplicate of this bug. ***
Comment 7 Vincent Untz 2010-03-09 01:58:07 UTC
Thanks, committed!