Installing Make
Summary: in this tutorial, you will learn install gnu make on linux, macos, and windows. verify your installation, configure your editor, and set up a working environment for makefile development.
Installing Make
Before writing your first Makefile, you need GNU Make installed on your system. The good news is that Make comes pre-installed on most Linux systems and macOS. This tutorial covers installation on all major platforms and setting up your editor.
What you'll learn in this tutorial:
- How to check if Make is already installed on your system
- How to install Make on Linux, macOS, and Windows
- How to configure your code editor for Makefile development
- The critical "tabs vs spaces" rule that trips up every beginner
- How to verify your installation with a test Makefile
Check If Make Is Already Installed
Open a terminal and run:
make --versionIf you see output like this, Make is already installed and you can skip ahead to the "Editor Setup" section:
GNU Make 4.3
Built for x86_64-pc-linux-gnu
If you get "command not found" or a similar error, follow the installation instructions for your operating system below.
Installing on Linux
Ubuntu / Debian
sudo apt update
sudo apt install makeWhat do these commands do?
sudoruns the command as an administrator (it will ask for your password)apt updaterefreshes the list of available software packagesapt install makedownloads and installs Make
For the full C/C++ development toolchain (includes the gcc compiler, make, and other useful build tools):
sudo apt install build-essentialFedora / RHEL / CentOS
sudo dnf install makeOr for the full development toolchain:
sudo dnf groupinstall "Development Tools"Arch Linux
sudo pacman -S makeOr for the full base development package:
sudo pacman -S base-develInstalling on macOS
Using Xcode Command Line Tools (Recommended)
macOS doesn't ship with Make by default, but it's included in the Xcode Command Line Tools:
xcode-select --installA dialog box will appear asking you to install the tools. Click "Install" and wait for the download to complete. This also installs a C compiler and other useful developer tools.
Using Homebrew
If you use Homebrew (a popular package manager for macOS):
brew install makeHeads up: Homebrew installs GNU Make as gmake (not make) to avoid conflicting with the Apple-provided version. If you want to use the make command to run GNU Make, add an alias to your shell:
echo 'alias make="gmake"' >> ~/.zshrc
source ~/.zshrcWhat does this do? It tells your shell: "When I type make, actually run gmake." The >> ~/.zshrc part appends this instruction to your shell's configuration file, and source reloads it.
Installing on Windows
Using WSL (Recommended)
WSL (Windows Subsystem for Linux) gives you a full Linux environment inside Windows. This is the best way to use Make on Windows because Make was designed for Unix-like systems.
Step 1: Open PowerShell as Administrator and run:
wsl --installStep 2: Restart your computer when prompted.
Step 3: Open the WSL terminal (search for "Ubuntu" in the Start menu) and set up your Linux username and password.
Step 4: Install Make inside WSL:
sudo apt update
sudo apt install build-essentialNow you can use make inside the WSL terminal just like on a native Linux system.
Using Chocolatey
If you prefer to use Make directly in Windows (without WSL):
choco install makeWhat is Chocolatey? Chocolatey is a package manager for Windows — similar to apt on Linux or brew on macOS. If you don't have it installed, visit chocolatey.org for installation instructions.
Using MSYS2
MSYS2 provides a Unix-like environment on Windows:
Step 1: Download and install MSYS2 from msys2.org
Step 2: Open the MSYS2 terminal and run:
pacman -S makeUsing Git Bash
If you have Git for Windows installed, you already have Git Bash — a minimal Unix-like terminal. However, Make isn't included by default. The easiest approach is to use Chocolatey or WSL instead.
Verify Your Installation
After installing, verify Make is working correctly:
make --versionYou should see something like:
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
The exact version number may differ, but anything 3.81 or above will work for all our tutorials.
Editor Setup
VS Code (Recommended)
VS Code has excellent Makefile support with extensions:
Step 1: Open VS Code
Step 2: Go to the Extensions panel (click the square icon on the sidebar, or press Ctrl+Shift+X)
Step 3: Search for "Makefile Tools" by Microsoft and install it
This extension provides syntax highlighting (colors for different parts of the Makefile), IntelliSense (auto-completion suggestions), and build task integration.
Step 4 (Important!): Configure VS Code to use tabs for Makefiles. Open your settings file (Ctrl+Shift+P → "Preferences: Open User Settings (JSON)") and add:
{
"[makefile]": {
"editor.insertSpaces": false,
"editor.tabSize": 4,
"editor.detectIndentation": false
}
}This tells VS Code: "When editing a Makefile, use real tab characters instead of spaces." This is critical — we'll explain why in the next section.
Vim / Neovim
Vim has built-in Makefile syntax highlighting — no additional setup needed. Vim also automatically uses tabs for Makefiles through its filetype detection.
Sublime Text
Install the Makefile Improved package through Package Control for better syntax highlighting.
The Tab Requirement (Read This!)
This is the number one source of Makefile errors for beginners:
Makefile recipes MUST be indented with tab characters, not spaces! This is not a suggestion or a convention — it's a strict requirement of the Make syntax. If you use spaces instead of tabs, Make will give you a confusing error and refuse to run.
If you see this error:
Makefile:3: *** missing separator. Stop.
It almost always means you used spaces instead of a tab character for the recipe indentation. Here's what correct and incorrect look like:
# CORRECT — indented with a tab
hello:
echo "This works!"
# WRONG — indented with spaces (looks the same but will fail!)
hello:
echo "This will cause an error"They look identical on screen, but the first uses a tab character and the second uses spaces. Your editor needs to be configured to insert tabs when editing Makefiles (see the Editor Setup section above).
How to Check If Your File Uses Tabs
You can check if your Makefile uses tabs with this command:
cat -A MakefileTab characters show as ^I:
hello: hello.c
^Igcc hello.c -o hello
If you see spaces instead of ^I before the command, your editor is inserting spaces and you need to change the setting.
Create a Test Makefile
Let's verify everything works with a minimal test. Create a new directory and a Makefile:
mkdir make-test
cd make-testCreate a file named Makefile (with a capital M, no file extension) with this content:
hello:
echo "Hello from Make!"Remember: The echo line must start with a tab character, not spaces! If your editor is configured correctly (from the setup above), pressing the Tab key should insert an actual tab.
Now run it:
makeYou should see:
echo "Hello from Make!"
Hello from Make!
Why are there two lines of output? Make prints the command it's about to run (the echo ... line) and then the actual output of that command (Hello from Make!). We'll learn how to suppress the command echo in the next tutorial.
If this works, your Make installation is ready! Clean up the test directory:
cd ..
rm -rf make-testSummary
You should now have GNU Make installed and working:
- Linux: Install with your package manager —
sudo apt install build-essential(Ubuntu/Debian),sudo dnf install make(Fedora), orsudo pacman -S make(Arch) - macOS: Install with
xcode-select --installorbrew install make - Windows: Use WSL (recommended), Chocolatey, or MSYS2
- Editor: Configure your editor to use tabs (not spaces) for Makefiles — this is critical
- Verify: Run
make --versionto confirm the installation
In the next tutorial, you'll write your first real Makefile with targets, prerequisites, and recipes.
Installation Verification
Complete these steps to confirm your setup:
- Run
make --versionand note the version number - Create a test directory with a simple Makefile
- Run
makeand verify it produces output - Confirm your editor is configured to use tabs for Makefiles
Show Solution
Step 1: Run make --version — you should see something like GNU Make 4.3 or a similar version number (3.81+).
Step 2: Create a test:
mkdir test-make && cd test-makeCreate a file called Makefile with this content (use a tab before echo):
test:
echo "Make is working!"Step 3: Run make — you should see:
echo "Make is working!"
Make is working!
Step 4: In VS Code, open Settings → search for "makefile" → make sure "Editor: Insert Spaces" is unchecked for the Makefile language. Or add the [makefile] settings block from the Editor Setup section to your settings.json.
Clean up when done:
cd ..
rm -rf test-makeWritten by the ShellRAG Team
The ShellRAG editorial team writes practical, beginner-friendly Makefile tutorials with tested code examples and real-world use cases. Every article is technically reviewed for accuracy and updated regularly.
Learn more about us →