Tugger the SLUGger!SLUG Mailing List Archives

Re: [chat] portable scripting


On Thu, Feb 06, 2003 at 12:11:17AM +0000, Pete Ryland wrote:
> 
> Another cool thing which I've only noticed recently (via sweep) is
> pkg-config[2] which should hopefully relieve more anguish.  However, I never
> understood the benefit of having a script that parsed a command line and
> echoed a value, only to be interpreted into another script.  Why not just
> have a script which set these as env vars which could be sourced by the
> configure script (much like a lot of init.d configuration files use)?
> Actually, you can already do this with autoconf's Site Config stuff[3], and
> all that is needed then is that packages when installed update that script
> (similarly to how Debian does modules.conf perhaps).
> 

pkg-config came about as a replacement for a bunch of similar scripts
(gtk-config, sndfile-config, ekepoint-config ...) which did just that --
each script parsed flags like --cflags and --libs and gave the needed
output.

then, you have a maintenance nightmare on the system where it's hard
to be sure that all such scripts behave the same way; most of these
scripts were sed-hacked versions of each other, usually by people who
didn't understand m4 properly (eg. me), so it was basically impossible
to try to add functionality globally.

pkg-config replaces this with a compiled program that parses simple
config files like this one (Erik's from libsndfile):

conrad@screech:~% cat /usr/local/lib/pkgconfig/sndfile.pc 
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sndfile
Description: A library for reading and writing audio files.
Requires: 
Version: 1.0.2
Libs: -L${libdir} -lsndfile
Cflags: -I${includedir} 

then, the pkg-config tool can be used to do new things like provide info
on all packages installed and trace back dependencies at build-time, and
stuff like checking if the version of any package is "at least X.x" or
"max X.x" etc. without duplicating those checks everywhere.

you can also set package-specific variables related to the installation
in the pkg-config file, then pick that up in the configure script of
another package, which is a very powerful way of breaking 'make distcheck'
;)

K.