The extension would be none at all, and the file is called Makefile
(or makefile
) if you want GNU make to find it automatically.
GNU make, at least, lets you rely on certain automatic variables that alone give you control over much of the building process with C/C++ files as input. These variables include CC
, CPP
, CFLAGS
, CPPFLAGS
, CXX
, CXXFLAGS
, and LDFLAGS
. These control the switches to the C/C++ preprocessor, compiler, and the linker (the program that generates what is known as "program executable", or in plainspeak "the program you are compiling") that make
will use.
GNU make also includes a lot of implicit rules designed to enable it automatically build programs from C/C++ source code, so you don't [always] have write your own rules.
For instance, even without a makefile, if you try to run make foobar
, GNU make will attempt to first build foobar.o
from foobar.c
or foobar.cpp
if it finds either, by invoking appropriate compiler, and then will attempt to build foobar
by assembling (incl. linking) its parts from system libraries and foobar.o
. In short, GNU Make knows how to build the foobar
program even without a makefile being present -- thanks to implicit rules. You can see these rules by invoking make
with the -p
switch.
Some people like to rely on GNU make's implicit rule database to have lean and short makefiles where only that specific to their project is specified, while some people may go as far as to disable the entire implicit rule database (using the -r
switch) and have full control of the building process by specifying everything in their makefile(s). I won't comment on the validity of either strategy, but rest assured both do work to some degree.