summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-11-27 15:56:23 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2014-11-27 15:56:23 (GMT)
commit5091cbad4a2cd9761a0ce20790e3386467a10c80 (patch)
tree3bc2c296349ba03b99ac7171414b9ff5c78f6fb2
parent5343265256275893914612a2328978ea6af71bff (diff)
downloadbuildsystem-5091cbad4a2cd9761a0ce20790e3386467a10c80.tar.gz
buildsystem-5091cbad4a2cd9761a0ce20790e3386467a10c80.tar.bz2
Update the pkg-config installation macro for library substitution
This adds REQUIRED_LIBS variable which is a space separated list of libraries that will be macro expanded into LIBRARIES in pkg-config install target. This is typically used in the "Libs:" stanza for additional (possibly conditional) libraries necessary to link the final program.
-rw-r--r--example/libfoo.pc.in2
-rw-r--r--makefiles/Makefile.top6
2 files changed, 6 insertions, 2 deletions
diff --git a/example/libfoo.pc.in b/example/libfoo.pc.in
index eab313b..4f0f4f5 100644
--- a/example/libfoo.pc.in
+++ b/example/libfoo.pc.in
@@ -6,5 +6,5 @@ includedir=${prefix}/include
Name: libfoo
Description: Pointless example library
Version: 0.0.1
-Libs: -L${libdir}
+Libs: -L${libdir} LIBRARIES
Cflags: -I${includedir}
diff --git a/makefiles/Makefile.top b/makefiles/Makefile.top
index 89a040d..2d09276 100644
--- a/makefiles/Makefile.top
+++ b/makefiles/Makefile.top
@@ -12,7 +12,6 @@
# lib-static - Static library
# lib-shared - Shared library
# riscos-module - RISC OS module
-# BUILD Target platform identifier
#
# Optional inputs:
#
@@ -22,8 +21,10 @@
# information at the same time as compiling sources.
# Set to "yes" if it can.
# DESTDIR Sandboxed FS root (e.g. for packaging)
+# BUILD Target platform identifier, defaults to HOST
# HOST Host platform identifier
# REQUIRED_PKGS List of required pkg-config packages
+# REQUIRED_LIBS List of required libraries to add to pkg-config
#
# The client may also override all toolchain settings, including:
#
@@ -280,7 +281,9 @@ distclean: clean
__comma := ,
__empty :=
__space := $(empty) $(empty)
+__dashl := $(empty) -l$(empty)
__required = $(if $(REQUIRED_PKGS),Requires: $(subst $(__space),$(__comma) ,$(strip $(REQUIRED_PKGS))),)
+__libraries = $(if $(REQUIRED_LIBS),-l$(subst $(__space),$(__dashl),$(strip $(REQUIRED_LIBS))),)
# Install a pkg-config control file ($1) to the specified location ($2)
define install_pkgconfig
@@ -293,6 +296,7 @@ define install_pkgconfig
-e 's#PATCH#$(patch-version)#' \
-e 's#VERSION#$(COMPONENT_VERSION)#' \
-e 's#REQUIRED#$(__required)#' \
+ -e 's#LIBRARIES#$(__libraries)#' \
$1 >$(BUILDDIR)/$(1:.in=)
$(INSTALL) $(INSTALLFLAGS) -m 644 $(BUILDDIR)/$(1:.in=) \
$2/$(1:.in=)