autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: generating pc files


From: Russ Allbery
Subject: Re: generating pc files
Date: Wed, 19 Sep 2012 00:46:31 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Vincent Torri <address@hidden> writes:

> But it seems that several projects use sed in their Makefile.am to use
> the value of $libdir, $includedir, etc.. to generate their pc files. So
> they have in foo.pc

> libdir=${libdir}

> So I would like to know the opinion of the autoconf dev about what the
> correct way to generate pc file is.

Well, I'm not an Autoconf developer, so feel free to ignore this, but I've
been very happy with the following recipe.  A *.pc.in file that looks
like:

    address@hidden@
    address@hidden@
    address@hidden@
    address@hidden@

    Name: <name>
    Description: <description>
    URL: <url>
    Version: @PACKAGE_VERSION@
    Cflags: -I${includedir}
    Libs: -L${libdir} -l<library>
    Libs.private: <other-libs>

with the <...> bits replaced with whatever is appropriate for your
library, and then the following in Makefile.am (adjusting file paths
accordingly, of course:

client/libremctl.pc: $(srcdir)/client/libremctl.pc.in
        sed -e 'address@hidden@]!$(prefix)!g'                     \
            -e 'address@hidden@]!$(exec_prefix)!g'           \
            -e 'address@hidden@]!$(includedir)!g'             \
            -e 'address@hidden@]!$(libdir)!g'                     \
            -e 'address@hidden@]!$(PACKAGE_VERSION)!g'   \
            -e 'address@hidden@]!$(GSSAPI_LDFLAGS)!g'     \
            -e 'address@hidden@]!$(GSSAPI_LIBS)!g'           \
            $(srcdir)/client/libremctl.pc.in > $@

Note the last two sed expressions, which show how to handle additional
flags for linking with other libraries.  @GSSAPI_LDFLAGS@ @GSSAPI_LIBS@ is
in the Libs.private part of my *.pc.in file in this case.

This has make expand all the variables for you, so you can safely omit
exec_prefix if you want; nothing else will refer to it, since the
variables will be fully collapsed.  I include it just for the hell of it.

The result, for this particular package as installed on Debian (so with a
multiarch libdir) looks like:

    prefix=/usr
    exec_prefix=/usr
    includedir=/usr/include
    libdir=/usr/lib/i386-linux-gnu

    Name: remctl
    Description: Remote authenticated command execution with ACLs
    URL: http://www.eyrie.org/~eagle/software/remctl/
    Version: 3.2
    Cflags: -I${includedir}
    Libs: -L${libdir} -lremctl
    Libs.private:  -lgssapi_krb5

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]