makefile extension

后端 未结 8 1093
遥遥无期
遥遥无期 2021-02-08 09:29

I\'m writing a C program using gcc in cygwin. My question is, how do you create a makefile? I mean, what file-extension does it have? I know how to write simple rules, but I can

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 10:09

    As you are using Cygwin which in turn means that you are using GNU make, I cite the relevant portion of the GNU make manual:

    3.2 What Name to Give Your Makefile

    By default, when make looks for the makefile, it tries the following names, in order: GNUmakefile, makefile and Makefile. Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) 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.

    [...]

    If you want to use a nonstandard name for your makefile, you can specify the makefile name with the ‘-f’ or ‘--file’ option. The arguments ‘-f name’ or ‘--file=name’ tell make to read the file name as the makefile. If you use more than one ‘-f’ or ‘--file’ option, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names GNUmakefile, makefile and Makefile are not checked automatically if you specify ‘-f’ or ‘--file’.

提交回复
热议问题