How can I make use of bash functions in a makefile?

HOW TO -️ October 18, 2021

If I need to use something like NVM in my makefile, I run into a problem, because NVM exports some bash functions that are not available in Make, even if my shell is defined as bash in the makefile.

How do I cause make to "inherit" all the parent shell's functions? Is there a way to make NVM accessible to a makefile, without writing export -f for a zillion little NVM bash functions?


Probably related. indeed. but does not offer a good solution. I can make it work with prepending source ... to every line of my makefile, for example, but clearly that's sub-optimal. Maybe this may worth a word in your question on what you already tried/found and why it doesn't solve your problem, an example Makefile exhibiting the problem could help aslo I think. Btw another source, I'm not working with node.js so that's just in case it may be of help to solve the problem not so much, actually, but I appreciate the help. Let me see if I get right: you're problem is to avoid writing export -f for each nvm function of your parent shell. (if this is the case I assume declare -F | sed 's/declare/export/' > and then a source within the makefile should do.) This probably belongs on StackOverflow as it is not specifically related to DevOps in any way @coderanger I've the feeling SO would redirect to server fault which would redirect to SO. I agree that's 100% programming but I feel it would be badly received on SO or SF/SU I'd say this on-topic at SF, SO, or here. It'd be nice if the OP clarified which functions they want from NVM.