Skip to content

Conversation

@neilsh
Copy link

@neilsh neilsh commented Jan 21, 2026

This PR modernizes the Onion Makefile with better maintainability, error handling, and cross-platform compatibility.

Changes

Build Reliability

  • Replace bare make with $(MAKE) in 14 places — enables proper flag propagation (--dry-run, --keep-going, -j)
  • Add || exit 1 to shell loops for fail-fast behavior on component build failures
  • Make deepclean resilient to missing git submodules

Cross-Platform Compatibility

  • Use portable sed pattern (temp file) instead of GNU-only sed -i
  • Skip Docker pull on ARM64 Mac when image exists locally (avoids manifest error)
  • Auto-initialize git submodules on first build

Maintainability

  • Extract component lists into variables (alphabetically sorted):
    • CORE_COMPONENTS — 27 core binaries
    • INSTALLER_BINS — 7 installer binaries
    • SIMPLE_APPS — apps that build to BIN_DIR
    • THIRD_PARTY_COMPONENTS — external projects
  • Add explanatory comments throughout

Hygiene

  • Expand .PHONY with all missing targets
  • Add consistent @ prefix for quiet output
  • Clean .d dependency files in addition to .o
  • Quote glob patterns to prevent shell expansion issues
  • Add build timing display at end of dist

Testing

  • Verified make with-toolchain CMD="build" completes successfully
  • Verified make clean and make deepclean work correctly

- Add .submodules target that auto-inits git submodules if missing
- Make .setup and with-toolchain depend on submodules being ready
- Fix docker pull to skip if image exists locally (ARM64 Mac compat)
- Replace bare 'make' with $(MAKE) in 14 places to properly propagate
  flags like --dry-run, --keep-going, etc. to sub-makes
- Add build timing: display elapsed seconds at end of 'dist' target
- Refactor core: target to use CORE_COMPONENTS variable for maintainability
- Add TODO explaining why parallel builds don't work (shared .o files)
- Keep 'with-toolchain' using bare 'make' since $(MAKE) expands to host path
- Use portable sed (temp file) instead of GNU-only 'sed -i'
- Quote glob in clean target to prevent shell expansion issues
- Add print-version to .PHONY declaration
- Extract INSTALLER_BINS variable for DRY installer binary copies
- Expand .PHONY with all missing targets (toolchain, git-submodules, etc.)
- Add error handling to shell loops with '|| exit 1' for fail-fast behavior
- Make deepclean resilient to missing submodules
- Add consistent @ prefix to .docker target and test runner
- Clean .d dependency files in addition to .o files
- Extract variables for maintainability: THIRD_PARTY_COMPONENTS, SIMPLE_APPS
- Sort all component lists alphabetically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant