aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2018-08-30 04:44:23 +0000
committerNIIBE Yutaka <[email protected]>2018-08-30 04:44:23 +0000
commit78be78bd3d9129919544781e17c8d2fefea6e1de (patch)
tree3bee3ef6197f84c39bcd98f53e878c8527f46897
parentHandle module dependency (Requires field). (diff)
downloadlibgpg-error-78be78bd3d9129919544781e17c8d2fefea6e1de.tar.gz
libgpg-error-78be78bd3d9129919544781e17c8d2fefea6e1de.zip
Remove dupulicates.
-rw-r--r--src/gpg-error-config-main.sh4
-rw-r--r--src/pkgconf-funcs.sh39
2 files changed, 41 insertions, 2 deletions
diff --git a/src/gpg-error-config-main.sh b/src/gpg-error-config-main.sh
index d7b9c56..c8ee06f 100644
--- a/src/gpg-error-config-main.sh
+++ b/src/gpg-error-config-main.sh
@@ -106,14 +106,14 @@ for p in $pkg_list; do
done
if [ $opt_cflags = yes ]; then
- output="$output $cflags"
+ output="$output $(list_only_once $cflags)"
# Backward compatibility to old gpg-error-config
if [ $mt = yes ]; then
output="$output $mtcflags"
fi
fi
if [ $opt_libs = yes ]; then
- output="$output $libs"
+ output="$output $(list_only_once_for_libs $libs)"
# Backward compatibility to old gpg-error-config
if [ $mt = yes ]; then
output="$output $mtlibs"
diff --git a/src/pkgconf-funcs.sh b/src/pkgconf-funcs.sh
index a51a8c3..04dabc1 100644
--- a/src/pkgconf-funcs.sh
+++ b/src/pkgconf-funcs.sh
@@ -161,6 +161,45 @@ list_only_once () {
echo $result
}
+list_only_once_for_libs () {
+ local result=""
+ loca rev_list=""
+ local arg
+
+ # Scan the list and eliminate duplicates for non-"-lxxx"
+ # the resulted list is in reverse order
+ for arg; do
+ case "$arg" in
+ -l*)
+ # As-is
+ rev_list="$arg $rev_list"
+ ;;
+ *)
+ if not_listed_yet $arg "$rev_list"; then
+ rev_list="$arg $rev_list"
+ fi
+ ;;
+ esac
+ done
+
+ # Scan again
+ for arg in $rev_list; do
+ case "$arg" in
+ -l*)
+ if not_listed_yet $arg "$result"; then
+ result="$arg $result"
+ fi
+ ;;
+ *)
+ # As-is
+ result="$arg $result"
+ ;;
+ esac
+ done
+
+ echo $result
+}
+
#
# Recursively solve package dependencies
#