Fix: No targets specified and no makefile found.

Whether you’re working with Ubuntu, Debian or Red Hat, you might see an error that reads make: *** No targets specified and no makefile found. Stop. Since this is a general issue related to GNU Make as a whole, you might see it on countless Unix implementations. It means that there isn’t a file called makefile or Makefile in your current working directory. Fortunately, that’s an easy error to fix.

Method 1: Finding a Makefile in the Current Directory

You may wish to try running the make command one more time in the current directory to see if the same error gets thrown at you. This is especially important if you’ve opened a new terminal window and already tried to locate the right directory or if you’ve used the cd command since the last time that you tried to run GNU make.

Assuming that it does, try running the ls or dir command to see what files are in your current directory. You might not be in the right part of the directory tree. If you notice that you see directories that belong in your root / directory or your home ~ directory, then you’ll want to run the cd command to position yourself in the right place to run the make command.

There’s a chance you might find yourself even further afield from where you’re expected to be. In our example, we tried running make from the /var/crash directory and found it didn’t work at all. It can’t be expected to run from here, as the only files in this particular location are from unrelated crash reports.

More than likely, you’re going to want to run your make command from a directory that’s located somewhere inside of your home directory. For instance, if you were building the latest version of GNU nano from source then you’d probably have a directory located at ~/nano-2.9.6 that you could cd to and then run make again. You might want to try running ls once more before you try to make to ensure that there’s a makefile located within the directory for you to build from.

Keep in mind that you’ll need to have configured the installation first. The configure command creates the perfect environment for the GNU compiler to flourish.  If you’re not finding a makefile even in the correct project directory, then run ./configure while you’re still inside of it followed by the make command. If this compiles correctly, then you can install your project with sudo make install, but remember that you don’t want to build anything as root so you’ll never want to run sudo make or anything else outside of installation.

Method 2: Specifying a Custom Makefile

Assuming that fixed the issue, there’s nothing more you need to do. However, there are two special use cases to consider if the previous method didn’t correct your problem. These both involve writing your own makefile for a project that you’ve been configuring by hand.

You can specify a  custom makefile that’s called something other than literally makefile by using the -f option. For instance, if you had a backup makefile called makefile.bak then you might specify it by running make -f makefile.bak from the command line. You may replace makefile.bak with any file name at all and you could include the -i option if you wanted to ignore errors in a custom or outdated makefile while the compiler is running. This usually isn’t recommended, since you’ll probably want to edit your makefile if there’s anything wrong with it.

The other very closely related use case involves a situation where case sensitivity is an issue. The following are all separate files in the Unix way of doing business:

  • Makefile
  • makefile
  • makeFile
  • MakeFile
  • MakefilE

Custom configured programs might not be able to recognize a makefile with odd capitalization. If you’ve handwritten it for a coding project you’re working on, then you’ll probably want to rename it makefile though you could use the -i option to ensure that GNU make is capable of finding it. Remember that if you’ve written everything correctly, then you can still run ./configure from your own project to force it to generate the right environment and avoid this problem, to begin with.

Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Expert Tip

Fix: No targets specified and no makefile found.

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested