Migrating from Make
If you’re coming from GNU Make, this guide will help you translate your Makefiles to Jakefiles.
Syntax Changes
Section titled “Syntax Changes”| Make | Jake |
|---|---|
target: deps | task target: [deps] |
$(VAR) | {{VAR}} |
.PHONY: target | task target: (automatic) |
| Tab required | 4 spaces or tab |
$@ (target name) | Use explicit name |
$< (first dep) | Use explicit name |
%.o: %.c | Write explicit rules |
Key Differences
Section titled “Key Differences”No Tab Sensitivity
Section titled “No Tab Sensitivity”Make requires tabs for indentation. Jake accepts either 4 spaces or a tab:
# Both work in Jaketask build: echo "Hello" # 4 spacesNo .PHONY Required
Section titled “No .PHONY Required”In Make, you must declare .PHONY for non-file targets. In Jake, task recipes are always treated as phony:
# This is automatically phony - no declaration neededtask clean: rm -rf dist/Explicit Variable Syntax
Section titled “Explicit Variable Syntax”Make uses $(VAR) with many variants (${VAR}, $@, $<). Jake uses a single, clear syntax:
cc = "gcc"cflags = "-Wall"
task build: {{cc}} {{cflags}} -c main.cDependencies in Brackets
Section titled “Dependencies in Brackets”Make lists dependencies after the colon. Jake uses [brackets] for task dependencies:
# Make: test: build# Jake:task test: [build] cargo testExample Migration
Section titled “Example Migration”Before (Makefile)
Section titled “Before (Makefile)”CC = gccCFLAGS = -Wall -O2
.PHONY: all clean test
all: build test
build: main.o utils.o $(CC) -o app main.o utils.o
%.o: %.c $(CC) $(CFLAGS) -c $<
test: build ./test_runner
clean: rm -f *.o appAfter (Jakefile)
Section titled “After (Jakefile)”cc = "gcc"cflags = "-Wall -O2"
@defaulttask all: [build, test] echo "Done"
file app: main.o utils.o {{cc}} -o app main.o utils.o
file main.o: main.c {{cc}} {{cflags}} -c main.c -o main.o
file utils.o: utils.c {{cc}} {{cflags}} -c utils.c -o utils.o
task test: [build] ./test_runner
task clean: rm -f *.o appWhat You Gain
Section titled “What You Gain”Migrating from Make to Jake gives you:
- Readable syntax - No more deciphering
$@and$< - Glob patterns - Use
src/**/*.tsinstead of listing every file - Parameters - Pass arguments to recipes with defaults
- Conditionals -
@if/@elsewithout shell gymnastics - Imports - Organize large projects with namespaced imports
- Better errors - Helpful messages with suggestions
- Watch mode - Built-in file watching with
-w
Migration Tips
Section titled “Migration Tips”- Start with tasks - Convert your
.PHONYtargets totaskrecipes first - Convert file rules - Change pattern rules to explicit
filerecipes - Simplify variables - Replace Make’s variable variants with
{{var}} - Add glob patterns - Use
**/*.cinstead of$(wildcard ...) - Remove workarounds - Delete shell tricks that Jake handles natively
See Also
Section titled “See Also”- File Targets - Learn about
filerecipes - Dependencies - Dependency syntax details
- Variables - Variable expansion