Subject: Re: pkgconfig and buildlink
To: Johnny C. Lam <jlam@netbsd.org>
From: None <mcmahill@mtl.mit.edu>
List: tech-pkg
Date: 03/19/2002 20:35:57
On Tue, 19 Mar 2002, Johnny C. Lam wrote:
> On Sun, Mar 17, 2002 at 10:43:16AM -0500, mcmahill@mtl.mit.edu wrote:
> >
> > are there any examples of how to create buildlink.mk files for packages
> > which use devel/pkgconfig (sort of a universal gtk-config type program).
>
> Can you give some examples of packages in our tree that use pkg-config?
> I'd like to study how it's invoked so I can help devise a buildlink.mk
> solution.
i'm not sure of any, but 4 packages I'm working on importing soon do....
graphics/imlib and graphics/gphoto2 both install .pc files, but it looks
like they don't do anything with them.
pkg-config works pretty much like the usual gtk-config, glib-config, etc.
The primary difference is there is a directory, /usr/pkg/lib/pkgconfig/,
where .pc files live. One per package. So where you used to type
gtk-config --cflags
glib-config --libs
you now type
pkg-config --cflags gtk-2.0
pkg-config --libs glib-2.0
there are a few other args that can check for the existance of programs.
The .pc files look like:
mudshark# more /usr/pkg/lib/pkgconfig/glib-2.0.pc
prefix=/usr/pkg
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=/usr/pkg/include/glib
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: GLib
Description: C Utility Library
Version: 2.0.0
Libs: -L${libdir} -R${libdir} -lglib-2.0 -lintl -liconv
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include
My first attempt at doing something for this is:
RCS file: /cvsroot/pkgsrc/mk/bsd.buildlink.mk,v
retrieving revision 1.55
diff -u -2 -r1.55 bsd.buildlink.mk
--- bsd.buildlink.mk 2002/02/26 22:24:00 1.55
+++ bsd.buildlink.mk 2002/03/20 01:22:43
@@ -185,10 +185,37 @@
.if defined(USE_BUILDLINK_ONLY)
USE_CONFIG_WRAPPER= # defined
+BUILDLINK_PKG_CONFIG= ${BUILDLINK_DIR}/bin/pkg-config
+CONFIGURE_ENV+= PKG_CONFIG="${BUILDLINK_PKG_CONFIG}"
+MAKE_ENV+= PKG_CONFIG="${BUILDLINK_PKG_CONFIG}"
.endif
+BUILDLINK_PKG_CONFIG_SED?= # empty
+_BUILDLINK_PKG_CONFIG_POST_SED+= \
+ -e "s|-I${LOCALBASE}/|-I${BUILDLINK_DIR}/|g" \
+ -e "s|-L${LOCALBASE}/|-L${BUILDLINK_DIR}/|g" \
+ -e "s|-I${X11PREFIX}/|-I${BUILDLINK_DIR}/|g" \
+ -e "s|-L${X11PREFIX}/|-L${BUILDLINK_DIR}/|g"
+
+${BUILDLINK_PKG_CONFIG}:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO_BUILDLINK_MSG} "Creating pkg-config wrapper
${BUILDLINK_PKG_CONFIG}"; \
+ ${MKDIR} ${BUILDLINK_PKG_CONFIG:S/pkg-config//}; \
+ (${ECHO} '#!/bin/sh'; \
+ ${ECHO} ''; \
+ ${ECHO} 'pc=`${LOCALBASE}/bin/pkg-config $$*`'; \
+ ${ECHO} 'rslt=$$?'; \
+ ${ECHO} '${ECHO} "$$pc" | ${SED} \'; \
+ ${ECHO} ' ${BUILDLINK_PKG_CONFIG_SED} \'; \
+ ${ECHO} ' ${_BUILDLINK_PKG_CONFIG_POST_SED}'; \
+ ${ECHO} 'exit $$rslt'; \
+ ) > ${BUILDLINK_PKG_CONFIG} ; \
+ ${CHMOD} +x ${BUILDLINK_PKG_CONFIG};
+
BUILDLINK_CONFIG_WRAPPER_SED?= # empty
_BUILDLINK_CONFIG_WRAPPER_POST_SED+= \
-e "s|-I${LOCALBASE}/|-I${BUILDLINK_DIR}/|g" \
- -e "s|-L${LOCALBASE}/|-L${BUILDLINK_DIR}/|g"
+ -e "s|-L${LOCALBASE}/|-L${BUILDLINK_DIR}/|g" \
+ -e "s|-I${X11PREFIX}/|-I${BUILDLINK_DIR}/|g" \
+ -e "s|-L${X11PREFIX}/|-L${BUILDLINK_DIR}/|g"
_BUILDLINK_CONFIG_WRAPPER_USE: .USE
then in, for example devel/glib2/buildlink.mk, I added:
BUILDLINK_TARGETS+= ${BUILDLINK_PKG_CONFIG}
The idea is just to create a wrapper around pkg-config. Have to be a bit
careful about return values as pkg-config's return value does mean
something.
Comments? Maybe I should put this instead in a
devel/pkgconfig/buildlink.mk file? Maybe we need a USE_PKG_CONFIG
variable?
This is one of the 2 things left before I import glib/gtk-2.
-Dan