Vincent Torri <[email protected]> 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:
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
libdir=@libdir@
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 's![@]prefix[@]!$(prefix)!g' \
-e 's![@]exec_prefix[@]!$(exec_prefix)!g' \
-e 's![@]includedir[@]!$(includedir)!g' \
-e 's![@]libdir[@]!$(libdir)!g' \
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
-e 's![@]GSSAPI_LDFLAGS[@]!$(GSSAPI_LDFLAGS)!g' \
-e 's![@]GSSAPI_LIBS[@]!$(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 ([email protected]) <http://www.eyrie.org/~eagle/>
_______________________________________________
Autoconf mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/autoconf