Support include directives
It seems that default checkmake does not follow include directives; it would be nice if it did to get a comprehensive review of distributed Makefile setups; for example:
##
# Global Makefile
#
# Do not edit this file directly. Please refer to the `.config/make` directory for managing, adding, or removing
# targets. File order matters for Make, so it is important that all files in this directory are appropriately named, as
# they will be loaded in alphabetical-order.
#
-include $(addsuffix /*.mak, $(shell find .config/make -type d))
https://www.gnu.org/software/make/manual/html_node/Include.html
this is interesting. I think it would be easy(-ish) to make work with static includes (where the filename to include is given directly). Given checkmake is more of a linter/static analyzer and doesn't execute any Makefiles, having these types of dynamic includes likely won't ever work (just to set expectations). But it should be easy to have a workaround for that in your project where you do something like:
for mkfile in $(find .config/make -type f -name '*.mak'); do checkmake ${mkfile} ; done
Thanks, @mrtazz! That's more or less exactly what I did by adding this configuration to my .megalinter.yml configuration:
MAKEFILE_CHECKMAKE_FILE_EXTENSIONS:
- .mak
That said, unfortunately checkmake treats every file as a separate and individual Makefile - so instead of getting one error saying I'm missing my all phony target, I now get eight!
I may go down the route of looking into concatenating them together and piping them into checkmake like that, but that's quickly going down a route that's complex on my side. Maybe that's an option the checker can add a flag for? So instead of treating each file as a separate one, it treats them as one big file by concatenating them together prior to checking? Something like this:
checkmake <(for mkfile in $(find .config/make -type f -name '*.mak'); do cat ${mkfile}; done)
(Don't quote me on the accuracy of that command... I haven't tested it)