Makefile file extension

I am writing a C program using gcc in cygwin. My question is: how do you create a makefile? I mean, what is its file extension? I know how to write simple rules, but I can’t save the file in a text editor with the correct extension? Unable to find information about this ... This is a super-newbie question. So let's start flaming. :-P

+7
c makefile
source share
8 answers

Since you are using Cygwin, which in turn means that you are using GNU make, I quote the relevant part of the GNU manual :

3.2. What is the name of the Makefile?

By default, when make searches for a makefile, it tries to execute the following names, in order: GNUmakefile, makefile, and Makefile. Usually you should call your makefile either makefile or Makefile. (We recommend a Makefile because it looks noticeably near the top of the directory listing, next to other important files, such as README.) First name verified, GNUmakefile is not recommended for most make files. You should use this name if you have a makefile that is specifically for GNU make, and that is not understood by other versions of make. Other make make programs make make make and Makefile, but not the GNUmakefile.

[...]

If you want to use a custom name for your makefile, you can specify the name of the makefile using '-f or' --file. The arguments "-f name" or "--file = name" indicate to read the file name as makefile. If you use more than one -f or -file option, you can specify multiple Makefiles. All makefiles are effectively combined in the specified order. The default file names are makefiles. GNUmakefile, makefile and Makefile are not checked automatically if you specify '-f or' --file.

+11
source share

Default filename for makefile Makefile ; this is the name that GNU Make looks for when you start it without any parameters. The -f argument allows you to specify an alternative file name, if required.

+8
source share

Usually they are called Makefile or Makefile . No extension. This is just an agreement.

It is not trivial to write a make file, look for a manual or tutorial =)

+1
source share

In the few places where I saw the extensions used in makefile names, they were usually either .make or .gmk , and even then these extensions are usually reserved for makefile fragments that are included in the main files if one of the default names .

+1
source share

Open your favorite text editor and create a file called Makefile .

The contents may vary, but provided that you have a program called hello.c very simple and easy to compile, it can be:

 hello: hello.c gcc -Wall hello.c -o hello.exe 

After that, you run run from the cygwin shell:

 $ ls hello.c Makefile $ make .... 

And your Makefile will try to compile hello.c . If everything goes as expected, you can run the hello.exe program by running the following shell command:

 $ ./hello.exe 

Here is a good tutorial on Makefiles .

0
source share

A file is usually called a Makefile .

0
source share

You can call them anything you like, but ".mak" looks right.

... google ... http://msdn.microsoft.com/en-us/library/aa380049%28VS.85%29.aspx ... yes

0
source share

Makefiles usually do not have an extension. They are usually called a "makefile" or a "makefile". Sometimes, when someone writes a complex set of makefiles that include each other, the included files get the .mak extension to indicate that they are makefiles, even if they are not called makefiles.

0
source share

All Articles