Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makefile extension

Tags:

c

makefile

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't save a file in the text-editor with the right extension? Impossible to find any info about this... This is prolly a super-newbie question. So let the flaming begin. :-P

like image 490
The Opposite of Garbage Avatar asked Oct 18 '10 19:10

The Opposite of Garbage


People also ask

How do I use Makefile extension?

Activating the extensionUpdate Makefile Path by going to File > Preferences > Settings and then selecting makefile under Extensions. After updating Makefile Path, type “makefile” into the Command Palette and run a Makefile Tools command to activate the extension.

Is Makefile a text file?

A makefile is a text file that contains instructions for how to compile and link (or build) a set of source code files. A program (often called a make program) reads the makefile and invokes a compiler, linker, and possibly other programs to make an executable file.

How do I open Makefile?

Open a Makefile projectSelect File | Open from the main menu. In the dialog that opens, click Open as Project. Cleaning is required for the project load as the Make build is incremental and only the updated files are compiled.

How do I run a Makefile in Vscode?

If your installation of make is not available in the default path, you can configure it in VS Code at File > Preferences > Settings > Extensions makefile. To compile and link the project, you can add a Makefile to the root of the project folder. It will be detected automatically by the extension.


1 Answers

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’.

like image 153
Peter G. Avatar answered Sep 20 '22 11:09

Peter G.