From 5ff59d00d046bd5cba588d51c77bb2715667deb5 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Tue, 28 Jan 2025 14:16:55 -0500
Subject: [PATCH] WIP: builds

---
 gcc/cobol/scripts/debug-configure-build   | 41 +++++++++++++++--------
 gcc/cobol/scripts/release-configure-build |  9 +++--
 2 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/gcc/cobol/scripts/debug-configure-build b/gcc/cobol/scripts/debug-configure-build
index 5813c8f22601..a3b83953228c 100755
--- a/gcc/cobol/scripts/debug-configure-build
+++ b/gcc/cobol/scripts/debug-configure-build
@@ -3,11 +3,30 @@
 set -e
 set -x
 
+# We want a relevant version code:
+if test -z "$(which git || true)" 
+then 
+    # Without git, we want *something*
+    COMMIT_VERSION=-rel-000000
+else
+    # git exists
+    MD5_HASH=-$(git log --abbrev-commit --abbrev=6 | head -n1 | head -n1 | sed 's/commit //')
+    # And we'll use the GIT date of the repo as a final pseudo-build number
+    # as a version tiebreaker.
+    GITDATE=$(git show --date=iso-strict | grep Date | head -n1 | sed 's/.*\([0-9]\{4\}\)[-]\([0-9]\{2\}\)[-]\([0-9]\{2\}\).*/\1\2\3/')
+    # As of this writing, we are building on Ubuntu 22.04 and 24.04 systems:
+    COMMIT_VERSION=-dev-$MD5_HASH
+fi
+
+RELEASE_ID=-$(cat /etc/os-release | grep "^ID=" | sed 's/ID=\(.*\).*$/\1/g' | sed 's/ubuntu/ubu/g')
+RELEASE_VERSION_ID=$(cat /etc/os-release | grep "^VERSION_ID=\"" | sed 's/^VERSION_ID="\([0-9]\+\)[.].*$/\1/g')
+
 if [ "$1" = "commit-release" ]
 then
-    pwd
-    commit_md5=$(git log -1 --abbrev-commit | awk '/^commit/ { print $2}')
-    COMMIT_VERSION=-dev-$commit_md5
+    # We want to know exactly where various files go for the purposes of
+    # creating the distribution package
+	ULIBDIR=--libdir=/usr/lib/gcobol
+	ULIBEXECDIR=--libexecdir=/usr/libexec/gcobol
     shift
 fi
 
@@ -23,25 +42,19 @@ if test -z "$(which make || true)"; then sudo apt -y install make; fi
 if test -z "$(which bison || true)"; then sudo apt -y install bison; fi
 if test -z "$(which flex || true)"; then sudo apt -y install flex; fi
 
-# sudo apt install g++ libgmp-dev  libmpfr-dev libmpc-dev libz-dev make bison flex gawk
-
-VERSION=$(cat ../../../gcc/BASE-VER)
-
-MAJOR_VERSION=$(echo $VERSION | sed 's/^\([0-9]\+\)[.].*$/\1/')
-PKGVERSION="GCOBOL ${VERSION}${COMMIT_VERSION} (debuggable)"
-
-echo "PKGVERSION is $PKGVERSION"
+DOTTED_VERSION=$(cat ${0%/*}/../../../gcc/BASE-VER)
+MAJOR_VERSION=$(echo $DOTTED_VERSION | sed 's/^\([0-9]\+\)[.].*$/\1/')
+PKGVERSION="GCOBOL(debuggable)-$DOTTED_VERSION.$GITDATE$MD5_HASH$SYSTEM$RELEASE_ID$RELEASE_VERSION_ID"
+PKGVERSION="GCOBOL(debuggable)-$MAJOR_VERSION.$GITDATE$MD5_HASH$SYSTEM$RELEASE_ID$RELEASE_VERSION_ID"
 
 arch=$(arch)
 
+test "$arch"
 if [ $arch = x86_64 ]
 then
     arch_options='--with-abi=m64 --with-tune=generic --enable-default-pie'
 fi
 
-# Set up for a build, using the presumptive directory tree that we've been using
-# for development.
-
 # We start in <repo>/gcc/cobol/scripts
 cd ${0%/*}/../../..
 mkdir -p build
diff --git a/gcc/cobol/scripts/release-configure-build b/gcc/cobol/scripts/release-configure-build
index 239c6108a002..751c5d045442 100755
--- a/gcc/cobol/scripts/release-configure-build
+++ b/gcc/cobol/scripts/release-configure-build
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 set -e
-set +x
+set -x
 
 # We want a relevant version code:
 if test -z "$(which git || true)" 
@@ -30,6 +30,11 @@ then
     shift
 fi
 
+ULIBDIR=--libdir=/usr/lib/gcobol
+ULIBEXECDIR=--libexecdir=/usr/libexec/gcobol
+
+
+
 # These prerequisites suffice for a compilation on Ubuntu 20.04 through 24.04  The various
 # tests avoid attempting to re-install packages, which can be annoying when the
 # user doesn't have complete sudo permissions.
@@ -44,8 +49,8 @@ if test -z "$(which flex || true)"; then sudo apt -y install flex; fi
 
 DOTTED_VERSION=$(cat ${0%/*}/../../../gcc/BASE-VER)
 MAJOR_VERSION=$(echo $DOTTED_VERSION | sed 's/^\([0-9]\+\)[.].*$/\1/')
-PKGVERSION="GCOBOL-$MAJOR_VERSION.$GITDATE$MD5_HASH$SYSTEM$RELEASE_ID$RELEASE_VERSION_ID"
 PKGVERSION="GCOBOL-$DOTTED_VERSION.$GITDATE$MD5_HASH$SYSTEM$RELEASE_ID$RELEASE_VERSION_ID"
+PKGVERSION="GCOBOL-$MAJOR_VERSION.$GITDATE$MD5_HASH$SYSTEM$RELEASE_ID$RELEASE_VERSION_ID"
 
 arch=$(arch)
 
-- 
GitLab