Welcome to little lamb

Code » comain » commit ed12b37

configure: Support linking our own libs

author Olivier Brunel
2023-06-18 07:08:40 UTC
committer Olivier Brunel
2023-06-20 07:07:15 UTC
parent b5f47a68f5054f6e544878f569b5d3b2294f4ac3

configure: Support linking our own libs

That is, a project can now have a binary that depends on one of the
libraries from that same project.

configure +27 -0

diff --git a/configure b/configure
index be4195e..bda59b1 100755
--- a/configure
+++ b/configure
@@ -791,6 +791,33 @@ if test -n "$BITS"; then
     echo ""
 fi
 
+# add our own libraries so we can have binaries depending on them
+for lib in src/lib*; do
+    if test $lib = "src/lib*"; then break; fi
+    lib="$(expr substr "$lib" 8 ${#lib})"
+    nb_deps=$((nb_deps + 1))
+    eval "idx$lib=$nb_deps"
+    eval "deps$nb_deps=$lib"
+    # in case there was a --set-shared/--set-static for it
+    link=$(eval echo \$link$lib)
+    # if not, we shall default to static (if built)
+    if test -z "$link"; then
+        if test $nostatic -eq 1; then
+            link=1
+        else
+            link=2
+        fi
+    fi
+    if test $link -eq 1; then
+        eval "libs$lib=lib$lib.so"
+    else
+        eval "libs$lib=lib$lib.a"
+    fi
+    eval "cppflags$lib=\"-isystem src/lib$lib/include\""
+    VPATHS="$VPATHS
+vpath lib$lib.a ."
+done
+
 # not sure this really matters, so long as both are mentioned it will be the
 # order of our vpath that will matter really - still, let's keep it that way
 if test "$prefer" = "static"; then