Welcome to little lamb

Code » comain » commit a30b274

configure: Fix handling of internal libs..

author Olivier Brunel
2023-06-21 18:17:42 UTC
committer Olivier Brunel
2023-06-28 16:07:22 UTC
parent 5376481de479787e1be4ae264dc5d3cae97f0754

configure: Fix handling of internal libs..

That is, when a binary depends on an internal library (i.e. a library
from this very project), make sure it comes first (or, that all actual
deps have a "after" set to such internal libs)

configure +11 -1

diff --git a/configure b/configure
index b029763..243f95f 100755
--- a/configure
+++ b/configure
@@ -792,9 +792,12 @@ if test -n "$BITS"; then
 fi
 
 # add our own libraries so we can have binaries depending on them
+intlib=$nb_deps
+intaft=0
 for lib in src/lib*; do
     if test $lib = "src/lib*"; then break; fi
     lib="$(expr substr "$lib" 8 ${#lib})"
+    intaft=$(( $intaft + (1 << $nb_deps) ))
     nb_deps=$((nb_deps + 1))
     eval "idx$lib=$nb_deps"
     eval "deps$nb_deps=$lib"
@@ -898,7 +901,14 @@ setupobjs()
             if test $(($deps & $n)) -gt 0; then
                 depname=$(eval echo \$deps$i)
                 depname=${depname##*/}
-                local after=$((($(eval echo \$after$depname) + 0) & $deps))
+                local after=0
+                if test $i -le $intlib; then
+                    # this is an "actual" deps, i.e. not an internal one
+                    # so we get its actual value for "after"
+                    after=$((($(eval echo \$after$depname) + 0) & $deps))
+                    # and make sure that it is also after all internal deps
+                    after=$(( ($intaft & $deps) + $after ))
+                fi
                 if test $after -eq 0; then
                     libs="$libs $(eval echo \$libs$depname)"
                     libsA="$libsA $(eval echo \$libsA$depname)"