Welcome to little lamb

Code » comain » commit 69cb77f

configure: Add support for per-option objetcts

author Olivier Brunel
2023-01-27 09:10:25 UTC
committer Olivier Brunel
2023-01-27 09:10:25 UTC
parent 6c2e7b6ee4f4f57f4838d2f8a91e6906f9b3f3f7

configure: Add support for per-option objetcts

That is, in meta/{bins,libs} files we can have line in format:

+optname=object

that will only set object if the option optname is enabled.

configure +31 -0

diff --git a/configure b/configure
index 216b710..c49710e 100755
--- a/configure
+++ b/configure
@@ -479,19 +479,36 @@ if test -d meta/libs; then
         depsA=
         depsSO=
         while IFS= read -r line <&4; do
+            # ignore comment
             if test "$(expr substr "$line" 1 1)" = "#"; then continue; fi
+            # +name=obj means only add obj is option name is set
+            if test "$(expr substr "$line" 1 1)" = "+"; then
+                opt="$(echo $line | cut -d= -f1)"
+                opt="$(expr substr "$opt" 2 ${#opt})"
+                eval disabled=\$optdisabled$opt
+                # empty $disabled means an option that doesn't exist!
+                if test -z "$disabled"; then error 2 "Unknown option '$opt' in $line"; fi
+                if test $disabled -eq 1; then continue; fi
+                line="$(echo $line | cut -d= -f2)"
+            fi
+            # replace depname by -llibdeb (e.g. skalibs by -lskarnet)
             foreach "dep" $nbdeps setdep
+
             offset=$((${#line}-1))
+            # if a variable - e.g. $$(FOO) - then use $$(FOO_so) for shared lib
             if test "$(expr substr "$line" ${#line} 1)" = ")"; then
                 lineso="$(expr substr "$line" 1 $offset)_so)"
+            # if a .o then use .lo for shared lib
             elif test "$(expr substr "$line" $offset 2)" = ".o"; then
                 lineso="$(expr substr "$line" 1 $(($offset-1))).lo"
             else
                 lineso=
             fi
+            # if .O then use .o always (shared lib also)
             if test "$(expr substr "$line" $offset 2)" = ".O"; then
                 line="$(expr substr "$line" 1 $(($offset-1))).o"
             fi
+            # not special for shared lib, so use the same
             if test -z "$lineso"; then
                 lineso="$line"
             fi
@@ -509,9 +526,23 @@ if test -d meta/bins; then
         exec 4<"$file"
         deps=
         while IFS= read -r line <&4; do
+            # ignore comment
             if test "$(expr substr "$line" 1 1)" = "#"; then continue; fi
+            # +name=obj means only add obj is option name is set
+            if test "$(expr substr "$line" 1 1)" = "+"; then
+                opt="$(echo $line | cut -d= -f1)"
+                opt="$(expr substr "$opt" 2 ${#opt})"
+                eval disabled=\$optdisabled$opt
+                # empty $disabled means an option that doesn't exist!
+                if test -z "$disabled"; then error 2 "Unknown option '$opt' in $line"; fi
+                if test $disabled -eq 1; then continue; fi
+                line="$(echo $line | cut -d= -f2)"
+            fi
+            # replace depname by -llibdeb (e.g. skalibs by -lskarnet)
             foreach "dep" $nbdeps setdep
+
             offset=$((${#line}-1))
+            # if .O then use .o always
             if test "$(expr substr "$line" $offset 2)" = ".O"; then
                 line="$(expr substr "$line" 1 $(($offset-1))).o"
             fi