Skip to content

Add general purpose GNUmakefile #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2025
Merged

Add general purpose GNUmakefile #38

merged 5 commits into from
Jul 9, 2025

Conversation

ingydotnet
Copy link
Member

@ingydotnet ingydotnet commented Jun 8, 2025

This GNUmakefile auto-installs (unless go is installed already) go locally in .cache/local/go-<version>/bin/go and uses that for all make commands.
We use the name GNUmakefile instead of Makefile because that will prevent people from using a non-GNU make command to run make commands.

This doesn't prevent anyone from doing things using their normal style but it adds the following benefits for everyone:

  • make test just works in almost any environment
  • You can clone the repo and run make test without needing anything installed (except make, curl and bash).
  • Test with any go version using: make test GO-VERSION=1.23.4
  • To get a shell with a particular go version installed and ready: make shell GO-VERSION=1.23.4

@Copilot Copilot AI review requested due to automatic review settings June 8, 2025 21:37
Copilot

This comment was marked as outdated.

@ingydotnet ingydotnet marked this pull request as draft June 20, 2025 13:06
@ingydotnet
Copy link
Member Author

This should work out for anyone on Linux / Mac if they have git, bash, curl and make installed. (minimal)
It self-installs the Makefile parts and then self-installs Go and sets the environment to run it, without affecting the user's system in any other way.

Example output of the self-installing make commands:

$ make distclean
rm -f -r .cache
$ 
$ make test
Installing 'go' locally
curl -Ls https://go.dev/dl/go1.24.3.linux-amd64.tar.gz > /home/ingy/src/go-yaml/.cache/.local/cache/go1.24.3.linux-amd64.tar.gz
tar -C /home/ingy/src/go-yaml/.cache/.local -xzf /home/ingy/src/go-yaml/.cache/.local/cache/go1.24.3.linux-amd64.tar.gz
mv /home/ingy/src/go-yaml/.cache/.local/go /home/ingy/src/go-yaml/.cache/.local/go-1.24.3
touch /home/ingy/src/go-yaml/.cache/.local/go-1.24.3/bin/go

go test 
OK: 50 passed
PASS
ok  	go.yaml.in/yaml/v3	2.236s
$ 
$ make test
go test 
OK: 50 passed
PASS
ok  	go.yaml.in/yaml/v3	2.245s
$ 

@ingydotnet
Copy link
Member Author

I need to finish the work for macOS, then I'll take it out of draft.

This Makefile ignores system Go and installs go locally in
`.git/.local/go-<version>/bin/go` and uses that for all make commands.

make <go-cmd>
make test
make test GO-VERSION=1.23.4

You can clone the repo and run `make test` without needing anything
installed (except make, curl and bash).
@ingydotnet ingydotnet marked this pull request as ready for review July 7, 2025 20:43
@ingydotnet
Copy link
Member Author

This is working well on Linux and Mac now.

Ready for review.

@ingydotnet ingydotnet requested review from ccoVeille, Copilot, dims, carloslima, scottrigby and stefanprodan and removed request for ccoVeille July 7, 2025 20:44
Copilot

This comment was marked as outdated.

@ingydotnet
Copy link
Member Author

Had to remove a file. Ready for real now.

@ingydotnet ingydotnet requested review from ccoVeille and Copilot July 7, 2025 20:59
Copilot

This comment was marked as resolved.

@ingydotnet
Copy link
Member Author

ingydotnet commented Jul 8, 2025

Updated and ready for review. Added support for make test v=1. Only installs local go is no go is installed or GO-VERSION=... is used.

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ingydotnet ingydotnet requested review from robertsirc and ccoVeille and removed request for ccoVeille July 8, 2025 14:53
@ingydotnet ingydotnet requested a review from ccoVeille July 8, 2025 17:46
@ingydotnet ingydotnet merged commit 49f674a into main Jul 9, 2025
8 checks passed
@ingydotnet ingydotnet deleted the makefile branch July 9, 2025 00:09
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.

4 participants