]>
Commit | Line | Data |
---|---|---|
4b0e5c1b | 1 | From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 |
5673f127 JB |
2 | From: Kevin Buettner <kevinb@redhat.com> |
3 | Date: Wed, 22 Feb 2023 22:30:40 -0700 | |
4b0e5c1b AM |
4 | Subject: gdb-6.6-buildid-locate-rpm.patch |
5 | ||
4b0e5c1b | 6 | ;;=push+jan |
4b0e5c1b AM |
7 | |
8 | diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 | |
4b0e5c1b AM |
9 | --- a/gdb/aclocal.m4 |
10 | +++ b/gdb/aclocal.m4 | |
ed003b1c | 11 | @@ -11,7 +11,223 @@ |
321e94d6 BS |
12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
13 | # PARTICULAR PURPOSE. | |
14 | ||
15 | +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- | |
16 | +# serial 1 (pkg-config-0.24) | |
174fe25c | 17 | +# |
321e94d6 BS |
18 | +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. |
19 | +# | |
20 | +# This program is free software; you can redistribute it and/or modify | |
21 | +# it under the terms of the GNU General Public License as published by | |
22 | +# the Free Software Foundation; either version 2 of the License, or | |
23 | +# (at your option) any later version. | |
24 | +# | |
25 | +# This program is distributed in the hope that it will be useful, but | |
26 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
28 | +# General Public License for more details. | |
29 | +# | |
30 | +# You should have received a copy of the GNU General Public License | |
31 | +# along with this program; if not, write to the Free Software | |
32 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
33 | +# | |
34 | +# As a special exception to the GNU General Public License, if you | |
35 | +# distribute this file as part of a program that contains a | |
36 | +# configuration script generated by Autoconf, you may include it under | |
37 | +# the same distribution terms that you use for the rest of that program. | |
3a58abaf | 38 | + |
321e94d6 BS |
39 | +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) |
40 | +# ---------------------------------- | |
41 | +AC_DEFUN([PKG_PROG_PKG_CONFIG], | |
42 | +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) | |
43 | +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) | |
44 | +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) | |
45 | +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) | |
46 | +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) | |
47 | +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) | |
3a58abaf | 48 | + |
321e94d6 BS |
49 | +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then |
50 | + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) | |
51 | +fi | |
52 | +if test -n "$PKG_CONFIG"; then | |
53 | + _pkg_min_version=m4_default([$1], [0.9.0]) | |
54 | + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) | |
55 | + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then | |
56 | + AC_MSG_RESULT([yes]) | |
57 | + else | |
58 | + AC_MSG_RESULT([no]) | |
59 | + PKG_CONFIG="" | |
60 | + fi | |
61 | +fi[]dnl | |
62 | +])# PKG_PROG_PKG_CONFIG | |
3a58abaf | 63 | + |
321e94d6 BS |
64 | +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
65 | +# | |
66 | +# Check to see whether a particular set of modules exists. Similar | |
67 | +# to PKG_CHECK_MODULES(), but does not set variables or print errors. | |
68 | +# | |
69 | +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | |
70 | +# only at the first occurence in configure.ac, so if the first place | |
71 | +# it's called might be skipped (such as if it is within an "if", you | |
72 | +# have to call PKG_CHECK_EXISTS manually | |
73 | +# -------------------------------------------------------------- | |
74 | +AC_DEFUN([PKG_CHECK_EXISTS], | |
75 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | |
76 | +if test -n "$PKG_CONFIG" && \ | |
77 | + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then | |
78 | + m4_default([$2], [:]) | |
79 | +m4_ifvaln([$3], [else | |
80 | + $3])dnl | |
81 | +fi]) | |
3a58abaf | 82 | + |
321e94d6 BS |
83 | +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) |
84 | +# --------------------------------------------- | |
85 | +m4_define([_PKG_CONFIG], | |
86 | +[if test -n "$$1"; then | |
87 | + pkg_cv_[]$1="$$1" | |
88 | + elif test -n "$PKG_CONFIG"; then | |
89 | + PKG_CHECK_EXISTS([$3], | |
90 | + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` | |
91 | + test "x$?" != "x0" && pkg_failed=yes ], | |
92 | + [pkg_failed=yes]) | |
93 | + else | |
94 | + pkg_failed=untried | |
95 | +fi[]dnl | |
96 | +])# _PKG_CONFIG | |
3a58abaf | 97 | + |
321e94d6 BS |
98 | +# _PKG_SHORT_ERRORS_SUPPORTED |
99 | +# ----------------------------- | |
100 | +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], | |
101 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | |
102 | +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then | |
103 | + _pkg_short_errors_supported=yes | |
104 | +else | |
105 | + _pkg_short_errors_supported=no | |
106 | +fi[]dnl | |
107 | +])# _PKG_SHORT_ERRORS_SUPPORTED | |
3a58abaf | 108 | + |
3a58abaf | 109 | + |
321e94d6 BS |
110 | +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], |
111 | +# [ACTION-IF-NOT-FOUND]) | |
112 | +# | |
113 | +# | |
114 | +# Note that if there is a possibility the first call to | |
115 | +# PKG_CHECK_MODULES might not happen, you should be sure to include an | |
116 | +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac | |
117 | +# | |
118 | +# | |
119 | +# -------------------------------------------------------------- | |
120 | +AC_DEFUN([PKG_CHECK_MODULES], | |
121 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | |
122 | +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl | |
123 | +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl | |
3a58abaf | 124 | + |
321e94d6 BS |
125 | +pkg_failed=no |
126 | +AC_MSG_CHECKING([for $1]) | |
3a58abaf | 127 | + |
321e94d6 BS |
128 | +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) |
129 | +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) | |
e5178960 | 130 | + |
321e94d6 BS |
131 | +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS |
132 | +and $1[]_LIBS to avoid the need to call pkg-config. | |
133 | +See the pkg-config man page for more details.]) | |
e5178960 | 134 | + |
321e94d6 | 135 | +if test $pkg_failed = yes; then |
174fe25c | 136 | + AC_MSG_RESULT([no]) |
321e94d6 BS |
137 | + _PKG_SHORT_ERRORS_SUPPORTED |
138 | + if test $_pkg_short_errors_supported = yes; then | |
139 | + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` | |
174fe25c | 140 | + else |
321e94d6 BS |
141 | + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` |
142 | + fi | |
143 | + # Put the nasty error message in config.log where it belongs | |
144 | + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD | |
3a58abaf | 145 | + |
321e94d6 BS |
146 | + m4_default([$4], [AC_MSG_ERROR( |
147 | +[Package requirements ($2) were not met: | |
3a58abaf | 148 | + |
321e94d6 | 149 | +$$1_PKG_ERRORS |
3a58abaf | 150 | + |
321e94d6 BS |
151 | +Consider adjusting the PKG_CONFIG_PATH environment variable if you |
152 | +installed software in a non-standard prefix. | |
3a58abaf | 153 | + |
321e94d6 BS |
154 | +_PKG_TEXT])[]dnl |
155 | + ]) | |
156 | +elif test $pkg_failed = untried; then | |
174fe25c | 157 | + AC_MSG_RESULT([no]) |
321e94d6 BS |
158 | + m4_default([$4], [AC_MSG_FAILURE( |
159 | +[The pkg-config script could not be found or is too old. Make sure it | |
160 | +is in your PATH or set the PKG_CONFIG environment variable to the full | |
161 | +path to pkg-config. | |
3a58abaf | 162 | + |
321e94d6 | 163 | +_PKG_TEXT |
3a58abaf | 164 | + |
321e94d6 BS |
165 | +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl |
166 | + ]) | |
167 | +else | |
168 | + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS | |
169 | + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS | |
170 | + AC_MSG_RESULT([yes]) | |
171 | + $3 | |
172 | +fi[]dnl | |
173 | +])# PKG_CHECK_MODULES | |
3a58abaf | 174 | + |
3a58abaf | 175 | + |
321e94d6 BS |
176 | +# PKG_INSTALLDIR(DIRECTORY) |
177 | +# ------------------------- | |
178 | +# Substitutes the variable pkgconfigdir as the location where a module | |
179 | +# should install pkg-config .pc files. By default the directory is | |
180 | +# $libdir/pkgconfig, but the default can be changed by passing | |
181 | +# DIRECTORY. The user can override through the --with-pkgconfigdir | |
182 | +# parameter. | |
183 | +AC_DEFUN([PKG_INSTALLDIR], | |
184 | +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) | |
185 | +m4_pushdef([pkg_description], | |
186 | + [pkg-config installation directory @<:@]pkg_default[@:>@]) | |
187 | +AC_ARG_WITH([pkgconfigdir], | |
188 | + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, | |
189 | + [with_pkgconfigdir=]pkg_default) | |
190 | +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) | |
191 | +m4_popdef([pkg_default]) | |
192 | +m4_popdef([pkg_description]) | |
193 | +]) dnl PKG_INSTALLDIR | |
194 | + | |
195 | + | |
196 | +# PKG_NOARCH_INSTALLDIR(DIRECTORY) | |
197 | +# ------------------------- | |
198 | +# Substitutes the variable noarch_pkgconfigdir as the location where a | |
199 | +# module should install arch-independent pkg-config .pc files. By | |
200 | +# default the directory is $datadir/pkgconfig, but the default can be | |
201 | +# changed by passing DIRECTORY. The user can override through the | |
202 | +# --with-noarch-pkgconfigdir parameter. | |
203 | +AC_DEFUN([PKG_NOARCH_INSTALLDIR], | |
204 | +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) | |
205 | +m4_pushdef([pkg_description], | |
206 | + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) | |
207 | +AC_ARG_WITH([noarch-pkgconfigdir], | |
208 | + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, | |
209 | + [with_noarch_pkgconfigdir=]pkg_default) | |
210 | +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) | |
211 | +m4_popdef([pkg_default]) | |
212 | +m4_popdef([pkg_description]) | |
213 | +]) dnl PKG_NOARCH_INSTALLDIR | |
214 | + | |
215 | + | |
216 | +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, | |
217 | +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) | |
218 | +# ------------------------------------------- | |
219 | +# Retrieves the value of the pkg-config variable for the given module. | |
220 | +AC_DEFUN([PKG_CHECK_VAR], | |
221 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | |
222 | +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl | |
3a58abaf | 223 | + |
321e94d6 BS |
224 | +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) |
225 | +AS_VAR_COPY([$1], [pkg_cv_][$1]) | |
3a58abaf | 226 | + |
321e94d6 BS |
227 | +AS_VAR_IF([$1], [""], [$5], [$4])dnl |
228 | +])# PKG_CHECK_VAR | |
ed003b1c AM |
229 | + |
230 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) | |
3a58abaf | 231 | + |
321e94d6 BS |
232 | # AM_AUX_DIR_EXPAND -*- Autoconf -*- |
233 | ||
ed003b1c | 234 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. |
5673f127 JB |
235 | diff --git a/gdb/build-id.c b/gdb/build-id.c |
236 | --- a/gdb/build-id.c | |
237 | +++ b/gdb/build-id.c | |
238 | @@ -780,10 +780,10 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor) | |
239 | static rpmts (*rpmtsCreate_p) (void); | |
240 | extern rpmts rpmtsFree(rpmts ts); | |
241 | static rpmts (*rpmtsFree_p) (rpmts ts); | |
242 | - extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, | |
243 | + extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag, | |
244 | const void * keyp, size_t keylen); | |
245 | static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts, | |
246 | - rpmTag rpmtag, | |
247 | + rpmDbiTagVal rpmtag, | |
248 | const void *keyp, | |
249 | size_t keylen); | |
250 | #else /* !DLOPEN_LIBRPM */ | |
251 | @@ -838,7 +838,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor) | |
252 | && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator")) | |
253 | && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate")) | |
254 | && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree")) | |
255 | - && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator")))) | |
256 | + && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmDbiTagVal rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator")))) | |
257 | { | |
258 | warning (_("Opened library \"%s\" is incompatible (%s), " | |
259 | "missing debuginfos notifications will not be displayed"), | |
260 | @@ -926,7 +926,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor) | |
261 | ||
262 | /* RPMDBI_PACKAGES requires keylen == sizeof (int). */ | |
263 | /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */ | |
264 | - mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0); | |
265 | + mi_debuginfo = rpmtsInitIterator_p (ts, (rpmDbiTagVal) RPMDBI_LABEL, debuginfo, 0); | |
266 | xfree (debuginfo); | |
267 | if (mi_debuginfo) | |
268 | { | |
4b0e5c1b | 269 | diff --git a/gdb/config.in b/gdb/config.in |
4b0e5c1b AM |
270 | --- a/gdb/config.in |
271 | +++ b/gdb/config.in | |
5673f127 | 272 | @@ -42,6 +42,9 @@ |
174fe25c JP |
273 | /* Handle .ctf type-info sections */ |
274 | #undef ENABLE_LIBCTF | |
4b0e5c1b AM |
275 | |
276 | +/* librpm version specific library name to dlopen. */ | |
277 | +#undef DLOPEN_LIBRPM | |
321e94d6 | 278 | + |
4b0e5c1b AM |
279 | /* Define to 1 if translation of program messages to the user's native |
280 | language is requested. */ | |
281 | #undef ENABLE_NLS | |
5673f127 JB |
282 | @@ -265,6 +268,9 @@ |
283 | /* Define to 1 if you have the `m' library (-lm). */ | |
284 | #undef HAVE_LIBM | |
321e94d6 | 285 | |
4b0e5c1b AM |
286 | +/* Define if librpm library is being used. */ |
287 | +#undef HAVE_LIBRPM | |
288 | + | |
289 | /* Define to 1 if you have the <libunwind-ia64.h> header file. */ | |
290 | #undef HAVE_LIBUNWIND_IA64_H | |
321e94d6 | 291 | |
4b0e5c1b | 292 | diff --git a/gdb/configure b/gdb/configure |
4b0e5c1b AM |
293 | --- a/gdb/configure |
294 | +++ b/gdb/configure | |
5673f127 | 295 | @@ -778,6 +778,11 @@ AMD_DBGAPI_CFLAGS |
0e7ddf04 JB |
296 | ENABLE_BFD_64_BIT_FALSE |
297 | ENABLE_BFD_64_BIT_TRUE | |
4b0e5c1b AM |
298 | subdirs |
299 | +RPM_LIBS | |
300 | +RPM_CFLAGS | |
301 | +PKG_CONFIG_LIBDIR | |
302 | +PKG_CONFIG_PATH | |
303 | +PKG_CONFIG | |
304 | GDB_DATADIR | |
305 | DEBUGDIR | |
306 | MAKEINFO_EXTRA_FLAGS | |
5673f127 | 307 | @@ -911,6 +916,7 @@ with_gdb_datadir |
4b0e5c1b AM |
308 | with_relocated_sources |
309 | with_auto_load_dir | |
310 | with_auto_load_safe_path | |
311 | +with_rpm | |
312 | enable_targets | |
313 | enable_64_bit_bfd | |
5673f127 JB |
314 | with_amd_dbgapi |
315 | @@ -988,6 +994,8 @@ AMD_DBGAPI_CFLAGS | |
316 | AMD_DBGAPI_LIBS | |
174fe25c JP |
317 | DEBUGINFOD_CFLAGS |
318 | DEBUGINFOD_LIBS | |
4b0e5c1b AM |
319 | +RPM_CFLAGS |
320 | +RPM_LIBS | |
321 | YACC | |
322 | YFLAGS | |
5673f127 JB |
323 | ZSTD_CFLAGS |
324 | @@ -1679,6 +1687,8 @@ Optional Packages: | |
325 | --with-amd-dbgapi support for the amd-dbgapi target (yes / no / auto) | |
174fe25c JP |
326 | --with-debuginfod Enable debuginfo lookups with debuginfod |
327 | (auto/yes/no) | |
4b0e5c1b AM |
328 | + --with-rpm query rpm database for missing debuginfos (yes/no, |
329 | + def. auto=librpm.so) | |
330 | --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets | |
331 | --with-curses use the curses library instead of the termcap | |
332 | library | |
5673f127 | 333 | @@ -1759,6 +1769,8 @@ Some influential environment variables: |
174fe25c JP |
334 | C compiler flags for DEBUGINFOD, overriding pkg-config |
335 | DEBUGINFOD_LIBS | |
336 | linker flags for DEBUGINFOD, overriding pkg-config | |
4b0e5c1b AM |
337 | + RPM_CFLAGS C compiler flags for RPM, overriding pkg-config |
338 | + RPM_LIBS linker flags for RPM, overriding pkg-config | |
ed003b1c AM |
339 | YACC The `Yet Another Compiler Compiler' implementation to use. |
340 | Defaults to the first program found out of: `bison -y', `byacc', | |
341 | `yacc'. | |
5673f127 | 342 | @@ -18039,6 +18051,495 @@ _ACEOF |
4b0e5c1b AM |
343 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 |
344 | $as_echo "$with_auto_load_safe_path" >&6; } | |
321e94d6 BS |
345 | |
346 | +# Integration with rpm library to support missing debuginfo suggestions. | |
347 | +# --without-rpm: Disable any rpm support. | |
348 | +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. | |
349 | +# Even with runtime missing `libname.so' GDB will still other run correctly. | |
350 | +# Missing `libname.so' during ./configure will abort the configuration. | |
351 | +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific | |
352 | +# minor version first such as `librpm-4.6.so' as minor version differences | |
353 | +# mean API+ABI incompatibility. If the specific match versioned library name | |
354 | +# could not be found still open dynamically at least `librpm.so'. | |
355 | +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try | |
356 | +# to find librpm for compilation-time linking by pkg-config. GDB binary will | |
357 | +# be probably linked with the version specific library (as `librpm-4.6.so'). | |
358 | +# Failure to find librpm by pkg-config will abort the configuration. | |
359 | +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config | |
360 | +# cannot find librpm use to the rpmless compilation (like `--without-rpm'). | |
361 | + | |
321e94d6 | 362 | + |
4b0e5c1b AM |
363 | +# Check whether --with-rpm was given. |
364 | +if test "${with_rpm+set}" = set; then : | |
365 | + withval=$with_rpm; | |
366 | +else | |
367 | + with_rpm="auto" | |
368 | +fi | |
369 | + | |
370 | + | |
371 | + | |
372 | + | |
321e94d6 BS |
373 | +if test "x$with_rpm" != "xno"; then |
374 | + if test "x$with_rpm" = "xyes"; then | |
375 | + LIBRPM="librpm.so" | |
376 | + RPM_REQUIRE=true | |
377 | + DLOPEN_REQUIRE=false | |
378 | + elif test "x$with_rpm" = "xauto"; then | |
379 | + LIBRPM="librpm.so" | |
380 | + RPM_REQUIRE=false | |
381 | + DLOPEN_REQUIRE=false | |
382 | + else | |
383 | + LIBRPM="$with_rpm" | |
384 | + RPM_REQUIRE=true | |
385 | + DLOPEN_REQUIRE=true | |
386 | + fi | |
387 | + LIBRPM_STRING='"'"$LIBRPM"'"' | |
388 | + | |
4b0e5c1b AM |
389 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5 |
390 | +$as_echo_n "checking specific librpm version... " >&6; } | |
321e94d6 BS |
391 | + HAVE_DLOPEN_LIBRPM=false |
392 | + save_LIBS="$LIBS" | |
393 | + LIBS="$LIBS -ldl" | |
4b0e5c1b AM |
394 | + if test "$cross_compiling" = yes; then : |
395 | + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
396 | +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
397 | +as_fn_error "cannot run test program while cross compiling | |
398 | +See \`config.log' for more details." "$LINENO" 5; } | |
399 | +else | |
400 | + cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
401 | +/* end confdefs.h. */ | |
402 | + | |
321e94d6 BS |
403 | +#include <rpm/rpmlib.h> |
404 | +#include <dlfcn.h> | |
405 | +#include <errno.h> | |
5673f127 | 406 | +#include <string.h> |
4b0e5c1b AM |
407 | + |
408 | +int | |
409 | +main () | |
410 | +{ | |
411 | + | |
321e94d6 | 412 | + void *h; |
3a58abaf AM |
413 | + const char *const *rpmverp; |
414 | + FILE *f; | |
415 | + | |
416 | + f = fopen ("conftest.out", "w"); | |
417 | + if (!f) | |
418 | + { | |
419 | + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", | |
420 | + strerror (errno)); | |
421 | + return 1; | |
422 | + } | |
423 | + h = dlopen ($LIBRPM_STRING, RTLD_LAZY); | |
424 | + if (!h) | |
425 | + { | |
426 | + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); | |
427 | + return 1; | |
428 | + } | |
429 | + rpmverp = dlsym (h, "RPMVERSION"); | |
430 | + if (!rpmverp) | |
431 | + { | |
432 | + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); | |
433 | + return 1; | |
434 | + } | |
435 | + fprintf (stderr, "RPMVERSION is: \""); | |
436 | + fprintf (stderr, "%s\"\n", *rpmverp); | |
437 | + | |
438 | + /* Try to find the specific librpm version only for "librpm.so" as we do | |
439 | + not know how to assemble the version string otherwise. */ | |
440 | + | |
441 | + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) | |
442 | + { | |
443 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
444 | + return 0; | |
445 | + } | |
446 | + else | |
447 | + { | |
448 | + char *h2_name; | |
449 | + void *h2; | |
450 | + int major, minor; | |
451 | + | |
452 | + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) | |
453 | + { | |
454 | + fprintf (stderr, "Unable to parse RPMVERSION.\n"); | |
455 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
456 | + return 0; | |
457 | + } | |
458 | + /* Avoid the square brackets by malloc. */ | |
459 | + h2_name = malloc (64); | |
460 | + sprintf (h2_name, "librpm-%d.%d.so", major, minor); | |
461 | + h2 = dlopen (h2_name, RTLD_LAZY); | |
462 | + if (!h2) | |
463 | + { | |
464 | + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); | |
465 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
466 | + return 0; | |
467 | + } | |
468 | + if (h2 != h) | |
469 | + { | |
470 | + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", | |
471 | + $LIBRPM_STRING, h2_name); | |
472 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
473 | + return 0; | |
474 | + } | |
475 | + /* Found the valid .so name with a specific version. */ | |
476 | + fprintf (f, "%s\n", h2_name); | |
477 | + return 0; | |
478 | + } | |
4b0e5c1b AM |
479 | + |
480 | + ; | |
481 | + return 0; | |
482 | +} | |
483 | +_ACEOF | |
484 | +if ac_fn_c_try_run "$LINENO"; then : | |
485 | + | |
3a58abaf AM |
486 | + DLOPEN_LIBRPM="`cat conftest.out`" |
487 | + if test "x$DLOPEN_LIBRPM" != "x"; then | |
488 | + HAVE_DLOPEN_LIBRPM=true | |
4b0e5c1b AM |
489 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5 |
490 | +$as_echo "$DLOPEN_LIBRPM" >&6; } | |
3a58abaf | 491 | + fi |
4b0e5c1b AM |
492 | + |
493 | +fi | |
494 | +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ | |
495 | + conftest.$ac_objext conftest.beam conftest.$ac_ext | |
496 | +fi | |
497 | + | |
3a58abaf AM |
498 | + rm -f conftest.out |
499 | + | |
4b0e5c1b AM |
500 | + |
501 | + | |
502 | + if $HAVE_DLOPEN_LIBRPM; then | |
503 | + | |
504 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 | |
505 | +$as_echo_n "checking rpm library API compatibility... " >&6; } | |
3a58abaf AM |
506 | + # The compilation requires -Werror to verify anything. |
507 | + save_CFLAGS="$CFLAGS" | |
508 | + CFLAGS="$CFLAGS -Werror" | |
4b0e5c1b AM |
509 | + cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
510 | +/* end confdefs.h. */ | |
511 | + | |
51a5ef0f | 512 | +/* Duplicate here the declarations to verify they match "elfread.c". */ |
3a58abaf AM |
513 | +#include <rpm/rpmlib.h> |
514 | +#include <rpm/rpmts.h> | |
515 | +#include <rpm/rpmdb.h> | |
516 | +#include <rpm/header.h> | |
517 | +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); | |
518 | +extern int rpmReadConfigFiles(const char * file, const char * target); | |
519 | +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); | |
520 | +extern Header rpmdbNextIterator(rpmdbMatchIterator mi); | |
521 | +extern rpmts rpmtsCreate(void); | |
522 | +extern rpmts rpmtsFree(rpmts ts); | |
5673f127 | 523 | +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag, |
3a58abaf | 524 | + const void * keyp, size_t keylen); |
4b0e5c1b AM |
525 | + |
526 | +int | |
527 | +main () | |
528 | +{ | |
529 | + | |
530 | + ; | |
531 | + return 0; | |
532 | +} | |
533 | +_ACEOF | |
534 | +if ac_fn_c_try_compile "$LINENO"; then : | |
535 | + | |
3a58abaf | 536 | + LIBRPM_COMPAT=true |
4b0e5c1b AM |
537 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 |
538 | +$as_echo "yes" >&6; } | |
539 | + | |
540 | +else | |
541 | + | |
3a58abaf | 542 | + LIBRPM_COMPAT=false |
4b0e5c1b AM |
543 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
544 | +$as_echo "no" >&6; } | |
545 | + | |
546 | +fi | |
547 | +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |
3a58abaf AM |
548 | + CFLAGS="$save_CFLAGS" |
549 | + | |
550 | + if ! $LIBRPM_COMPAT; then | |
551 | + HAVE_DLOPEN_LIBRPM=false | |
552 | + fi | |
553 | + fi | |
554 | + | |
555 | + if $HAVE_DLOPEN_LIBRPM; then | |
556 | + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' | |
3a58abaf | 557 | + |
4b0e5c1b AM |
558 | +cat >>confdefs.h <<_ACEOF |
559 | +#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING | |
560 | +_ACEOF | |
3a58abaf | 561 | + |
3a58abaf | 562 | + |
4b0e5c1b | 563 | +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h |
3a58abaf | 564 | + |
4b0e5c1b AM |
565 | + else |
566 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
567 | +$as_echo "no" >&6; } | |
568 | + LIBS="$save_LIBS" | |
569 | + if $DLOPEN_REQUIRE; then | |
570 | + as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5 | |
571 | + fi | |
28b292e9 | 572 | + |
3a58abaf AM |
573 | + |
574 | + | |
575 | + | |
3a58abaf | 576 | + |
3a58abaf | 577 | + |
3a58abaf | 578 | + |
4b0e5c1b AM |
579 | +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then |
580 | + if test -n "$ac_tool_prefix"; then | |
581 | + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. | |
582 | +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 | |
583 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 | |
584 | +$as_echo_n "checking for $ac_word... " >&6; } | |
585 | +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : | |
586 | + $as_echo_n "(cached) " >&6 | |
587 | +else | |
588 | + case $PKG_CONFIG in | |
589 | + [\\/]* | ?:[\\/]*) | |
590 | + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. | |
591 | + ;; | |
592 | + *) | |
593 | + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR | |
594 | +for as_dir in $PATH | |
595 | +do | |
596 | + IFS=$as_save_IFS | |
597 | + test -z "$as_dir" && as_dir=. | |
598 | + for ac_exec_ext in '' $ac_executable_extensions; do | |
599 | + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then | |
600 | + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" | |
601 | + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 | |
602 | + break 2 | |
603 | + fi | |
604 | +done | |
605 | + done | |
606 | +IFS=$as_save_IFS | |
3a58abaf | 607 | + |
4b0e5c1b AM |
608 | + ;; |
609 | +esac | |
610 | +fi | |
611 | +PKG_CONFIG=$ac_cv_path_PKG_CONFIG | |
612 | +if test -n "$PKG_CONFIG"; then | |
613 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 | |
614 | +$as_echo "$PKG_CONFIG" >&6; } | |
615 | +else | |
616 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
617 | +$as_echo "no" >&6; } | |
618 | +fi | |
3a58abaf | 619 | + |
3a58abaf | 620 | + |
4b0e5c1b AM |
621 | +fi |
622 | +if test -z "$ac_cv_path_PKG_CONFIG"; then | |
623 | + ac_pt_PKG_CONFIG=$PKG_CONFIG | |
624 | + # Extract the first word of "pkg-config", so it can be a program name with args. | |
625 | +set dummy pkg-config; ac_word=$2 | |
626 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 | |
627 | +$as_echo_n "checking for $ac_word... " >&6; } | |
628 | +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : | |
629 | + $as_echo_n "(cached) " >&6 | |
630 | +else | |
631 | + case $ac_pt_PKG_CONFIG in | |
632 | + [\\/]* | ?:[\\/]*) | |
633 | + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. | |
634 | + ;; | |
635 | + *) | |
636 | + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR | |
637 | +for as_dir in $PATH | |
638 | +do | |
639 | + IFS=$as_save_IFS | |
640 | + test -z "$as_dir" && as_dir=. | |
641 | + for ac_exec_ext in '' $ac_executable_extensions; do | |
642 | + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then | |
643 | + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" | |
644 | + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 | |
645 | + break 2 | |
646 | + fi | |
647 | +done | |
648 | + done | |
649 | +IFS=$as_save_IFS | |
3a58abaf | 650 | + |
4b0e5c1b AM |
651 | + ;; |
652 | +esac | |
653 | +fi | |
654 | +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG | |
655 | +if test -n "$ac_pt_PKG_CONFIG"; then | |
656 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 | |
657 | +$as_echo "$ac_pt_PKG_CONFIG" >&6; } | |
658 | +else | |
659 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
660 | +$as_echo "no" >&6; } | |
661 | +fi | |
3a58abaf | 662 | + |
4b0e5c1b AM |
663 | + if test "x$ac_pt_PKG_CONFIG" = x; then |
664 | + PKG_CONFIG="" | |
665 | + else | |
666 | + case $cross_compiling:$ac_tool_warned in | |
667 | +yes:) | |
668 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 | |
669 | +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} | |
670 | +ac_tool_warned=yes ;; | |
671 | +esac | |
672 | + PKG_CONFIG=$ac_pt_PKG_CONFIG | |
673 | + fi | |
674 | +else | |
675 | + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" | |
676 | +fi | |
3a58abaf | 677 | + |
4b0e5c1b AM |
678 | +fi |
679 | +if test -n "$PKG_CONFIG"; then | |
680 | + _pkg_min_version=0.9.0 | |
681 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 | |
682 | +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } | |
683 | + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then | |
684 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
685 | +$as_echo "yes" >&6; } | |
686 | + else | |
687 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
688 | +$as_echo "no" >&6; } | |
689 | + PKG_CONFIG="" | |
690 | + fi | |
691 | +fi | |
692 | + | |
693 | +pkg_failed=no | |
694 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5 | |
695 | +$as_echo_n "checking for RPM... " >&6; } | |
696 | + | |
697 | +if test -n "$RPM_CFLAGS"; then | |
698 | + pkg_cv_RPM_CFLAGS="$RPM_CFLAGS" | |
699 | + elif test -n "$PKG_CONFIG"; then | |
700 | + if test -n "$PKG_CONFIG" && \ | |
701 | + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 | |
702 | + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 | |
703 | + ac_status=$? | |
704 | + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
705 | + test $ac_status = 0; }; then | |
706 | + pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null` | |
707 | + test "x$?" != "x0" && pkg_failed=yes | |
708 | +else | |
709 | + pkg_failed=yes | |
710 | +fi | |
711 | + else | |
712 | + pkg_failed=untried | |
713 | +fi | |
714 | +if test -n "$RPM_LIBS"; then | |
715 | + pkg_cv_RPM_LIBS="$RPM_LIBS" | |
716 | + elif test -n "$PKG_CONFIG"; then | |
717 | + if test -n "$PKG_CONFIG" && \ | |
718 | + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 | |
719 | + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 | |
720 | + ac_status=$? | |
721 | + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
722 | + test $ac_status = 0; }; then | |
723 | + pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null` | |
724 | + test "x$?" != "x0" && pkg_failed=yes | |
725 | +else | |
726 | + pkg_failed=yes | |
727 | +fi | |
728 | + else | |
729 | + pkg_failed=untried | |
730 | +fi | |
3a58abaf | 731 | + |
3a58abaf | 732 | + |
3a58abaf | 733 | + |
4b0e5c1b | 734 | +if test $pkg_failed = yes; then |
174fe25c | 735 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
4b0e5c1b | 736 | +$as_echo "no" >&6; } |
3a58abaf | 737 | + |
4b0e5c1b AM |
738 | +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then |
739 | + _pkg_short_errors_supported=yes | |
740 | +else | |
741 | + _pkg_short_errors_supported=no | |
742 | +fi | |
743 | + if test $_pkg_short_errors_supported = yes; then | |
744 | + RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1` | |
745 | + else | |
746 | + RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1` | |
747 | + fi | |
748 | + # Put the nasty error message in config.log where it belongs | |
749 | + echo "$RPM_PKG_ERRORS" >&5 | |
3a58abaf | 750 | + |
4b0e5c1b AM |
751 | + HAVE_LIBRPM=false |
752 | +elif test $pkg_failed = untried; then | |
174fe25c | 753 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
4b0e5c1b AM |
754 | +$as_echo "no" >&6; } |
755 | + HAVE_LIBRPM=false | |
756 | +else | |
757 | + RPM_CFLAGS=$pkg_cv_RPM_CFLAGS | |
758 | + RPM_LIBS=$pkg_cv_RPM_LIBS | |
759 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
760 | +$as_echo "yes" >&6; } | |
761 | + HAVE_LIBRPM=true | |
762 | +fi | |
3a58abaf | 763 | + |
4b0e5c1b | 764 | + if $HAVE_LIBRPM; then |
6ed6bacf | 765 | + |
4b0e5c1b AM |
766 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 |
767 | +$as_echo_n "checking rpm library API compatibility... " >&6; } | |
768 | + # The compilation requires -Werror to verify anything. | |
769 | + save_CFLAGS="$CFLAGS" | |
770 | + CFLAGS="$CFLAGS -Werror" | |
771 | + cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
772 | +/* end confdefs.h. */ | |
3a58abaf | 773 | + |
4b0e5c1b AM |
774 | +/* Duplicate here the declarations to verify they match "elfread.c". */ |
775 | +#include <rpm/rpmlib.h> | |
776 | +#include <rpm/rpmts.h> | |
777 | +#include <rpm/rpmdb.h> | |
778 | +#include <rpm/header.h> | |
779 | +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); | |
780 | +extern int rpmReadConfigFiles(const char * file, const char * target); | |
781 | +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); | |
782 | +extern Header rpmdbNextIterator(rpmdbMatchIterator mi); | |
783 | +extern rpmts rpmtsCreate(void); | |
784 | +extern rpmts rpmtsFree(rpmts ts); | |
5673f127 | 785 | +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag, |
4b0e5c1b | 786 | + const void * keyp, size_t keylen); |
3a58abaf | 787 | + |
4b0e5c1b AM |
788 | +int |
789 | +main () | |
790 | +{ | |
3a58abaf | 791 | + |
4b0e5c1b AM |
792 | + ; |
793 | + return 0; | |
321e94d6 | 794 | +} |
4b0e5c1b AM |
795 | +_ACEOF |
796 | +if ac_fn_c_try_compile "$LINENO"; then : | |
3a58abaf | 797 | + |
4b0e5c1b AM |
798 | + LIBRPM_COMPAT=true |
799 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
800 | +$as_echo "yes" >&6; } | |
3a58abaf | 801 | + |
4b0e5c1b | 802 | +else |
3a58abaf | 803 | + |
4b0e5c1b AM |
804 | + LIBRPM_COMPAT=false |
805 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
806 | +$as_echo "no" >&6; } | |
3a58abaf | 807 | + |
4b0e5c1b AM |
808 | +fi |
809 | +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |
810 | + CFLAGS="$save_CFLAGS" | |
3a58abaf | 811 | + |
4b0e5c1b AM |
812 | + if ! $LIBRPM_COMPAT; then |
813 | + HAVE_LIBRPM=false | |
814 | + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" | |
815 | + fi | |
816 | + fi | |
3a58abaf | 817 | + |
4b0e5c1b | 818 | + if $HAVE_LIBRPM; then |
3a58abaf | 819 | + |
4b0e5c1b | 820 | +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h |
3a58abaf | 821 | + |
4b0e5c1b AM |
822 | + CFLAGS="$CFLAGS $RPM_CFLAGS" |
823 | + LIBS="$LIBS $RPM_LIBS" | |
824 | + else | |
825 | + if $RPM_REQUIRE; then | |
826 | + as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5 | |
827 | + else | |
828 | + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5 | |
829 | +$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;} | |
830 | + fi | |
831 | + fi | |
832 | + fi | |
833 | +fi | |
834 | + | |
835 | ||
836 | ||
837 | subdirs="$subdirs testsuite" | |
838 | diff --git a/gdb/configure.ac b/gdb/configure.ac | |
4b0e5c1b AM |
839 | --- a/gdb/configure.ac |
840 | +++ b/gdb/configure.ac | |
5673f127 | 841 | @@ -173,6 +173,200 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, |
4b0e5c1b AM |
842 | [Directories safe to hold auto-loaded files.]) |
843 | AC_MSG_RESULT([$with_auto_load_safe_path]) | |
844 | ||
845 | +# Integration with rpm library to support missing debuginfo suggestions. | |
846 | +# --without-rpm: Disable any rpm support. | |
847 | +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. | |
848 | +# Even with runtime missing `libname.so' GDB will still other run correctly. | |
849 | +# Missing `libname.so' during ./configure will abort the configuration. | |
850 | +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific | |
851 | +# minor version first such as `librpm-4.6.so' as minor version differences | |
852 | +# mean API+ABI incompatibility. If the specific match versioned library name | |
853 | +# could not be found still open dynamically at least `librpm.so'. | |
854 | +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try | |
855 | +# to find librpm for compilation-time linking by pkg-config. GDB binary will | |
856 | +# be probably linked with the version specific library (as `librpm-4.6.so'). | |
857 | +# Failure to find librpm by pkg-config will abort the configuration. | |
858 | +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config | |
859 | +# cannot find librpm use to the rpmless compilation (like `--without-rpm'). | |
860 | + | |
861 | +AC_ARG_WITH([rpm], | |
862 | + [AS_HELP_STRING([--with-rpm], | |
863 | + [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"]) | |
864 | + | |
865 | +m4_pattern_allow([^AC_MSG_ERROR$]) | |
866 | +m4_pattern_allow([^AC_MSG_WARN$]) | |
867 | +if test "x$with_rpm" != "xno"; then | |
868 | + if test "x$with_rpm" = "xyes"; then | |
869 | + LIBRPM="librpm.so" | |
870 | + RPM_REQUIRE=true | |
871 | + DLOPEN_REQUIRE=false | |
872 | + elif test "x$with_rpm" = "xauto"; then | |
873 | + LIBRPM="librpm.so" | |
874 | + RPM_REQUIRE=false | |
875 | + DLOPEN_REQUIRE=false | |
876 | + else | |
877 | + LIBRPM="$with_rpm" | |
878 | + RPM_REQUIRE=true | |
879 | + DLOPEN_REQUIRE=true | |
880 | + fi | |
881 | + LIBRPM_STRING='"'"$LIBRPM"'"' | |
882 | + | |
883 | + AC_MSG_CHECKING([specific librpm version]) | |
884 | + HAVE_DLOPEN_LIBRPM=false | |
885 | + save_LIBS="$LIBS" | |
886 | + LIBS="$LIBS -ldl" | |
887 | + AC_RUN_IFELSE(AC_LANG_PROGRAM([[ | |
888 | +#include <rpm/rpmlib.h> | |
889 | +#include <dlfcn.h> | |
890 | +#include <errno.h> | |
5673f127 | 891 | +#include <string.h> |
4b0e5c1b AM |
892 | + ]], [[ |
893 | + void *h; | |
894 | + const char *const *rpmverp; | |
895 | + FILE *f; | |
896 | + | |
897 | + f = fopen ("conftest.out", "w"); | |
898 | + if (!f) | |
899 | + { | |
900 | + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", | |
901 | + strerror (errno)); | |
902 | + return 1; | |
903 | + } | |
904 | + h = dlopen ($LIBRPM_STRING, RTLD_LAZY); | |
905 | + if (!h) | |
906 | + { | |
907 | + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); | |
908 | + return 1; | |
909 | + } | |
910 | + rpmverp = dlsym (h, "RPMVERSION"); | |
911 | + if (!rpmverp) | |
912 | + { | |
913 | + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); | |
914 | + return 1; | |
915 | + } | |
916 | + fprintf (stderr, "RPMVERSION is: \""); | |
917 | + fprintf (stderr, "%s\"\n", *rpmverp); | |
3a58abaf | 918 | + |
4b0e5c1b AM |
919 | + /* Try to find the specific librpm version only for "librpm.so" as we do |
920 | + not know how to assemble the version string otherwise. */ | |
321e94d6 | 921 | + |
4b0e5c1b AM |
922 | + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) |
923 | + { | |
924 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
925 | + return 0; | |
926 | + } | |
927 | + else | |
928 | + { | |
929 | + char *h2_name; | |
930 | + void *h2; | |
931 | + int major, minor; | |
321e94d6 | 932 | + |
4b0e5c1b AM |
933 | + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) |
934 | + { | |
935 | + fprintf (stderr, "Unable to parse RPMVERSION.\n"); | |
936 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
937 | + return 0; | |
938 | + } | |
939 | + /* Avoid the square brackets by malloc. */ | |
940 | + h2_name = malloc (64); | |
941 | + sprintf (h2_name, "librpm-%d.%d.so", major, minor); | |
942 | + h2 = dlopen (h2_name, RTLD_LAZY); | |
943 | + if (!h2) | |
944 | + { | |
945 | + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); | |
946 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
947 | + return 0; | |
948 | + } | |
949 | + if (h2 != h) | |
950 | + { | |
951 | + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", | |
952 | + $LIBRPM_STRING, h2_name); | |
953 | + fprintf (f, "%s\n", $LIBRPM_STRING); | |
954 | + return 0; | |
955 | + } | |
956 | + /* Found the valid .so name with a specific version. */ | |
957 | + fprintf (f, "%s\n", h2_name); | |
958 | + return 0; | |
959 | + } | |
960 | + ]]), [ | |
961 | + DLOPEN_LIBRPM="`cat conftest.out`" | |
962 | + if test "x$DLOPEN_LIBRPM" != "x"; then | |
963 | + HAVE_DLOPEN_LIBRPM=true | |
964 | + AC_MSG_RESULT($DLOPEN_LIBRPM) | |
965 | + fi | |
966 | + ]) | |
967 | + rm -f conftest.out | |
321e94d6 | 968 | + |
4b0e5c1b AM |
969 | + m4_define([CHECK_LIBRPM_COMPAT], [ |
970 | + AC_MSG_CHECKING([rpm library API compatibility]) | |
971 | + # The compilation requires -Werror to verify anything. | |
972 | + save_CFLAGS="$CFLAGS" | |
973 | + CFLAGS="$CFLAGS -Werror" | |
974 | + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ | |
975 | +/* Duplicate here the declarations to verify they match "elfread.c". */ | |
976 | +#include <rpm/rpmlib.h> | |
977 | +#include <rpm/rpmts.h> | |
978 | +#include <rpm/rpmdb.h> | |
979 | +#include <rpm/header.h> | |
980 | +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); | |
981 | +extern int rpmReadConfigFiles(const char * file, const char * target); | |
982 | +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); | |
983 | +extern Header rpmdbNextIterator(rpmdbMatchIterator mi); | |
984 | +extern rpmts rpmtsCreate(void); | |
985 | +extern rpmts rpmtsFree(rpmts ts); | |
5673f127 | 986 | +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag, |
4b0e5c1b AM |
987 | + const void * keyp, size_t keylen); |
988 | + ]]), [ | |
989 | + LIBRPM_COMPAT=true | |
990 | + AC_MSG_RESULT(yes) | |
991 | + ], [ | |
992 | + LIBRPM_COMPAT=false | |
993 | + AC_MSG_RESULT(no) | |
994 | + ]) | |
995 | + CFLAGS="$save_CFLAGS" | |
996 | + ]) | |
321e94d6 | 997 | + |
4b0e5c1b AM |
998 | + if $HAVE_DLOPEN_LIBRPM; then |
999 | + CHECK_LIBRPM_COMPAT | |
1000 | + if ! $LIBRPM_COMPAT; then | |
1001 | + HAVE_DLOPEN_LIBRPM=false | |
1002 | + fi | |
1003 | + fi | |
321e94d6 | 1004 | + |
4b0e5c1b AM |
1005 | + if $HAVE_DLOPEN_LIBRPM; then |
1006 | + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' | |
1007 | + AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.]) | |
1008 | + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) | |
1009 | + else | |
1010 | + AC_MSG_RESULT(no) | |
1011 | + LIBS="$save_LIBS" | |
1012 | + if $DLOPEN_REQUIRE; then | |
1013 | + AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.]) | |
1014 | + fi | |
1015 | + PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false]) | |
321e94d6 | 1016 | + |
4b0e5c1b AM |
1017 | + if $HAVE_LIBRPM; then |
1018 | + CHECK_LIBRPM_COMPAT | |
1019 | + if ! $LIBRPM_COMPAT; then | |
1020 | + HAVE_LIBRPM=false | |
1021 | + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" | |
1022 | + fi | |
1023 | + fi | |
321e94d6 | 1024 | + |
4b0e5c1b AM |
1025 | + if $HAVE_LIBRPM; then |
1026 | + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) | |
1027 | + CFLAGS="$CFLAGS $RPM_CFLAGS" | |
1028 | + LIBS="$LIBS $RPM_LIBS" | |
1029 | + else | |
1030 | + if $RPM_REQUIRE; then | |
1031 | + AC_MSG_ERROR($RPM_PKG_ERRORS) | |
1032 | + else | |
1033 | + AC_MSG_WARN($RPM_PKG_ERRORS) | |
1034 | + fi | |
1035 | + fi | |
1036 | + fi | |
1037 | +fi | |
174fe25c | 1038 | + |
4b0e5c1b | 1039 | AC_CONFIG_SUBDIRS(testsuite) |
3a58abaf | 1040 | |
4b0e5c1b | 1041 | # Check whether to support alternative target configurations |
4b0e5c1b | 1042 | diff --git a/gdb/event-top.c b/gdb/event-top.c |
4b0e5c1b AM |
1043 | --- a/gdb/event-top.c |
1044 | +++ b/gdb/event-top.c | |
5673f127 | 1045 | @@ -43,6 +43,7 @@ |
174fe25c | 1046 | #include "async-event.h" |
0e7ddf04 | 1047 | #include "bt-utils.h" |
5673f127 | 1048 | #include "pager.h" |
4b0e5c1b | 1049 | +#include "symfile.h" |
321e94d6 | 1050 | |
4b0e5c1b AM |
1051 | /* readline include files. */ |
1052 | #include "readline/readline.h" | |
5673f127 | 1053 | @@ -404,6 +405,8 @@ display_gdb_prompt (const char *new_prompt) |
4b0e5c1b AM |
1054 | /* Reset the nesting depth used when trace-commands is set. */ |
1055 | reset_command_nest_depth (); | |
321e94d6 | 1056 | |
4b0e5c1b AM |
1057 | + debug_flush_missing (); |
1058 | + | |
1059 | /* Do not call the python hook on an explicit prompt change as | |
1060 | passed to this function, as this forms a secondary/local prompt, | |
1061 | IE, displayed but not set. */ | |
5673f127 | 1062 | @@ -788,7 +791,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl) |
4b0e5c1b | 1063 | command_handler (cmd); |
321e94d6 | 1064 | |
4b0e5c1b AM |
1065 | if (ui->prompt_state != PROMPTED) |
1066 | - display_gdb_prompt (0); | |
321e94d6 | 1067 | + { |
4b0e5c1b AM |
1068 | + debug_flush_missing (); |
1069 | + display_gdb_prompt (0); | |
321e94d6 | 1070 | + } |
4b0e5c1b | 1071 | } |
321e94d6 | 1072 | } |
e5178960 | 1073 | |
4b0e5c1b | 1074 | diff --git a/gdb/symfile.h b/gdb/symfile.h |
4b0e5c1b AM |
1075 | --- a/gdb/symfile.h |
1076 | +++ b/gdb/symfile.h | |
5673f127 | 1077 | @@ -367,6 +367,7 @@ extern void generic_load (const char *args, int from_tty); |
4b0e5c1b AM |
1078 | /* build-id support. */ |
1079 | extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); | |
1080 | extern void debug_print_missing (const char *binary, const char *debug); | |
1081 | +extern void debug_flush_missing (void); | |
174fe25c | 1082 | #define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") |
4b0e5c1b | 1083 | |
1d2a824d | 1084 | /* From minidebug.c. */ |