syncevolution/src/syncevo/icaltz-util-wrapper.c
Patrick Ohly 426ec3543a syncevolution.org: compile on Ubuntu Trusty, libical v1/v2 compatibility
syncevolution.org binaries are now getting compiled on Ubuntu Trusty and thus
no longer support distros with older EDS. The code should still compile
against older EDS (for example, for Maemo), but that is not getting tested
anymore.

This allows removing the dynamic linker hacks related to older libraries,
which was only used in those binaries. Instead, backends using libical or EDS
get compiled on Ubuntu Trusty and then the soname of those libs get patched to
make the backend module usable in combination with a different set of
libs. That patching is part of a script maintained in the syncevolution.org
build infrastructure.

This approach was already used before to generate different EDS backends
for EDS versions with the newer EClient API, because that turned out to be
easier than the dynamic loading approach. It works because none of the methods
used by SyncEvolution changed their ABI, only some other parts of the
libraries did. Should there ever be a situation again that cannot be handled
like this, then backends might also get compiled on different distros than
Ubuntu Trusty (however, that may lead to problems due to the libstdc++ ABI
changes - to be decided...).

libical still requires one special hack: system time zone loading in
libical v1 (and only in that version, v2 has builtin support again) must
be overridden such that time zones are generated with rules instead
of transitions because that is more compatible with the peers that
SyncEvolution exchanges data with.

That hack now relies on overriding the two relevant functions inside the main
binaries (has to be there, otherwise libical still ends up calling its own
internal implementation). The overriding code is in
libsyncevo-icaltz-util.so.0 and depends on libical.so.1. If
libsyncevo-icaltz-util.so.0 can be loaded, the wrappers in the main binary use
it, otherwise they fall through to the code from the current libical.so, which
then should be libical.so.2 or more recent.

This hack is active by default when libical v1 is detected during configuration.
2016-09-26 12:58:26 +02:00

43 lines
1.2 KiB
C

#define _GNU_SOURCE 1
#include <dlfcn.h>
static void *(*icaltimezone_get_component_p)(void *zone);
static void *(*icaltzutil_fetch_timezone_p)(const char *location);
static void init()
{
static int initialized;
if (!initialized) {
static void *icaltzutil;
icaltzutil = dlopen("libsyncevo-icaltz-util.so.0", RTLD_LAZY|RTLD_LOCAL);
if (icaltzutil) {
icaltimezone_get_component_p = dlsym(icaltzutil, "icaltimezone_get_component");
icaltzutil_fetch_timezone_p = dlsym(icaltzutil, "icaltzutil_fetch_timezone");
} else {
icaltimezone_get_component_p = dlsym(RTLD_NEXT, "icaltimezone_get_component");
icaltzutil_fetch_timezone_p = dlsym(RTLD_NEXT, "icaltzutil_fetch_timezone");
}
initialized = 1;
}
}
void *icaltimezone_get_component(void *zone)
{
init();
return icaltimezone_get_component_p(zone);
}
void *icaltzutil_fetch_timezone(const char *location)
{
init();
return icaltzutil_fetch_timezone_p(location);
}
/*
* For including the .o file in binaries via -Wl,-usyncevo_fetch_timezone.
* We cannot use -Wl,-uicaltzutil_fetch_timezone because that gets satisfied by
* libical itself.
*/
int syncevo_fetch_timezone;