Compiling software from source code in Linux using the GNU make utility is a fundamental system administration and development skill. However, running the make command inside a newly extracted project archive or cloned Git repository can immediately terminate with a terminal error: make: *** No targets specified and no makefile found. Stop. This error signifies that GNU Make scanned your current working directory for build instruction files—such as Makefile or makefile—and found none, leaving the utility with zero compilation directives.
Why Does make Report ‘No Makefile Found’?
GNU Make does not generate software builds on its own; it requires a structured configuration file called a Makefile that defines build targets, compiler flags, and source dependencies. The error arises due to:
- Missing Pre-Compilation Configuration Step: Attempting to run
makebefore executing./configureor generating the build configuration file. - Modern CMake or Meson Build Systems: The project relying on modern build meta-generators (such as CMake, Meson, or QMake) that do not store pre-built Makefiles in the root source tree.
- Incorrect Current Working Directory: Executing
makein a parent directory or subfolder that does not contain the actual project build file. - Case-Sensitivity and Custom Makefile Naming: The Makefile being named using non-standard naming conventions (such as
Makefile.in,Makefile.am, orbuild.mk) that GNU Make does not parse automatically without specific flags. - Unextracted or Incomplete Project Repositories: Submodules missing from a freshly cloned Git repository.
Step 1: Check Current Directory and Inspect Existing Build Files
Verify whether a Makefile exists or if an alternate build configuration script is present.
- Confirm your current path:
pwd - List all files in the directory, checking for build scripts:
ls -la - Look for files such as
configure,CMakeLists.txt,meson.build,Makefile.in, orautogen.sh. - If no build files exist, ensure you have navigated (
cd) into the specific unpacked source directory where the codebase resides.
Step 2: Generate the Makefile via ./configure
In standard GNU Autotools projects, the Makefile is dynamically generated based on your system’s hardware architecture and installed development libraries.
- If a file named
configureis present in the directory, run it first:./configure - The configure script checks for required compilers (such as
gcc,g++) and dependencies, then automatically outputs a verifiedMakefilein the directory. - Once the script prints
config.status: creating Makefile, run:make - Compilation will commence without throwing target errors.
Step 3: Generate the Makefile Using CMake
Projects utilizing CMake must generate Makefiles through CMake’s configuration pass.
- If you observe a file named
CMakeLists.txt, install CMake:sudo apt install -y cmake build-essential - Create a clean out-of-source build directory:
mkdir -p build && cd build - Instruct CMake to generate native Makefiles:
cmake .. - CMake will inspect dependencies and generate a complete, optimized
Makefileinside thebuild/directory. - Now invoke make:
(Themake -j$(nproc)-j$(nproc)flag compiles across all available CPU cores for maximum speed).
Step 4: Specify Custom Makefile Names with the -f Flag
If the developer used an explicit or alternate filename for the build directives, point GNU Make directly to it.
- If your directory contains files named
Makefile.linux,Makefile.unix, orGNUmakefile: - Pass the
-fflag followed by the exact filename:make -f Makefile.linux - This overrides default filename lookups and reads the build rules immediately.
Step 5: Clone Git Submodules for Complex Repositories
If the source code was cloned from GitHub, third-party build components may reside in unpopulated submodules.
- In the root of the Git repository, pull all required submodule trees:
git submodule update --init --recursive - Once submodules populate, review the project’s
README.mdto follow the developer’s exact build pipeline.