Welcome to little lamb

Code » comain » commit 2145383

configure: Add a check/variable BITS

author Olivier Brunel
2023-01-26 14:46:43 UTC
committer Olivier Brunel
2023-01-26 14:46:43 UTC
parent d03ba862bdf3183afa0c0e0733de1b02c94205dc

configure: Add a check/variable BITS

Set to either 32 or 64 based on $target

Also use GNU make's .SECONDEXPANSION: (in config.mk) so it works even
though the variables are defined later/in project.mk

configure +14 -2

diff --git a/configure b/configure
index e904d1e..62dce59 100755
--- a/configure
+++ b/configure
@@ -372,7 +372,11 @@ echon "  -> Checking target.."
 if test -z "$target" ; then
     target=$($CC -dumpmachine 2>/dev/null) || target=unknown
 fi
-echo ".. $target"
+BITS=32
+case "$target" in
+    *x86_64*) BITS=64 ;;
+esac
+echo ".. $target [${BITS}bit]"
 if test ! -d $sysdeps || test ! -f $sysdeps/target; then
     error 2 "$sysdeps is not a valid sysdeps directory"
 fi
@@ -380,6 +384,7 @@ if test "x$target" != "x$(cat $sysdeps/target)"; then
     error 2 "target $target does not match the contents of $sysdeps/target ($(cat $sysdeps/target))"
 fi
 
+
 echo " => Testing C compiler..."
 tryflag CFLAGS -std=c99
 tryflag CFLAGS -fomit-frame-pointer
@@ -430,6 +435,9 @@ echo "# $0 $@"
 echo "# Any changes you make in here will be lost on the next ./configure"
 echo ""
 
+echo "BITS := $BITS"
+echo ""
+
 echo "CC = $CC"
 echo "AR = $AR"
 echo "RANLIB = $RANLIB"
@@ -453,6 +461,7 @@ setdep()
 }
 
 echo "# dependencies"
+echo ".SECONDEXPANSION:"
 if test -d meta/libs; then
     for file in meta/libs/*; do
         exec 4<"$file"
@@ -462,7 +471,9 @@ if test -d meta/libs; then
             if test "$(expr substr "$line" 1 1)" = "#"; then continue; fi
             foreach "dep" $nbdeps setdep
             offset=$((${#line}-1))
-            if test "$(expr substr "$line" $offset 2)" = ".o"; then
+            if test "$(expr substr "$line" ${#line} 1)" = ")"; then
+                lineso="$(expr substr "$line" 1 $offset)_so)"
+            elif test "$(expr substr "$line" $offset 2)" = ".o"; then
                 lineso="$(expr substr "$line" 1 $(($offset-1))).lo"
             else
                 lineso=
@@ -542,6 +553,7 @@ cat <<EOF
 #ifndef ${prefix}_CONFIG_H
 #define ${prefix}_CONFIG_H
 
+#define ${prefix}_BITS      $BITS
 #define ${prefix}_CURYEAR   "$(date +%Y)"
 #define ${prefix}_AUTHOR    "Olivier Brunel"
 #define ${prefix}_VERSION   "$version"