Requires.private with optional dependencies?‏

Jef Driesen jefdriesen at hotmail.com
Fri Sep 23 03:59:02 PDT 2011


Hi,
 
I have a library that depends on another library (libusb) for its implementation. My understanding is that I need to add the libusb library to the "Requires.private" of my pkg-config file. So far no problem, but what if the libusb dependency is optional?
 
My configure.ac file contains:
 
# Checks for USB support.
PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [have_libusb=yes], [have_libusb=no])
if test "$have_libusb" = "yes"; then
   AC_DEFINE([HAVE_LIBUSB], [1], [libusb support])
fi
 
With this I can use $(LIBUSB_CFLAGS) and $(LIBUSB_LIBS) in the Makefile.am and HAVE_LIBUSB in the source code. But how should I write th *.pc.in file for m library? Obviously I can't just write:
 
Requires.private: libusb-1.0
 
Is the correct way to add this line inside the if statement above:
 
AC_SUBST([DEPENDENCIES],[libusb-1.0])
 
And then use this line in the *.pc.in file:
 
Requires.private: @DEPENDENCIES@
 
Jef
 		 	   		  


More information about the pkg-config mailing list