2 # Compare semantically pc files between two dirs, with same relative
3 # pathnames, say one generated by autotools, the other one generated
4 # by meson, by not requesting lexical identity but by
5 # checking that the same vars are available, and that they eventually
6 # have the same definition, whatever way (with whatever pkconf
7 # variable) they have been expressed.
9 # Copyright 2024 Thierry LARONDE <tlaronde@kergis.com>
10 # SPDX-License-Identifier: MIT
12 # Pc file paths have to be given fully qualified to be independent
13 # from PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH definition.
15 test $# -eq 2 && test -d "$1" && test -d "$2"\
16 && test "${1#/}" != "$1" && test "${2#/}" != "$2" ||
{
17 echo "Usage: $(basename $0) fqdir1 fqdir2" >&2
34 # Start by simply comparing the list of pc files between the two dirs.
36 (cd "$dir1"; find .
-type f
-name "*.pc") |
sort > "$TMPDIR/$$.1"
37 (cd "$dir2"; find .
-type f
-name "*.pc") |
sort > "$TMPDIR/$$.2"
38 cmp "$TMPDIR/$$.1" "$TMPDIR/$$.2" 2>/dev
/null ||
{
39 log
"Pc files not matching between %s and %s:\n" "$dir1" "$dir2"
40 diff -u "$TMPDIR/$$.1" "$TMPDIR/$$.2" >&2
49 for pc
in "$dir1/$pcfile" "$dir2/$pcfile"; do
51 pkgconf
--print-variables "$pc"\
54 test "$var" != "pcfiledir" ||
continue
55 pkgconf
--variable=$var "$pc"\
57 done >"$TMPDIR/$$.pc$ifile"
59 if ! cmp "$TMPDIR/$$.pc1" "$TMPDIR/$$.pc2" 2>/dev
/null
; then
60 log
"!!! %s generated files differ:\n" "$pcfile"
61 diff -U0 "$TMPDIR/$$.pc1" "$TMPDIR/$$.pc2" >&2
62 status
=$
(($status + 1))
67 if test "$status" -ne 0; then
68 log
"%d pc files in %s and %s differ semantically.\n" "$status" "$dir1" "$dir2"