Somehow bear did not work on my setup. Here is an alternative that collects the build log and use compiledb to generate compile_commands.json
First generate the build log by tracing executed commands
gmake SHELL='sh -x' 2>&1 | tee make.txtNow we parse the build log: