blob: 82bb4cdb4734a2414c01469b0d84add45923ed34 [file] [log] [blame]
Patrick Williams03907ee2022-05-01 06:28:52 -05001From 0214d886d0153f7288f81213c47dc50f3b9fde20 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---
Patrick Williams03907ee2022-05-01 06:28:52 -050017 src/gpg-error.m4 | 161 +----------------------------------------------
18 1 file changed, 3 insertions(+), 158 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
Patrick Williams03907ee2022-05-01 06:28:52 -050021index 4b5cd40..c9978d6 100644
Andrew Geisslerd1e89492021-02-12 15:35:20 -060022--- a/src/gpg-error.m4
23+++ b/src/gpg-error.m4
Patrick Williams03907ee2022-05-01 06:28:52 -050024@@ -27,158 +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
Brad Bishop19323692019-04-05 15:28:33 -0400121- else
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700122- # When we cannot determine system libdir-format, use this:
123- gpgrt_libdir=${possible_libdir1}
Brad Bishop19323692019-04-05 15:28:33 -0400124- fi
125- else
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700126- unset GPGRT_CONFIG
127- fi
128-
129- if test -n "$gpgrt_libdir"; then
130- GPGRT_CONFIG="$GPGRT_CONFIG --libdir=$gpgrt_libdir"
131- if $GPGRT_CONFIG gpg-error >/dev/null 2>&1; then
132- GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
133- AC_MSG_NOTICE([Use gpgrt-config with $gpgrt_libdir as gpg-error-config])
134- gpg_error_config_version=`$GPG_ERROR_CONFIG --modversion`
135- else
136- unset GPGRT_CONFIG
137- fi
138- elif test "$GPG_ERROR_CONFIG" != "no"; then
Brad Bishop19323692019-04-05 15:28:33 -0400139- gpg_error_config_version=`$GPG_ERROR_CONFIG --version`
Patrick Williams03907ee2022-05-01 06:28:52 -0500140- unset GPGRT_CONFIG
Brad Bishop19323692019-04-05 15:28:33 -0400141- fi
142- if test "$GPG_ERROR_CONFIG" != "no"; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143- req_major=`echo $min_gpg_error_version | \
144- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
145- req_minor=`echo $min_gpg_error_version | \
146- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147- major=`echo $gpg_error_config_version | \
148- sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
149- minor=`echo $gpg_error_config_version | \
150- sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
151- if test "$major" -gt "$req_major"; then
152- ok=yes
153- else
154- if test "$major" -eq "$req_major"; then
155- if test "$minor" -ge "$req_minor"; then
156- ok=yes
157- fi
158- fi
159- fi
160- fi
Brad Bishop19323692019-04-05 15:28:33 -0400161- AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600162+ min_gpg_error_version=ifelse([$1], ,0.0,$1)
163+ PKG_CHECK_MODULES(GPG_ERROR, [gpg-error >= $min_gpg_error_version], [ok=yes], [ok=no])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164 if test $ok = yes; then
Brad Bishop19323692019-04-05 15:28:33 -0400165- GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG --cflags`
166- GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG --libs`
167- if test -z "$GPGRT_CONFIG"; then
168- GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --mt --cflags 2>/dev/null`
169- GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --mt --libs 2>/dev/null`
170- else
171- GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --variable=mtcflags 2>/dev/null`
172- GPG_ERROR_MT_CFLAGS="$GPG_ERROR_CFLAGS${GPG_ERROR_CFLAGS:+ }$GPG_ERROR_MT_CFLAGS"
173- GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --variable=mtlibs 2>/dev/null`
174- GPG_ERROR_MT_LIBS="$GPG_ERROR_LIBS${GPG_ERROR_LIBS:+ }$GPG_ERROR_MT_LIBS"
175- fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176- AC_MSG_RESULT([yes ($gpg_error_config_version)])
177 ifelse([$2], , :, [$2])
Brad Bishop19323692019-04-05 15:28:33 -0400178 if test -z "$GPGRT_CONFIG"; then
179- gpg_error_config_host=`$GPG_ERROR_CONFIG --host 2>/dev/null || echo none`
180- else
181- gpg_error_config_host=`$GPG_ERROR_CONFIG --variable=host 2>/dev/null || echo none`
182+ gpg_error_config_host=`$PKG_CONFIG --variable=host gpg-error`
183 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184 if test x"$gpg_error_config_host" != xnone ; then
185 if test x"$gpg_error_config_host" != x"$host" ; then
Patrick Williams03907ee2022-05-01 06:28:52 -0500186@@ -194,15 +48,6 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187 fi
188 fi
189 else
190- GPG_ERROR_CFLAGS=""
191- GPG_ERROR_LIBS=""
192- GPG_ERROR_MT_CFLAGS=""
193- GPG_ERROR_MT_LIBS=""
194- AC_MSG_RESULT(no)
195 ifelse([$3], , :, [$3])
196 fi
Brad Bishop19323692019-04-05 15:28:33 -0400197- AC_SUBST(GPG_ERROR_CFLAGS)
198- AC_SUBST(GPG_ERROR_LIBS)
199- AC_SUBST(GPG_ERROR_MT_CFLAGS)
200- AC_SUBST(GPG_ERROR_MT_LIBS)
201 ])