Fix Linux build dependency checks

ober

ed59e659223516aa5cd240f0d4cee60d584e1bd9

diff --git a/.gitignore b/.gitignore
index 3590b2a..2d06854 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 # Generated by jerbuild — do not edit
 lib/**/*.sls
 vendor/*.sls
+vendor/**/*.sls
 src/.jerbuild-hashes
 
 # Compiled Chez artifacts
diff --git a/Makefile b/Makefile
index 5993e33..55d60c8 100644
--- a/Makefile
+++ b/Makefile
@@ -127,7 +127,7 @@ SCHEME_CHEZ_DIR = $(shell if [ -n "$(SCHEME_MT)" ]; then ls -d "$(SCHEME_PREFIX)
 CHEZ_DIR ?= $(SCHEME_CHEZ_DIR)
 export CHEZ_DIR
 
-.PHONY: all vendor-deps deps ensure-jerboa-tools scintilla-vendor-deps scintilla-vendor-clean build rebuild run test-tier0 test-tier2 test-tier3 test-tier4 test-tier5 test-org test-extra test clean clean-generated \
+.PHONY: all vendor-deps check-pcre2-system-deps deps ensure-jerboa-tools scintilla-vendor-deps scintilla-vendor-clean build rebuild run test-tier0 test-tier2 test-tier3 test-tier4 test-tier5 test-org test-extra test clean clean-generated \
         test-org-duration test-org-element test-org-fold test-org-footnote \
         test-org-lint test-org-num test-org-property test-org-src test-org-tempo \
         test-vtscreen test-debug-repl test-qt test-qt-e2e build-qt binary-qt \
@@ -191,6 +191,11 @@ vendor-deps:
 	  fi; \
 	  if [ -d "$$dest/.git" ]; then \
 	    echo "  (exists) $$repo"; \
+	  elif [ -d "$$dest" ] && [ -z "$$(ls -A "$$dest")" ]; then \
+	    echo "  replacing empty gitlink directory $$dest"; \
+	    rmdir "$$dest"; \
+	    echo "  cloning $$repo from $$url"; \
+	    git clone --depth 1 "$$url" "$$dest"; \
 	  elif [ -e "$$dest" ]; then \
 	    echo "ERROR: $$dest exists but is not a git clone; remove it and rerun make vendor-deps" >&2; \
 	    exit 1; \
@@ -202,7 +207,24 @@ vendor-deps:
 	@scripts/patch-jerboa-aws-compat.sh "$(CURDIR)"
 	@echo "=== Vendor complete ==="
 
-deps: vendor-deps
+PCRE2_CHECK_CFLAGS := $(shell pkg-config --cflags libpcre2-8 2>/dev/null)
+PCRE2_CHECK_LIBS := $(shell pkg-config --libs libpcre2-8 2>/dev/null || echo -lpcre2-8)
+
+check-pcre2-system-deps:
+	@tmp="$${TMPDIR:-/tmp}/jemacs-pcre2-check-$$$$"; \
+	  printf '%s\n' '#define PCRE2_CODE_UNIT_WIDTH 8' '#include <pcre2.h>' 'int main(void) { return 0; }' > "$$tmp.c"; \
+	  if ! $(CC) $(PCRE2_CHECK_CFLAGS) "$$tmp.c" -o "$$tmp" $(PCRE2_CHECK_LIBS) >/dev/null 2>&1; then \
+	    rm -f "$$tmp.c" "$$tmp"; \
+	    echo "ERROR: PCRE2 development headers/libraries are required for vendor/jerboa-pcre2." >&2; \
+	    echo "Install them first, then rerun make build." >&2; \
+	    echo "  Debian/Ubuntu: sudo apt-get install build-essential pkg-config libpcre2-dev" >&2; \
+	    echo "  Fedora:        sudo dnf install gcc make pkgconf-pkg-config pcre2-devel" >&2; \
+	    echo "  macOS:         brew install pkg-config pcre2" >&2; \
+	    exit 1; \
+	  fi; \
+	  rm -f "$$tmp.c" "$$tmp"
+
+deps: check-pcre2-system-deps vendor-deps
 	$(MAKE) -C $(JSH_ROOT) vendor-deps
 	$(MAKE) -C $(JERBOA) build
 	$(MAKE) -C $(JERBOA_PCRE2_ROOT) SCHEME=$(SCHEME) JERBOA_HOME=$(JERBOA) JERBUILD=$(JERBUILD_BIN)
diff --git a/README.md b/README.md
index 37072f2..0cb3b92 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,13 @@ The TUI backend runs in a terminal using Scintilla's text model. The Qt backend 
 | jerboa-shell (jsh) | Shell interpreter | `vendor/jerboa-shell` |
 | jerboa-scintilla | Scintilla editor FFI | `vendor/jerboa-scintilla` |
 | jerboa-pcre2 | PCRE2 regex FFI | `vendor/jerboa-pcre2` |
+| PCRE2 development headers | Native regex library | system |
+
+On Debian/Ubuntu, install the native build prerequisites with:
+
+```bash
+sudo apt-get install build-essential pkg-config libpcre2-dev
+```
 
 ### Additional (Qt backend)