9 ms·
If you're using GNU-specific Make features, please, please consider naming the file GNUmakefile instead of Makefile and use $(MAKE) for recursion. GNU make will
by sirn 7y ago
If you're using GNU-specific Make features, please, please consider naming the file GNUmakefile instead of Makefile and use $(MAKE) for recursion. GNU make will happily pick up GNUmakefile before Makefile, and using $(MAKE) will remove a lot of headaches when people try to build your project outside of author's $PREFERRED_PLATFORM.
- swiley 7y agoDo you have a good guide for writing portable makefiles? I’m always using GNU make so I don’t notice it with mine but I always feel a little bad.
- sirn 7y agoI don't think there's a guide, the only resource I'm aware of is The Open Group Base Specifications[1] which can be reference when in doubt. Almost other times I just install bmake alongside with gmake and try to get it work with both (it's still not perfectly conform to POSIX, since GNU supports some of BSD's make feature, and vice versa). [1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/m...
- gumby 7y agoI'm a big fan of "be strictly conformant" (e.g. use no C++ extensions) for maximum portability but I always install Bash and GNU Make. The extra power is worth it.
- nipav 7y agoThe best way is reading the spec: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/m... But to get you started Chris Wellons does have a pretty nice blog post about writing POSIX Makefiles: https://nullprogram.com/blog/2017/08/20/ https://nullprogram.com/blog/2017/08/20/
- asveikau 7y agoI use the *BSDs a lot and it's pretty common to install gmake from ports. I wouldn't feel bad.
- kazinator 7y agoThe POSIX standard? https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/m... If you don't use anything that is not there, or in a manner not covered by a requirement, you will likely have a highly portable result.
- pmarin 7y agoThere is a very good tutorial by Chris Wellons https://nullprogram.com/blog/2017/08/20/ https://nullprogram.com/blog/2017/08/20/
- nullifidian 7y agoDoes somebody even use other make implementations anymore? I think such suggestions aren't relevant nowadays. Same goes for bash. Posix compatibility is overrated.
- zingermc 7y agoIt's still 100% relevant. I can only speak for FreeBSD, but this is a real pain when building from source (outside of FreeBSD Ports). https://www.freebsd.org/cgi/man.cgi?make(1) https://www.freebsd.org/cgi/man.cgi?make(1)
- nullifidian 7y agoinstalling gnu make on FreeBSD is not hard. Other unixes such as AIX and Solaris are super obscure now, and gnu make also works there.
- rcthompson 7y agoInstalling GNU Make is not the problem. It's knowing which Make to invoke. If you use GNUMakefile, it's unambiguous.
- nullifidian 7y agoIt's simple, you make gnu make the default one and the problem is solved.
- codetrotter 7y agoYou definitely do not want to make GNU Make the default on a system that ships with another implementation of Make, because then you break other builds. The solution, like the other people were saying, is to name the makefile as GNUmakefile if it is using GNU Make specific features.
- 7y ago