Skip to content

Commit

Permalink
add Requires: and Requires.private: to libplanes.pc
Browse files Browse the repository at this point in the history
This allows for resolving dependent libraries using pkg-config instead of having
to explicitly list them.

Signed-off-by: Joshua Henderson <[email protected]>
  • Loading branch information
joshua-henderson committed May 30, 2019
1 parent f64a2d5 commit 7b2df7f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Makefile.in
/autom4te.cache/
/config.*
/configure
m4/*.m4
/stamp-h?
.deps/
.dirstamp
Expand Down
10 changes: 5 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@ AC_TYPE_INT32_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.0], [], [AC_MSG_ERROR([
AX_PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.0], [], [], [AC_MSG_ERROR([
libdrm is a hard dependency, but a sufficient version was not found.])])

PKG_CHECK_MODULES(CJSON, [libcjson >= 1.6.0], [], [AC_MSG_ERROR([
AX_PKG_CHECK_MODULES([CJSON], [], [libcjson >= 1.6.0], [], [AC_MSG_ERROR([
cJSON is a hard dependency, but a sufficient version was not found.])])

PKG_CHECK_MODULES(LUA, [lua >= 5.3.1], [], [AC_MSG_ERROR([
AX_PKG_CHECK_MODULES([LUA], [], [lua >= 5.3.1], [], [AC_MSG_ERROR([
liblua is a hard dependency, but a sufficient version was not found.])])

PKG_CHECK_MODULES(DIRECTFB, [directfb >= 1.7.0], [have_directfb=yes], [have_directfb=no])
PKG_CHECK_MODULES([DIRECTFB], [directfb >= 1.7.0], [have_directfb=yes], [have_directfb=no])
AM_CONDITIONAL(HAVE_DIRECTFB, [test "x$have_directfb" != "xno"])

if test "x$have_directfb" = "xyes"; then
AC_C_INLINE
fi

PKG_CHECK_MODULES(CAIRO, [cairo >= 1.14.6], [], [AC_MSG_ERROR([
AX_PKG_CHECK_MODULES([CAIRO], [cairo >= 1.14.6], [], [], [AC_MSG_ERROR([
cairo is a hard dependency, but a sufficient version was not found.])])

AC_ARG_ENABLE([python],
Expand Down
2 changes: 2 additions & 0 deletions libplanes.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Description: Microchip library for working with hardware LCD planes
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lplanes
Cflags: -I${includedir} -I${includedir}/planes
Requires: @AX_PACKAGE_REQUIRES@
Requires.private: @AX_PACKAGE_REQUIRES_PRIVATE@
Empty file removed m4/.empty
Empty file.
5 changes: 5 additions & 0 deletions m4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
libtool.m4
lt~obsolete.m4
ltoptions.m4
ltsugar.m4
ltversion.m4
69 changes: 69 additions & 0 deletions m4/ax_pkg_check_modules.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pkg_check_modules.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PKG_CHECK_MODULES(PREFIX, PUBLIC-MODULES, PRIVATE-MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [PUBLIC-VARIABLE], [PRIVATE-VARIABLE])
#
# DESCRIPTION
#
# A wrapper around PKG_CHECK_MODULES which splits the list of modules into
# public and private dependencies, and produces two variables listing the
# dependencies across all invocations of AX_PKG_CHECK_MODULES. These two
# variables are exposed via AC_SUBST, and should be used in a pkg-config
# file as the substituted values for Requires and Requires.private.
#
# The PREFIX, PUBLIC-MODULES and PRIVATE-MODULES arguments should be
# specified as for PKG_CHECK_MODULES, with the concatenation of
# PUBLIC-MODULES and PRIVATE-MODULES equaling the LIST-OF-MODULES from
# PKG_CHECK_MODULES. The ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
# arguments are optional, and should also be specified as for
# PKG_CHECK_MODULES. ACTION-IF-FOUND is evaluated if the full
# LIST-OF-MODULES is found; ACTION-IF-NOT-FOUND similarly.
#
# PUBLIC-VARIABLE defaults to AX_PACKAGE_REQUIRES, and PRIVATE-VARIABLE
# defaults to AX_PACKAGE_REQUIRES_PRIVATE. Both variables are AC_SUBST-ed
# by this macro.
#
# For example:
#
# AX_PKG_CHECK_MODULES([GLIB],[glib-2.0 gio-2.0],[gthread-2.0])
# AX_PKG_CHECK_MODULES([DBUS],[],[dbus-glib-1 >= 0.98 dbus-1])
#
# results in the substitutions:
#
# AX_PACKAGE_REQUIRES="glib-2.0 gio-2.0"
# AX_PACKAGE_REQUIRES_PRIVATE="gthread-2.0 dbus-glib-1 >= 0.98 dbus-1"
#
# and can be used with a template pkg-config file (.pc.in) using:
#
# Requires: @AX_PACKAGE_REQUIRES@
# Requires.private: @AX_PACKAGE_REQUIRES_PRIVATE@
#
# LICENSE
#
# Copyright (c) 2014 Philip Withnall <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 4

AC_DEFUN([AX_PKG_CHECK_MODULES],[
m4_define([ax_package_requires],
[m4_default_quoted([$6],[AX_PACKAGE_REQUIRES])])
m4_define([ax_package_requires_private],
[m4_default_quoted([$7],[AX_PACKAGE_REQUIRES_PRIVATE])])
ax_package_requires="$[]ax_package_requires m4_normalize($2)"
ax_package_requires_private="$[]ax_package_requires_private m4_normalize($3)"
PKG_CHECK_MODULES([$1],[$2 $3],[$4],[$5])
# Substitute output.
AC_SUBST(ax_package_requires)
AC_SUBST(ax_package_requires_private)
])dnl AX_PKG_CHECK_MODULES

0 comments on commit 7b2df7f

Please sign in to comment.