You might encounter an error that reads make: *** No targets specified and no makefile found, regardless of whether you’re using Ubuntu, Debian, or Red Hat. Stop.

This is a widespread problem with GNU Make as a whole, so it may appear on many Unix implementations. It denotes that there isn’t a makefile or Makefile file in the working directory where you are currently located. Fortunately, that mistake is simple to correct.

Make: *** No Targets Specified and no Makefile Found. Stop.

Method 1: Finding a Makefile in the Current Directory

To see if you receive the same error, you might want to try running the make command once more in the current directory. This is crucial if you’ve previously attempted to find the correct directory in a new terminal window or if you’ve used the cd command since the last time you attempted to run GNU make.

Try using the ls or dir command to see what files are in your current directory if it runs, assuming that it does. Perhaps you are not in the correct location in the directory tree. You should use the cd command to position yourself in the proper location to execute the make command if you notice that you see directories that belong in your root / directory or your home directory.

There’s a possibility that you’ll end up even farther from your intended location. In our example, we attempted to launch make from the /var/crash directory and discovered that it completely failed. Since the only files in this specific location are from unrelated crash reports, it cannot be expected to run from here.

Most likely, a directory inside of your home directory will be where you want to run the make command from. For instance, if you were constructing the most recent version of GNU nano from source code, you most likely had a directory at /nano-2.9.6 that you could cd to and then issue another make command from.

Before attempting to run make, you might want to run ls again to make sure there is a makefile present in the directory for you to build from.

Keep in mind that the installation must first be configured. The GNU compiler thrives in the ideal environment that the configure command creates. Run./configure while still inside the project directory, followed by the make command, if you can’t find a makefile there either.

If this compiles successfully, you can use sudo make install to install your project. However, keep in mind that you should never use sudo make or any other command outside of installation if you don’t want to build anything as root.

Method 2: Choosing a Custom Makefile

Nothing else needs to be done if that resolved the problem. If the earlier technique failed to solve your issue, there are two additional use cases to take into account. Both of these require creating your own makefile for a project that you’ve been manually configuring.

Using the -f option, you can specify a unique makefile with a name other than the literal makefile. For instance, you could specify a backup makefile by running make -f makefile.bak from the command line if your makefile was called makefile.bak.

If you want to ignore errors in a customised or outdated makefile while the compiler is running, you can replace makefile.bak with any file name at all. This is typically not advised because, if your makefile contains any errors, you’ll probably want to edit it.

The second use case, which is also closely related, involves a circumstance in which case sensitivity is a concern. In the Unix way of doing things, each of the following files is a separate entity:

  • Makefile
  • Makefile
  • MakeFile
  • MakeFile
  • MakefilE

Programs with unique configurations might not be able to identify a makefile with strange capitalization. You should probably rename it makefile if you wrote it by hand for a programming project you’re working on, though you could use the -i option to make sure GNU make can find it. If you’ve written everything correctly, keep in mind that you can still run./configure from within your own project to force it to create the correct environment and prevent this issue from happening in the first place.