Welcome to little lamb

Code » comain » commit 97eb89e

configure: Fix vpath handling

author Olivier Brunel
2023-07-18 11:30:59 UTC
committer Olivier Brunel
2023-07-18 16:24:07 UTC
parent 6185f705939fe06125e78046263d107b7a916a6e

configure: Fix vpath handling

configure +44 -39
meta/deps.tpl/skalibs/get_vpath +8 -0

diff --git a/configure b/configure
index 2eb2fbb..2f0daa6 100755
--- a/configure
+++ b/configure
@@ -250,6 +250,8 @@ procdep_real()
         if test $isint -eq 1; then
             cppflags="src/lib$depname/include"
         fi
+        vpath="$libdir"
+        vpathA="$libdir"
     else
         libs="$("$depdir/get_libs" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)"
         libsA="$("$depdir/get_libs" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)"
@@ -258,13 +260,17 @@ procdep_real()
         cflags="$("$depdir/get_cflags" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)"
         cflagsA="$("$depdir/get_cflags" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)"
         cppflags="$("$depdir/get_incdir" $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)"
+        vpath="$("$depdir/get_vpath" shared "$libdir" 2>/dev/null)"
+        vpathA="$("$depdir/get_vpath" static "$libdir" 2>/dev/null)"
     fi
     if test $isint -eq 1; then
         d="$intdir/$depname"
         vpath="$d"
+        vpathA="$d"
     else
         d="$incdir"
-        vpath="$libdir"
+        if test -z "$vpath"; then vpath="$libdir"; fi
+        if test -z "$vpathA"; then vpathA="$libdir"; fi
     fi
     if test -n "$cppflags"; then
         cppflags="-isystem $d/$cppflags"
@@ -298,13 +304,14 @@ procdep_real()
                     else
                         case "$arg" in
                             LIBS=*) libs="$libs $(expr substr "$arg" 6 ${#arg}) " ;;
-                            LIBSA=*) libsa="$libsa $(expr substr "$arg" 7 ${#arg}) " ;;
+                            LIBSA=*) libsA="$libsA $(expr substr "$arg" 7 ${#arg}) " ;;
                             LDFLAGS=*) ldflags="$ldflags $(expr substr "$arg" 9 ${#arg}) " ;;
-                            LDFLAGSA=*) ldflagsa="$ldflagsa $(expr substr "$arg" 10 ${#arg}) " ;;
+                            LDFLAGSA=*) ldflagsA="$ldflagsA $(expr substr "$arg" 10 ${#arg}) " ;;
                             CFLAGS=*) cflags="$cflags $(expr substr "$arg" 8 ${#arg}) " ;;
-                            CFLAGSA=*) cflagsa="$cflags $(expr substr "$arg" 9 ${#arg}) " ;;
+                            CFLAGSA=*) cflagsA="$cflagsA $(expr substr "$arg" 9 ${#arg}) " ;;
                             CPPFLAGS=*) cppflags="$cppflags $(expr substr "$arg" 10 ${#arg}) " ;;
                             VPATH=*) vpath="$vpath $(expr substr "$arg" 7 ${#arg}) " ;;
+                            VPATHA=*) vpathA="$vpathA $(expr substr "$arg" 8 ${#arg}) " ;;
                         esac
                     fi
                 done < $tmp
@@ -320,13 +327,14 @@ procdep_real()
     cat <<EOF
 $isint OK $version $needver $verok
 LIBS=$(echo $libs | tr '\n' ' ')
-LIBSA=$(echo $libsa | tr '\n' ' ')
+LIBSA=$(echo $libsA | tr '\n' ' ')
 LDFLAGS=$(echo $ldflags | tr '\n' ' ')
-LDFLAGSA=$(echo $ldflagsa | tr '\n' ' ')
+LDFLAGSA=$(echo $ldflagsA | tr '\n' ' ')
 CFLAGS=$(echo $cflags | tr '\n' ' ')
-CFLAGSA=$(echo $cflagsa | tr '\n' ' ')
+CFLAGSA=$(echo $cflagsA | tr '\n' ' ')
 CPPFLAGS=$(echo $cppflags | tr '\n' ' ')
 VPATH=$(echo $vpath | tr '\n' ' ')
