How to turn makefile into JSON Compilation Database?

c++, clang, compilation, compilation-database, makefile

Solution

I have no personal experience with it but Bear seems to be targeted to your scenario. (It was linked from the clang-modernize site.)

Problem

Say we have `make` files (not cmake/premake/ninja etc) for our project that do work for gcc and clang. We want to generate out from them JSON Compilation Database to feed it into `clang-modernize` tool. How to do such thing? (is there any parser in clang infrastructure or some script with usage like `make CC='cc_args.py gcc' CXX='cc_args.py g++'` or some other tool)?

Original source