mbake is a Makefile formatter and linter. It only took 50 years!
762
stars
127
commits
Python
primary language
Jul 22, 2026
updated
{XDG_CONFIG_HOME}/bake.toml# Install from PyPI
pip install mbake
# Or install VSCode extension
# Search for "mbake Makefile Formatter" in VSCode Extensions
# Format a Makefile
mbake format Makefile
# Check if formatting is needed (CI/CD mode)
mbake format --check Makefile
# Validate Makefile syntax
mbake validate Makefile
# Initialize configuration
mbake init
# Format files
mbake format Makefile # Format single file
mbake format --check Makefile # Check formatting (CI/CD)
mbake format --diff Makefile # Show changes without modifying
# Validate syntax
mbake validate Makefile # Check Makefile syntax with GNU make
# Configuration
mbake init # Create config file
mbake config # Show current settings
mbake update # Update to latest version
--check: Check formatting without making changes (perfect for CI/CD)--diff: Show what changes would be made--backup: Create backup before formatting--validate: Validate syntax after formatting--timeout: Timeout to use for syntax checks--config: Use custom configuration fileCreate a config file with mbake init. Key settings:
[formatter]
# Spacing and formatting
space_around_assignment = true # CC=gcc to CC = gcc
space_after_colon = true # myapp.o:myapp.c to myapp.o: myapp.c
normalize_line_continuations = true # Clean up backslash continuations
remove_trailing_whitespace = true # Remove trailing spaces
fix_missing_recipe_tabs = true # Convert spaces to tabs in recipes
# Variable alignment
align_variable_assignments = false # Align consecutive assignments
align_across_comments = false # Continue alignment across comments
# .PHONY management
auto_insert_phony_declarations = false # Auto-detect and insert .PHONY
group_phony_declarations = false # Group multiple .PHONY lines
phony_at_top = false # Place .PHONY at file top
mbake intelligently detects phony targets by analyzing recipe commands:
# These are automatically detected as phony
test:
npm test
clean:
rm -f *.o
deploy:
ssh user@server 'systemctl restart app'
# This creates a file, so it's NOT phony
myapp.o: myapp.c
gcc -c myapp.c -o myapp.o
Enable auto-insertion in your config:
[formatter]
auto_insert_phony_declarations = true
# Before: Inconsistent spacing and indentation
CC:=gcc
CFLAGS= -Wall -g
SOURCES=main.c \
utils.c \
helper.c
all: $(TARGET)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f *.o
# After: Clean, consistent formatting
CC := gcc
CFLAGS = -Wall -g
SOURCES = main.c \
utils.c \
helper.c
all: $(TARGET)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f *.o
Use special comments to disable formatting in specific regions:
# bake-format off
CUSTOM_FORMAT= \
1 \
45678 \
#bake-format on
# GitHub Actions example
- name: Check Makefile formatting
run: |
pip install mbake
mbake format --check Makefile
Exit codes: 0 (success), 1 (needs formatting), 2 (error)
Contributions welcome! See CONTRIBUTING.md for details.
# Development setup
git clone https://github.com/ebodshojaei/bake.git
cd mbake
pip install -e ".[dev]"
pytest # Run tests
MIT License - see LICENSE for details.
Python
90.0%
Makefile
5.3%
JavaScript
2.5%
Emacs Lisp
1.2%
mbake is a Makefile formatter and linter. It only took 50 years!
762
stars
127
commits
Python
primary language
Jul 22, 2026
updated
{XDG_CONFIG_HOME}/bake.toml# Install from PyPI
pip install mbake
# Or install VSCode extension
# Search for "mbake Makefile Formatter" in VSCode Extensions
# Format a Makefile
mbake format Makefile
# Check if formatting is needed (CI/CD mode)
mbake format --check Makefile
# Validate Makefile syntax
mbake validate Makefile
# Initialize configuration
mbake init
# Format files
mbake format Makefile # Format single file
mbake format --check Makefile # Check formatting (CI/CD)
mbake format --diff Makefile # Show changes without modifying
# Validate syntax
mbake validate Makefile # Check Makefile syntax with GNU make
# Configuration
mbake init # Create config file
mbake config # Show current settings
mbake update # Update to latest version
--check: Check formatting without making changes (perfect for CI/CD)--diff: Show what changes would be made--backup: Create backup before formatting--validate: Validate syntax after formatting--timeout: Timeout to use for syntax checks--config: Use custom configuration fileCreate a config file with mbake init. Key settings:
[formatter]
# Spacing and formatting
space_around_assignment = true # CC=gcc to CC = gcc
space_after_colon = true # myapp.o:myapp.c to myapp.o: myapp.c
normalize_line_continuations = true # Clean up backslash continuations
remove_trailing_whitespace = true # Remove trailing spaces
fix_missing_recipe_tabs = true # Convert spaces to tabs in recipes
# Variable alignment
align_variable_assignments = false # Align consecutive assignments
align_across_comments = false # Continue alignment across comments
# .PHONY management
auto_insert_phony_declarations = false # Auto-detect and insert .PHONY
group_phony_declarations = false # Group multiple .PHONY lines
phony_at_top = false # Place .PHONY at file top
mbake intelligently detects phony targets by analyzing recipe commands:
# These are automatically detected as phony
test:
npm test
clean:
rm -f *.o
deploy:
ssh user@server 'systemctl restart app'
# This creates a file, so it's NOT phony
myapp.o: myapp.c
gcc -c myapp.c -o myapp.o
Enable auto-insertion in your config:
[formatter]
auto_insert_phony_declarations = true
# Before: Inconsistent spacing and indentation
CC:=gcc
CFLAGS= -Wall -g
SOURCES=main.c \
utils.c \
helper.c
all: $(TARGET)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f *.o
# After: Clean, consistent formatting
CC := gcc
CFLAGS = -Wall -g
SOURCES = main.c \
utils.c \
helper.c
all: $(TARGET)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f *.o
Use special comments to disable formatting in specific regions:
# bake-format off
CUSTOM_FORMAT= \
1 \
45678 \
#bake-format on
# GitHub Actions example
- name: Check Makefile formatting
run: |
pip install mbake
mbake format --check Makefile
Exit codes: 0 (success), 1 (needs formatting), 2 (error)
Contributions welcome! See CONTRIBUTING.md for details.
# Development setup
git clone https://github.com/ebodshojaei/bake.git
cd mbake
pip install -e ".[dev]"
pytest # Run tests
MIT License - see LICENSE for details.
Python
90.0%
Makefile
5.3%
JavaScript
2.5%
Emacs Lisp
1.2%