Discussion:
Using AC_LIB_HAVE_LINKFLAGS with non standard named libraries generates "non-POSIX" automake error?
Johan Persson
2013-11-22 22:40:44 UTC
Permalink
I've stumbled on on an "stupid" issue I've never had to deal with before
and I can't seem to get around it (could also be that I'm getting
tired...)

In my configure.ac I'm using a number of standard
AC_LIB_HAVE_LINKFLAGS() calls to allow the end user to configure the
library locations. This works as expected.

However one of the libraries I need to configure is named
"libusb-1.0.so" but if I use "usb-1.0" as the library name in the call
to the macro this will the generate an illegal variable name that
automake chokes on.

SRC/MAKEFILE.AM:19: WARNING: LIBUSB-1.0: NON-POSIX VARIABLE NAME

Renaming the name of the library is no-solution since I cannot control
3:rd party library installation.

Have anyone else had to deal with this? (I guess there is a simple
solution that I just fail to see but no matter of what more and more
bizarre quoting I tried with I cannot get automake to accept the name)

--Johan

(I'm using autoconf 2.69 / automake 1.12.1)
Eric Blake
2013-11-22 22:55:27 UTC
Permalink
Post by Johan Persson
However one of the libraries I need to configure is named
"libusb-1.0.so" but if I use "usb-1.0" as the library name in the call
to the macro this will the generate an illegal variable name that
automake chokes on.
SRC/MAKEFILE.AM:19: WARNING: LIBUSB-1.0: NON-POSIX VARIABLE NAME
Needs more context. Can you boil it down to a minimal configure.ac and
Makefile.am that reproduce the problem of using just that library, so
that we can see what you have attempted and offer suggestions how to fix
it? It sounds like it is just a matter of requesting a transliteration
of - to _ in the variable name used to track whether the library is
present, but without seeing your actual code, I can't suggest where to
add the m4_translit.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Johan Persson
2013-11-22 23:29:08 UTC
Permalink
However one of the libraries I need to configure is named "libusb-1.0.so" but if I use "usb-1.0" as the library name in the call to the macro this will the generate an illegal variable name that automake chokes on. SRC/MAKEFILE.AM:19: WARNING: LIBUSB-1.0: NON-POSIX VARIABLE NAME
Needs more context. Can you boil it down to a minimal configure.ac and
Makefile.am that reproduce the problem of using just that library, so
<SNIP>
Fortunately that is easy (for once). The following trivial combo shows
the problem.

autoconf.ac :

AC_PREREQ([2.69])
AC_INIT([myprog],[0.0.1])
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([
Makefile
])
AC_LIB_HAVE_LINKFLAGS([[usb-1.0]],[],[],[],[libusb-1.0 Library needed.])
AC_OUTPUT

Makefile.am :

bin_PROGRAMS = a
SUBDIRS = .
a_SOURCES = main.c
a_LDADD = $(LIBUSB-1.0)
Eric Blake
2013-11-22 23:39:37 UTC
Permalink
Post by Johan Persson
Fortunately that is easy (for once). The following trivial combo shows
the problem.
AC_LIB_HAVE_LINKFLAGS([[usb-1.0]],[],[],[],[libusb-1.0 Library needed.])
This macro is not provided by autoconf. (It's a shame that the macro
author abused the AC_ namespace instead of putting it in another
namespace, because it means if autoconf ever DOES implement this macro,
it will break this third-party code.) You'll need to track down the
implementation of AC_LIB_HAVE_LINKFLAGS before I can offer further
suggestions.
Post by Johan Persson
AC_OUTPUT
bin_PROGRAMS = a
SUBDIRS = .
a_SOURCES = main.c
a_LDADD = $(LIBUSB-1.0)
$(LIBUSB-1.0) is not a valid make variable name. You probably want:

a_LDADD = $(LIBUSB_1_0)

(autoconf and automake both tend to normalize - and . into _). But
whether that will help or not goes back to what AC_LIB_HAVE_LINKFLAGS is
doing under the hood.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Johan Persson
2013-11-23 00:02:35 UTC
Permalink
Fortunately that is easy (for once). The following trivial combo shows the problem.
AC_LIB_HAVE_LINKFLAGS([[usb-1.0]],[],[],[],[libusb-1.0 Library needed.])
This macro is not provided by autoconf. (It's a shame that the macro
author abused the AC_ namespace instead of putting it in another
namespace, because it means if autoconf ever DOES implement this macro,
it will break this third-party code.) You'll need to track down the
You are right! I've been using this construction for several years and I
always though this was part of the core autoconf. Looking more closely
this is provided by Gnulib module "havelib" (See
https://www.gnu.org/software/gnulib/manual/html_node/Searching-for-Libraries.html#Searching-for-Libraries
[1])

However, it seems thought that the macro is well behaved in that it does
normalize to "_" which means that using the variable name with "_"
instead actually works. Problem solved and I still can have warning free
code.

Thanks for the pointers!

--Johan


Links:
------
[1]
https://www.gnu.org/software/gnulib/manual/html_node/Searching-for-Libraries.html#Searching-for-Libraries
Loading...