• PowerShell 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-14 23:04:29 +02:00
docs Added --print-make-variable option. 2026-06-14 23:04:29 +02:00
tests Added --print-make-variable option. 2026-06-14 23:04:29 +02:00
.gitignore Initial commit 2026-04-09 09:25:30 +02:00
.gitlab-ci.yml Corrected make.ps1 to deal with powershell on MS-Windows; updated documentation. 2026-04-09 11:52:24 +02:00
AGENTS.md Updated documentation. 2026-04-09 11:24:36 +02:00
CLAUDE.md Updated documentation. 2026-04-09 11:24:36 +02:00
LICENSE Added AGPL-3 L 2026-04-09 09:30:02 +02:00
make.ps1 Added --print-make-variable option. 2026-06-14 23:04:29 +02:00
README.md Added --print-make-variable option. 2026-06-14 23:04:29 +02:00

psmake

psmake is a PowerShell implementation of make intended to process Makefiles on Microsoft Windows when make is not available, not installable, or blocked by local administration policies.

The goal is not to reproduce 100% of GNU make. The goal is to support a practical, well-documented subset that is useful on real projects and maintainable over time.

Status

Current entrypoint:

powershell.exe -File .\make.ps1

If PowerShell 7 is installed, pwsh also works.

Current scope includes:

  • explicit targets and dependency traversal
  • single-stem pattern rules with %
  • variable assignment with :=, ?=, and =
  • conditionals: ifeq, ifneq, ifdef, ifndef, else, endif
  • built-ins used by the supported subset: wildcard, sort, shell, if
  • automatic variables: $@, $<, $^, $*
  • recursive $(MAKE) calls
  • .PHONY, .DELETE_ON_ERROR, .SECONDEXPANSION
  • order-only prerequisites with |

Why This Exists

Many Makefiles are shell-heavy and GNU-make-like, but the execution environment may be PowerShell-first, especially on Windows. This project provides a PowerShell-native driver while still running Makefile recipes through a POSIX shell when possible.

Quick Start

Run the default target:

powershell.exe -File .\make.ps1

Run a specific target:

powershell.exe -File .\make.ps1 test

Use a specific Makefile:

powershell.exe -File .\make.ps1 -f Makefile test

Change directory first:

powershell.exe -File .\make.ps1 -C docs pdf

Override make variables from the command line:

powershell.exe -File .\make.ps1 CAD=--bricscad test

Inspect a make variable after parsing:

powershell.exe -File .\make.ps1 --print-make-variable MAKE

Shell Execution

Although psmake is written in PowerShell, recipes are intentionally executed with a POSIX shell whenever one is available, because the supported Makefiles rely heavily on shell syntax.

Shell resolution order:

  1. PSMAKE_BASH
  2. MAKE_BASH
  3. on Windows, known TortoiseGit / Git for Windows bash.exe locations
  4. bash or sh from PATH
  5. the current PowerShell host (powershell.exe or pwsh) as fallback

For recursive $(MAKE) execution, Windows intentionally prefers powershell.exe so that recursive builds still work even when pwsh is not installed or not reachable from bash.

Windows / TortoiseGit

If TortoiseGit is installed, psmake will try:

C:\Program Files\TortoiseGit\bin\bash.exe

You can also force an explicit shell:

$env:PSMAKE_BASH = 'C:\Program Files\TortoiseGit\bin\bash.exe'
powershell.exe -File .\make.ps1 test

PowerShell Script Restrictions

On some Windows machines, script execution may be blocked by policy. In that case, the most useful invocation forms are:

powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File .\make.ps1 test

If PowerShell 7 is installed, this also works:

pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File .\make.ps1 test

If you only want to relax the policy for the current shell session:

Set-ExecutionPolicy -Scope Process Bypass
powershell.exe -File .\make.ps1 test

These options are especially useful on systems where installing GNU make or changing machine-wide policy is not possible.

Repository Layout

Supported GNU make Subset

Implemented today:

  • comments and blank lines
  • trailing \ line continuations
  • :=, ?=, =
  • $(...) and ${...}
  • substitution refs such as $(VAR:.a=.b) and $(VAR:%.a=dir/%.b)
  • explicit rules
  • single-stem pattern rules
  • tab-indented recipes
  • order-only prerequisites
  • basic freshness checks for file targets

Not supported yet:

  • include, -include, sinclude
  • define / endef
  • target-specific variables
  • static pattern rules
  • parallel execution
  • full GNU make function parity

Running Tests

powershell.exe -File .\tests\run-tests.ps1

The fixture suite covers:

  • variable expansion
  • pattern rules
  • conditionals
  • recursive $(MAKE)
  • second expansion
  • .DELETE_ON_ERROR

Design Principle

Compatibility work should be driven by practical Makefile usage, not by abstract GNU make completeness. When a new feature is needed, the preferred workflow is:

  1. reproduce the requirement with a focused fixture
  2. implement the smallest compatible change
  3. document the behavior
  4. keep the regression test

Copying

This project is distributed under the GNU Affero General Public License, version 3.

You may copy, modify, and redistribute it under the terms of the license in LICENSE. If you run a modified version for users over a network, AGPL-3 also requires making the corresponding source available to those users.