From 1a9327bf225082c7ae04a1cd4f7cff883be05c33 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 4 Mar 2026 20:17:14 +0100 Subject: [PATCH] Enhance FUSE detection for non-standard locations Multi-stage detection strategy: 1. Try pkg-config (fastest, most reliable) 2. Search common header locations: - /usr/include, /usr/local/include - /opt/local/include, /opt/include 3. Compiler test as last resort: - Attempts to preprocess #include - Tests both FUSE 3 and FUSE 2 versions This handles: - Minimal CI/CD environments (no pkg-config) - Non-standard install locations (Homebrew, custom builds) - Distro-specific paths (BSD, macOS, custom Linux) The compiler test ensures detection works even when headers are in unusual locations that gcc can find via its search paths. --- detect_fuse.sh | 54 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/detect_fuse.sh b/detect_fuse.sh index 07d8e9c..a73e16f 100755 --- a/detect_fuse.sh +++ b/detect_fuse.sh @@ -2,25 +2,47 @@ # Detect FUSE version and set appropriate flags # Check if pkg-config is available -if ! command -v pkg-config >/dev/null 2>&1; then - # Fallback: check for header files - if [ -f /usr/include/fuse3/fuse.h ] || [ -f /usr/local/include/fuse3/fuse.h ]; then +if command -v pkg-config >/dev/null 2>&1; then + # Use pkg-config if available + if pkg-config --exists fuse3 2>/dev/null; then echo "FUSE3" - elif [ -f /usr/include/fuse/fuse.h ] || [ -f /usr/local/include/fuse/fuse.h ]; then + exit 0 + elif pkg-config --exists fuse 2>/dev/null; then echo "FUSE2" - else - echo "NONE" - exit 1 + exit 0 fi - exit 0 fi -# Use pkg-config if available -if pkg-config --exists fuse3 2>/dev/null; then - echo "FUSE3" -elif pkg-config --exists fuse 2>/dev/null; then - echo "FUSE2" -else - echo "NONE" - exit 1 +# Fallback: search for header files in common locations +SEARCH_PATHS="/usr/include /usr/local/include /opt/local/include /opt/include" + +for base in $SEARCH_PATHS; do + if [ -f "$base/fuse3/fuse.h" ]; then + echo "FUSE3" + exit 0 + fi +done + +for base in $SEARCH_PATHS; do + if [ -f "$base/fuse/fuse.h" ]; then + echo "FUSE2" + exit 0 + fi +done + +# Last resort: try to compile a test program +if command -v gcc >/dev/null 2>&1; then + # Try FUSE 3 + if echo '#include ' | gcc -E -DFUSE_USE_VERSION=30 - >/dev/null 2>&1; then + echo "FUSE3" + exit 0 + fi + # Try FUSE 2 + if echo '#include ' | gcc -E -DFUSE_USE_VERSION=26 - >/dev/null 2>&1; then + echo "FUSE2" + exit 0 + fi fi + +echo "NONE" +exit 1