Question

I am trying to build an application with OpenSync 0.4 (0.3.9 indeed) dependency.

In the project's configure.ac the opensync library is written as libopensync1. However, this doesn't build on my Gentoo system. Changing libopensync1 to libopensync does fix the issue for me.

I searched with Google and found that libopensync1 is used in some distributions, while libopensync in others. So how to resolve this issue in configure.ac?

Thanks.

Was it helpful?

Solution

I'm assuming that the place at which this occurs inside your configure.ac is inside a PKG_CHECK_MODULES call.

Looking at the libopensync sources, it seems that libopensync1 is the newer name, and libopensync is the old name. So, we'll use pkg-config macros to look for the newer name unless it doesn't exist.

Put this in your configure.ac:

# Check if libopensync1 is known to pkg-config, and if not, look for libopensync instead
PKG_CHECK_EXISTS([libopensync1], [OPENSYNC=libopensync1], [OPENSYNC=libopensync])

Then later in your PKG_CHECK_MODULES call, replace libopensync1 with $OPENSYNC.

OTHER TIPS

The macro AC_SEARCH_LIBS does what you need. (There is much heated debate about whether or not pkg-config should ever be used. If you choose to rely on it, ptomato gives a reasonable approach.) Simply add this to your configure.ac:

AC_SEARCH_LIBS([osync_mapping_new],[opensync1 opensync],[],
  [AC_MSG_ERROR([can't find opensync])])

This will first look for a library named opensync1; if it doesn't find that, it will look for opensync.

The primary drawback of using pkg-config is that most projects that rely on it do not actually check if the data provided by the .pc file is reliable, so configure may succeed but a subsequent build will fail. It is always possible for a user to set PKG_CONFIG=true when running configure and completely eliminate all of the data provided by any associated .pc files, setting LIBS, CFLAGS, etc by hand the 'old-fashioned' way.

The primary drawback of not using pkg-config is that the user has to set LIBS, CFLAGS, etc. the old-fashioned way. In practice, this is pretty trivial, and all pkg-config has done is move the data from a single CONFIG_SITE file to separately maintained .pc files for each package.

If you do use PKG_MODULE_CHECK, follow it up with a call to AC_CHECK_LIB or AC_SEARCH_LIBS to validate the data in whatever .pc file was located by PKG_CHECK_MODULES

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top