views:

150

answers:

3

I wanted to create a makefile. So I wrote instructions in a notepad file.
But what extension should I give while saving this file?

+5  A: 

If you run:

make

this program will look for a file named makefile in your directory, and then execute it. If you have several makefiles, then you can execute them with the command:

make -f MyMakefile
berkay
So, to clarify: makefiles normally do not have an extension, not even a dot at the end.
Andrew McGregor
Correct, or you can save with a file extension and point make to it using the -f switch.
Duracell
When I create makefile by notepad, it is saved as text document andwhen I type make on command line, it shows makefile not found.When I create makefile by ed editor, it is saved as file type whichis found by make.
Happy Mittal
are you sure you are working on same directory. simply gedit makefile and paste your code here and run on the shell, make.
berkay
Notepad will generally supply a .txt extension. Notepad is also not the most friendly editor for coding. Editor choice is essentially a religious argument, and there are a lot to choose among. Notepad, however, will appear near the bottom of most people's lists. On Windows, be sure to disable the "feature" that hides file extensions in Explorer to avoid even more confusion.
RBerteig
+1  A: 

From the GNU Make documentation

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

These will be searched for if you don't specify the makefile with the -f flag (Only GNU make will look for GNUMakefile, so give it that name only if you know you're using GNU tools)

Scott Wales
A: 

It sounds like you're running Windows, in which case makefiles often have a .NMK suffix (because they are intended for use with NMAKE). In the civilised world though makefiles do not generally have a suffix: makefile or Makefile are the canonical file names.

Paul R