๐ ๏ธ How to Use make on Windows#
This guide explains how to install and use make on Windows, with three different options depending on your preference and environment.
โ
Option 1: Use make on Windows via Git Bash#
Git Bash provides a Unix-like shell on Windows. However, it does not include make by default, so you must install it separately.
๐ฆ Step-by-Step: Installing Git Bash#
-
Download Git for Windows:
๐ https://gitforwindows.org -
Install Git and ensure that Git Bash is included in the installation.
-
Open Git Bash in your project folder by right-clicking and selecting "Git Bash Here".
-
Now follow Option 3 (below) to install
makeinside Git Bash via MSYS2.
โ Option 2: Install GNU Make via Chocolatey#
This method allows you to use make directly in PowerShell or Command Prompt.
Prerequisites#
Before installing GNU Make via Chocolatey, ensure you have Chocolatey package manager installed on your Windows system.
To check if Chocolatey is installed: Open PowerShell as Administrator and run:
choco --version
If Chocolatey is not installed:
- Open PowerShell as Administrator
-
Run the following command to install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -
Close and reopen PowerShell as Administrator
Installing GNU Make#
-
Open PowerShell or Command Prompt as Administrator
Press
Win + Xand select "Windows PowerShell (Admin)" or "Command Prompt (Admin)" -
Install GNU Make using Chocolatey
choco install make -
Confirm the installation
When prompted, type
yoryesto proceed with the installation. -
Verify the installation
-
After installation completes, verify that
makeis available:make --versionYou should see output similar to:
GNU Make 4.x.x Built for Windows32
Usage#
Once installed, you can use make commands directly in any PowerShell or Command Prompt window:
# Navigate to your project directory
cd path\to\your\project
# Run make commands
make
make build
make clean
Troubleshooting#
If make command is not recognized:
1. Close and reopen your terminal
2. Check if the installation path is in your system PATH environment variable
3. Try running refreshenv in PowerShell to refresh environment variables
To uninstall:
choco uninstall make
โ
Option 3: Manually Add make to Git Bash via MSYS2#
MSYS2 provides a full Unix toolchain for Windows, including make.
๐ฆ Step-by-Step: Installing make using MSYS2#
-
Download MSYS2 from:
-
Install MSYS2 (default path:
C:\msys64). -
Open the "MSYS2 MSYS" terminal (not UCRT64 or MINGW64).
-
Update the package manager:
bash pacman -Syu๐ If prompted, close the terminal and re-open it after updating.
-
Install
make:bash pacman -S make -
Verify installation:
bash make --version
โ๏ธ Add make to System PATH (Optional but Recommended)#
To use make in Git Bash (or any terminal), you must add it to your system's PATH:
-
Find the path to
make, usually:C:\msys64\usr\bin -
Open System Properties โ Environment Variables.
-
Under "User variables" or "System variables", find the
Pathvariable and click Edit. -
Add the path:
C:\msys64\usr\bin -
Click OK and restart Git Bash or your system.
-
Test in Git Bash:
bash make --version
โ Example Usage#
Once make is installed, you can run:
make fmt
From within your project folder, assuming you have a Makefile with a fmt target.
๐ Alternative: Bash Script Instead of Makefile#
If you prefer not to install make, create a simple Bash script:
format.sh
#!/bin/bash
isort config-cli-gui/
black -l 100 config-cli-gui/
black -l 100 tests/
Make it executable:
chmod +x format.sh
./format.sh
๐ Summary#
| Option | Description | Difficulty |
|---|---|---|
| Git Bash | Use make in Unix-like shell |
Easy |
| Chocolatey | Use make in PowerShell or CMD |
Medium |
| MSYS2 | Full Unix toolchain for Windows | Easy |
Choose the option that best fits your workflow!