kde binary building is not portable :(
Benjamin Reed
ranger at befunk.com
Mon Nov 25 15:32:10 GMT 2002
After a discussion on the libtool list of working around module behavior
on Darwin, it has become evident that the way KDE treats libtool modules
is not portable (and apparently is not how you're supposed to use them
=)
The issue is that while on elf platforms, modules and shared libraries
are the same thing, there are platforms where this is not true.
Darwin/MacOSX and NetBSD a.out are the two I know about, but there may
be others as well.
(for more info, see the thread at the libtool list:)
http://mail.gnu.org/pipermail/libtool/2002-November/007235.html
There are tons of places in the KDE code where people are linking
against libtool libraries built with -module, but the most notable is in
the dummy binaries, ie, the ones with main() in the .so file, and then a
dummy.cpp that gets linked with that library to make the binary for
non-kdeinit startup.
For those, the NetBSD folks came up with this fix:
-----(before)-----
bin_PROGRAMS = foo
lib_LTLIBRARIES = foo.la
foo_la_SOURCES = main.cpp foo.cpp
foo_SOURCES = dummy.cpp
foo_LDADD = foo.la
-----(after)-----
bin_PROGRAMS = foo
lib_LTLIBRARIES = foo.la libfoo_main.la
libfoo_main_la_SOURCES = foo.cpp
foo_la_SOURCES = libfoo_main.cpp
foo_la_LIBADD = libfoo_main.la
foo_SOURCES = foo_main.cpp
foo_LDADD = libfoo_main.la
-----(snip!)-----
...their change makes foo.cpp contain an "extern int kdemain()" as it's
main function, and then the dummy files (foo_main.cpp and
libfoo_main.cpp) actually each contain a main() that just call the
kdemain().
It seems like this is kind of overkill, but I don't know if maybe it's
because some kind of weird symbol-loading issue on other platforms...
It certainly seems the safest way to do it.
If kdeinit's behavior is going to stay this way in the near future,
perhaps the easiest thing is to make an am_edit change or some kind of
automake macro that lets us define something like:
-----(foo.am)-----
bin_KDEPROGRAMS = foo
foo_SOURCES = foo.cpp # <-- contains kdemain() instead of main()
-----(snip!)-----
...and that auto-generates the above output (with a split foo.la and
libfoo_main.la) automatically.
We've been discussing this on the #kde-devel channel, and it sounds like
an am_edit macro that does the above transform is the easiest workaround
for this, and it allows for future removal of kdeinit if that is still a
goal.
Does this make sense? Do you need more info or clarification from me?
More information about the kde-core-devel
mailing list