Back to concepts

Makefile discovery

See how `make` searches for a makefile when no arguments are provided.

When you run make without any arguments, GNU Make must find a makefile to read.

Unless -f or --file names a file, GNU Make searches the current directory for GNUmakefile, makefile, and Makefile, in that order. It reads the first one it finds.

The GNU Make manual recommends Makefile because it appears prominently near files such as README. It reserves GNUmakefile for input specific to GNU Make; other make implementations do not look for that name.

Default makefile search order
1GNUmakefile2makefile3Makefile

Compare missing and empty makefiles

In an empty directory, run make before and after creating an empty Makefile.

step 1/3
interactive replay

Select the terminal to begin, or choose Auto-fill.

See it in context

Follow the lessons that apply this concept, then inspect the repository at the exact commit behind each explanation.

GNU Make manual: What Name to Give Your Makefile