Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support include directives #97

Open
andrewvaughan opened this issue Oct 9, 2023 · 2 comments
Open

Support include directives #97

andrewvaughan opened this issue Oct 9, 2023 · 2 comments

Comments

@andrewvaughan
Copy link

andrewvaughan commented Oct 9, 2023

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

@mrtazz
Copy link
Owner

mrtazz commented Oct 10, 2023

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

@andrewvaughan
Copy link
Author

andrewvaughan commented Oct 10, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants