Determine if Makefile is executed with gmake

廉价感情. 提交于 2019-12-06 04:30:53

问题


Say on FreeBSD an application needs to be compiled with GNU make (gmake), not the standard system make. Is there any directive I could put to the Makefile to stop executing it and print an error if the Makefile is not compiled with gmake?


回答1:


Call your makefile GNUmakefile. GNU Make will find it, but not other makes.

The first name checked, GNUmakefile, is not recommended for most makefiles. You should use this name if you have a makefile that is specific to GNU make, and will not be understood by other versions of make. Other make programs look for makefile and Makefile, but not GNUmakefile.



回答2:


This is an addon to Jack Kelly's answer.

After you have renamed your Makefile to GNUmakefile create Makefile with:

USEGNU=gmake $*
all:
    @$(USEGNU)
.DEFAULT:
    @$(USEGNU)

This will call gmake for you every time you run make.



来源:https://stackoverflow.com/questions/11775109/determine-if-makefile-is-executed-with-gmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!