cac1fca3406536a9f42965bbbebc101b62d8d8e3
braney
  Wed Sep 9 18:01:54 2026 -0700
submoduleSetup: anchor on kent/src so it works from either caller's cwd

Every path in submoduleSetup is relative to kent/src, but its two callers
invoke it from different directories: src/makefile runs
./submodules/submoduleSetup from src, while userApps/fetchKentSource.sh cds
into src/submodules first and runs ./submoduleSetup.

Since the zlib-ng change this broke the userApps source build.  From
src/submodules the guard "[ ! -e submodules/zlib-ng/Makefile ]" is true
because that path cannot exist there, so the configure block ran and its
redirect to submodules/zlib-ng-configure.log failed on a missing directory:

./submoduleSetup: line 41: submodules/zlib-ng-configure.log:
No such file or directory
Error: zlib-ng configure failed, see submodules/zlib-ng-configure.log
make: *** [Makefile:28: fetchSource] Error 1

The htslib serial-probe block added for the AVX2 -j race has the same path
problem, but its guard is not negated, so from src/submodules it silently
tested a path that could not exist and never ran at all -- leaving the
userApps build exposed to the very race that block exists to prevent.

Fix both by cd'ing to the script's own parent directory up front, so the
caller's cwd no longer matters.  Verified from both call sites: the
userApps path now configures zlib-ng and pre-generates htscodecs.mk with
correct probe flags (HTS_CFLAGS_AVX2 = -mavx2 -mpopcnt), and a re-run from
src is a quiet no-op.

refs #38125

diff --git src/submodules/submoduleSetup src/submodules/submoduleSetup
index b3d12f06d6a..3be933f5428 100755
--- src/submodules/submoduleSetup
+++ src/submodules/submoduleSetup
@@ -1,22 +1,30 @@
 #!/bin/bash
 set -beEu -o pipefail
 
 # Do required submodule setup to support building the browser
 # Sync submodules to the commits pinned by the parent repo, and check for
 # having remains of old htslib copy to deal with switch from old version.
 
+# Every path below is relative to kent/src, but callers reach this script from
+# different directories: src/makefile runs ./submodules/submoduleSetup from
+# src, while userApps/fetchKentSource.sh cds into src/submodules first.  Anchor
+# on kent/src ourselves so the caller's cwd does not matter.  Without this the
+# zlib-ng configure below died on its own log path, and the htslib probe guard
+# silently tested a path that could not exist and so never ran.  refs #38125
+cd "$(dirname "$0")/.."
+
 if [ -e htslib ] ; then
     echo "*********************************************************************" >&2
     echo "Note: an outdated kent/src/htslib/ exists in the working tree." >&2
     echo "      It is no longer used and can be removed."   >&2
     echo "*********************************************************************" >&2
 fi
 
 if git rev-parse --is-inside-work-tree >/dev/null 2>&1 ; then
     # Sync submodules to the commits pinned by the parent repo on every build,
     # not just on first-time init, so a moved pointer (e.g. after a pull) is
     # always checked out.  --init covers the first-time case, --recursive also
     # updates the nested htscodecs submodule.  git is silent when already in sync.
     git -c protocol.file.allow=always submodule update --init --recursive
 elif [ ! -e submodules/htslib/hts.c -o ! -e submodules/htslib/htscodecs/htscodecs/htscodecs.c \
        -o ! -e submodules/zlib-ng/deflate.c ] ; then