scan-build has little or no knowledge about how you build your code. It works by overriding the CC and CXX environment variables to (hopefully) change your build to use a “fake” compiler instead of the one that would normally build your project.
However, through experimentation, I have found that running scan-build make with a Makefile that contains an explicit assignment CC := <something>, scan-build still works, even though environment variablesdon’t override explicit assignments in Makefiles. Does scan-build have a special case for make that calls make with a CC=…/ccc-analyzer command-line argument?
~/Documents$ bat echo.mk
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: echo.mk
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ CC := echo
2 │ all:
3 │ $(CC) $@
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
~/Documents$ make -f echo.mk
echo all
all
~/Documents$ CC=clang make -f echo.mk
echo all
all
~/Documents$ scan-build make -f echo.mk
scan-build: Using '/nix/store/p2i411dpdfh3nv41fgn77y9cqvbd8bqs-clang-wrapper-14.0.6/bin/clang' for static analysis
/nix/store/76qrr5dksjzljr0vwqwdfycbxx6q39fs-clang-analyzer-14.0.6/bin/../libexec/ccc-analyzer all
clang-14: error: no such file or directory: 'all'
make: *** [echo.mk:3: all] Error 1
scan-build: Analysis run complete.
scan-build: Removing directory '/tmp/scan-build-2023-05-14-023619-329036-1' because it contains no reports.
scan-build: No bugs found.
~/Documents [2]$
I can try to fix this myself but it’s probably also valuable if you phrase it in a way that’s ideal for you as a reader who actually encountered the problem