The difference between .mk file and Makefile

make file can have any name. The -f option of make is used to specify which file to use:

make -f foobar

You can even use -f several times:

make -f foo -f bar

In which case make processes the files in order (or, equivalently, concatenates the files and processes the result).

makefile and Makefile are special names because if make is called without the -f option it automatically searches for them, in this order, and use the first it finds. Note that GNU make also considers GNUmakefile, and prefers it over makefile and Makefile. Other make implementations can have other default names.

The .mk extension is a more or less standard extension for make files that have other names than the defaults. It is a reasonable extension if you want humans to quickly understand what these files are: convert.mk is more informative than foobar. Some editors use this extension to identify the file type and apply syntax coloring. They usually apply the same syntax coloring to makefile and Makefile.

Leave a Comment