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 <fuse.h>
   - 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.
This commit is contained in:
Levi Neely 2026-03-04 20:17:14 +01:00
parent 071f5aec85
commit 1a9327bf22
1 changed files with 38 additions and 16 deletions

View File

@ -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 <fuse.h>' | gcc -E -DFUSE_USE_VERSION=30 - >/dev/null 2>&1; then
echo "FUSE3"
exit 0
fi
# Try FUSE 2
if echo '#include <fuse.h>' | gcc -E -DFUSE_USE_VERSION=26 - >/dev/null 2>&1; then
echo "FUSE2"
exit 0
fi
fi
echo "NONE"
exit 1