+VPATHA=$(echo $vpathA | tr '\n' ' ')
 EOF
 }
 
@@ -402,13 +410,14 @@ procdep()
         else
             case "$arg" in
                 LIBS=*) deplibs="$(expr substr "$arg" 6 ${#arg}) " ;;
-                LIBSA=*) deplibsa="$(expr substr "$arg" 7 ${#arg}) " ;;
+                LIBSA=*) deplibsA="$(expr substr "$arg" 7 ${#arg}) " ;;
                 LDFLAGS=*) depldflags="$(expr substr "$arg" 9 ${#arg}) " ;;
-                LDFLAGSA=*) depldflagsa="$(expr substr "$arg" 10 ${#arg}) " ;;
+                LDFLAGSA=*) depldflagsA="$(expr substr "$arg" 10 ${#arg}) " ;;
                 CFLAGS=*) depcflags="$(expr substr "$arg" 8 ${#arg}) " ;;
-                CFLAGSA=*) depcflagsa="$(expr substr "$arg" 9 ${#arg}) " ;;
+                CFLAGSA=*) depcflagsA="$(expr substr "$arg" 9 ${#arg}) " ;;
                 CPPFLAGS=*) depcppflags="$(expr substr "$arg" 10 ${#arg}) " ;;
                 VPATH=*) vpath="$(expr substr "$arg" 7 ${#arg}) " ;;
+                VPATHA=*) vpathA="$(expr substr "$arg" 8 ${#arg}) " ;;
             esac
         fi
     done < $tmp
@@ -456,18 +465,6 @@ procdep()
     local l="$(eval "echo \$link$depname")"
     if test -n "$l" && test "$l" -ge 0; then link="$l"; fi
 
-    local vpathso
-    local vpatha
-    if test $cpnt -ne 1; then
-        if test $internal -eq 1; then
-            vpathso="$depdir"
-            vpatha="$depdir"
-        else
-            vpathso="$libdir"
-            vpatha="$libdir"
-        fi
-    fi
-
     if test $cpnt -ne 1 && test $link -gt 0; then
         if test $link -eq 1; then
             echo " (shared linking)"
@@ -489,23 +486,31 @@ procdep()
         eval "libs$depname=\"$deplibs\""
         eval "libsA$depname=\"$deplibsA\""
 
-        case $link in
-            1) VPATHS="$VPATHS
-vpath lib$library.so $vpathso"
-                ;;
-            2) VPATHS="$VPATHS
-vpath lib$library.a $vpatha"
-                ;;
-        esac
-        if test $prefer = "shared"; then
-            VPATHS="$VPATHS
-vpath lib%.so $vpath
-vpath lib%.a $vpath"
-        else
-            VPATHS="$VPATHS
-vpath lib%.a $vpath
-vpath lib%.so $vpath"
-        fi
+        function mkvpath()
+        {
+            local link=$1
+            local vpath=$2
+            shift 2
+            local ext1=so
+            local ext2=a
+            if test $prefer = "static"; then
+                ext1=a
+                ext2=so
+                link=$((1 + ($link & 1)))
+            fi
+            for lib in $@; do
+                if test $(($link & 5)) -ge 1; then
+                    echo vpath lib${lib:2:${#lib}}.$ext1 $vpath
+                fi
+                if test $(($link & 6)) -ge 2; then
+                    echo vpath lib${lib:2:${#lib}}.$ext2 $vpath
+                fi
+                link=$(($link | 4))
+            done
+        }
+
+        VPATHS="$VPATHS
+$(mkvpath $link "$vpath" $deplibs)"
 
         if test $internal -eq 1 && test $depname = "skalibs"; then
             sysdeps="$depdir/sysdeps.cfg"
diff --git a/meta/deps.tpl/skalibs/get_vpath b/meta/deps.tpl/skalibs/get_vpath
new file mode 100755
index 0000000..da80629
--- /dev/null
+++ b/meta/deps.tpl/skalibs/get_vpath
@@ -0,0 +1,8 @@
+#!/bin/sh
+type=$1
+libdir=$2
+if test "$type" = "shared"; then
+    echo $libdir
+else
+    echo $libdir/skalibs
+fi