blob: 75c1febc10fea839d7932d2d10eee56b97af419c [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From e10f93167c76c477a7b97286cfac603795bf28d8 Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Thu, 29 Mar 2018 15:12:17 +0800
4Subject: [PATCH] support pkgconfig
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
Andrew Geissler595f6302022-01-24 19:11:47 +00006Upstream-Status: Inappropriate [gnupg upstream will not take this, it has been tried with other components]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008Rebase to 1.28
9
10Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Brad Bishop19323692019-04-05 15:28:33 -040011
12Refactored for 1.33
13Signed-off-by: Armin Kuster <akuster808@gmail.com>
Andrew Geisslerd1e89492021-02-12 15:35:20 -060014Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>
William A. Kennington IIIac69b482021-06-02 12:28:27 -070015
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016---
Andrew Geissler517393d2023-01-13 08:55:19 -060017 src/gpg-error.m4 | 165 +----------------------------------------------
18 1 file changed, 3 insertions(+), 162 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019
Andrew Geisslerd1e89492021-02-12 15:35:20 -060020diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
Andrew Geissler517393d2023-01-13 08:55:19 -060021index a975e53..af4bf2f 100644
Andrew Geisslerd1e89492021-02-12 15:35:20 -060022--- a/src/gpg-error.m4
23+++ b/src/gpg-error.m4
Andrew Geissler517393d2023-01-13 08:55:19 -060024@@ -27,162 +27,12 @@ dnl is added to the gpg_config_script_warn variable.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 dnl
26 AC_DEFUN([AM_PATH_GPG_ERROR],
27 [ AC_REQUIRE([AC_CANONICAL_HOST])
28- gpg_error_config_prefix=""
29- dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
30- dnl since that is consistent with how our three siblings use the directory/
31- dnl package name in --with-$dir_name-prefix=PFX.
32- AC_ARG_WITH(libgpg-error-prefix,
Andrew Geisslerd1e89492021-02-12 15:35:20 -060033- AS_HELP_STRING([--with-libgpg-error-prefix=PFX],
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034- [prefix where GPG Error is installed (optional)]),
35- [gpg_error_config_prefix="$withval"])
Andrew Geisslerd1e89492021-02-12 15:35:20 -060036-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037- dnl Accept --with-gpg-error-prefix and make it work the same as
38- dnl --with-libgpg-error-prefix above, for backwards compatibility,
39- dnl but do not document this old, inconsistently-named option.
40- AC_ARG_WITH(gpg-error-prefix,,
41- [gpg_error_config_prefix="$withval"])
Brad Bishop19323692019-04-05 15:28:33 -040042-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043- if test x"${GPG_ERROR_CONFIG}" = x ; then
44- if test x"${gpg_error_config_prefix}" != x ; then
45- GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
46- else
47- case "${SYSROOT}" in
48- /*)
49- if test -x "${SYSROOT}/bin/gpg-error-config" ; then
50- GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
51- fi
52- ;;
53- '')
54- ;;
55- *)
56- AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
57- ;;
58- esac
59- fi
60- fi
Brad Bishop19323692019-04-05 15:28:33 -040061-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062- AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
Brad Bishop19323692019-04-05 15:28:33 -040063- min_gpg_error_version=ifelse([$1], ,1.33,$1)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064- ok=no
Brad Bishop19323692019-04-05 15:28:33 -040065-
Andrew Geissler595f6302022-01-24 19:11:47 +000066- AC_PATH_PROG(GPGRT_CONFIG, gpgrt-config, no, [$prefix/bin:$PATH])
William A. Kennington IIIac69b482021-06-02 12:28:27 -070067- if test "$GPGRT_CONFIG" != "no"; then
68- # Determine gpgrt_libdir
69- #
70- # Get the prefix of gpgrt-config assuming it's something like:
71- # <PREFIX>/bin/gpgrt-config
72- gpgrt_prefix=${GPGRT_CONFIG%/*/*}
73- possible_libdir1=${gpgrt_prefix}/lib
74- # Determine by using system libdir-format with CC, it's like:
75- # Normal style: /usr/lib
76- # GNU cross style: /usr/<triplet>/lib
77- # Debian style: /usr/lib/<multiarch-name>
78- # Fedora/openSUSE style: /usr/lib, /usr/lib32 or /usr/lib64
79- # It is assumed that CC is specified to the one of host on cross build.
80- if libdir_candidates=$(${CC:-cc} -print-search-dirs | \
Andrew Geissler595f6302022-01-24 19:11:47 +000081- sed -n -e "/^libraries/{s/libraries: =//;s/:/\\
82-/g;p;}"); then
William A. Kennington IIIac69b482021-06-02 12:28:27 -070083- # From the output of -print-search-dirs, select valid pkgconfig dirs.
84- libdir_candidates=$(for dir in $libdir_candidates; do
85- if p=$(cd $dir 2>/dev/null && pwd); then
86- test -d "$p/pkgconfig" && echo $p;
Brad Bishop19323692019-04-05 15:28:33 -040087- fi
William A. Kennington IIIac69b482021-06-02 12:28:27 -070088- done)
Brad Bishop19323692019-04-05 15:28:33 -040089-
William A. Kennington IIIac69b482021-06-02 12:28:27 -070090- for possible_libdir0 in $libdir_candidates; do
91- # possible_libdir0:
92- # Fallback candidate, the one of system-installed (by $CC)
93- # (/usr/<triplet>/lib, /usr/lib/<multiarch-name> or /usr/lib32)
94- # possible_libdir1:
95- # Another candidate, user-locally-installed
96- # (<gpgrt_prefix>/lib)
97- # possible_libdir2
98- # Most preferred
99- # (<gpgrt_prefix>/<triplet>/lib,
100- # <gpgrt_prefix>/lib/<multiarch-name> or <gpgrt_prefix>/lib32)
101- if test "${possible_libdir0##*/}" = "lib"; then
102- possible_prefix0=${possible_libdir0%/lib}
103- possible_prefix0_triplet=${possible_prefix0##*/}
104- if test -z "$possible_prefix0_triplet"; then
105- continue
106- fi
107- possible_libdir2=${gpgrt_prefix}/$possible_prefix0_triplet/lib
108- else
109- possible_prefix0=${possible_libdir0%%/lib*}
110- possible_libdir2=${gpgrt_prefix}${possible_libdir0#$possible_prefix0}
111- fi
112- if test -f ${possible_libdir2}/pkgconfig/gpg-error.pc; then
113- gpgrt_libdir=${possible_libdir2}
114- elif test -f ${possible_libdir1}/pkgconfig/gpg-error.pc; then
115- gpgrt_libdir=${possible_libdir1}
116- elif test -f ${possible_libdir0}/pkgconfig/gpg-error.pc; then
117- gpgrt_libdir=${possible_libdir0}
118- fi
119- if test -n "$gpgrt_libdir"; then break; fi
120- done
Andrew Geissler517393d2023-01-13 08:55:19 -0600121- if test -z "$libdir_candidates"; then
122- # No valid pkgconfig dir in any of the system directories, fallback
123- gpgrt_libdir=${possible_libdir1}
124- fi
Brad Bishop19323692019-04-05 15:28:33 -0400125- else
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700126- # When we cannot determine system libdir-format, use this:
127- gpgrt_libdir=${possible_libdir1}
Brad Bishop19323692019-04-05 15:28:33 -0400128- fi
129- else
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700130- unset GPGRT_CONFIG
131- fi
132-
133- if test -n "$gpgrt_libdir"; then
134- GPGRT_CONFIG="$GPGRT_CONFIG --libdir=$gpgrt_libdir"
135- if $GPGRT_CONFIG gpg-error >/dev/null 2>&1; then
136- GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
137- AC_MSG_NOTICE([Use gpgrt-config with $gpgrt_libdir as gpg-error-config])
138- gpg_error_config_version=`$GPG_ERROR_CONFIG --modversion`
139- else
140- unset GPGRT_CONFIG
141- fi
142- elif test "$GPG_ERROR_CONFIG" != "no"; then
Brad Bishop19323692019-04-05 15:28:33 -0400143- gpg_error_config_version=`$GPG_ERROR_CONFIG --version`
Patrick Williams03907ee2022-05-01 06:28:52 -0500144- unset GPGRT_CONFIG
Brad Bishop19323692019-04-05 15:28:33 -0400145- fi
146- if test "$GPG_ERROR_CONFIG" != "no"; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147- req_major=`echo $min_gpg_error_version | \
148- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
149- req_minor=`echo $min_gpg_error_version | \
150- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151- major=`echo $gpg_error_config_version | \
152- sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
153- minor=`echo $gpg_error_config_version | \
154- sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
155- if test "$major" -gt "$req_major"; then
156- ok=yes
157- else
158- if test "$major" -eq "$req_major"; then
159- if test "$minor" -ge "$req_minor"; then
160- ok=yes
161- fi
162- fi
163- fi
164- fi
Brad Bishop19323692019-04-05 15:28:33 -0400165- AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600166+ min_gpg_error_version=ifelse([$1], ,0.0,$1)
167+ PKG_CHECK_MODULES(GPG_ERROR, [gpg-error >= $min_gpg_error_version], [ok=yes], [ok=no])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 if test $ok = yes; then
Brad Bishop19323692019-04-05 15:28:33 -0400169- GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG --cflags`
170- GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG --libs`
171- if test -z "$GPGRT_CONFIG"; then
172- GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --mt --cflags 2>/dev/null`
173- GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --mt --libs 2>/dev/null`
174- else
175- GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --variable=mtcflags 2>/dev/null`
176- GPG_ERROR_MT_CFLAGS="$GPG_ERROR_CFLAGS${GPG_ERROR_CFLAGS:+ }$GPG_ERROR_MT_CFLAGS"
177- GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --variable=mtlibs 2>/dev/null`
178- GPG_ERROR_MT_LIBS="$GPG_ERROR_LIBS${GPG_ERROR_LIBS:+ }$GPG_ERROR_MT_LIBS"
179- fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180- AC_MSG_RESULT([yes ($gpg_error_config_version)])
181 ifelse([$2], , :, [$2])
Brad Bishop19323692019-04-05 15:28:33 -0400182 if test -z "$GPGRT_CONFIG"; then
183- gpg_error_config_host=`$GPG_ERROR_CONFIG --host 2>/dev/null || echo none`
184- else
185- gpg_error_config_host=`$GPG_ERROR_CONFIG --variable=host 2>/dev/null || echo none`
186+ gpg_error_config_host=`$PKG_CONFIG --variable=host gpg-error`
187 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188 if test x"$gpg_error_config_host" != xnone ; then
189 if test x"$gpg_error_config_host" != x"$host" ; then
Andrew Geissler517393d2023-01-13 08:55:19 -0600190@@ -198,15 +48,6 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191 fi
192 fi
193 else
194- GPG_ERROR_CFLAGS=""
195- GPG_ERROR_LIBS=""
196- GPG_ERROR_MT_CFLAGS=""
197- GPG_ERROR_MT_LIBS=""
198- AC_MSG_RESULT(no)
199 ifelse([$3], , :, [$3])
200 fi
Brad Bishop19323692019-04-05 15:28:33 -0400201- AC_SUBST(GPG_ERROR_CFLAGS)
202- AC_SUBST(GPG_ERROR_LIBS)
203- AC_SUBST(GPG_ERROR_MT_CFLAGS)
204- AC_SUBST(GPG_ERROR_MT_LIBS)
205 ])