Skip to content

Commit 49f674a

Browse files
committed
Finalize the GNUmakefile setup
1 parent 128f593 commit 49f674a

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

GNUmakefile

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1-
M := .cache/.makes
2-
$(shell [ -d $M ] || git clone -q https://github.com/makeplus/makes $M)
3-
include $M/init.mk
4-
include $M/go.mk
5-
include $M/ys.mk
1+
# Auto-install https://github.com/makeplus/makes at specific commit:
2+
MAKES := .cache/makes
3+
MAKES-LOCAL := .cache/local
4+
MAKES-COMMIT ?= 74a4d03223cdaf39140613d48d3f1d8c0a0840e5
5+
$(shell [ -d $(MAKES) ] || ( \
6+
git clone -q https://github.com/makeplus/makes $(MAKES) && \
7+
git -C $(MAKES) reset -q --hard $(MAKES-COMMIT)))
8+
ifneq ($(shell git -C $(MAKES) rev-parse HEAD), \
9+
$(shell git -C $(MAKES) rev-parse $(MAKES-COMMIT)))
10+
$(error $(MAKES) is not at the correct commit: $(MAKES-COMMIT))
11+
endif
12+
include $(MAKES)/init.mk
613

7-
# Print Makefile targets summary
8-
default::
14+
# Only auto-install go if no go exists or GO-VERSION specified:
15+
ifeq (,$(shell which go))
16+
GO-VERSION ?= 1.24.0
17+
endif
18+
GO-VERSION-NEEDED := $(GO-VERSION)
919

10-
$(GO-CMDS):: $(GO)
11-
go $@ $A
20+
# Setup and include go.mk and shell.mk:
21+
GO-CMDS-SKIP := test
22+
ifndef GO-VERSION-NEEDED
23+
GO-NO-DEP-GO := true
24+
endif
25+
include $(MAKES)/go.mk
26+
ifdef GO-VERSION-NEEDED
27+
TEST-DEPS += $(GO)
28+
else
29+
SHELL-DEPS := $(filter-out $(GO),$(SHELL-DEPS))
30+
endif
31+
SHELL-NAME := makes go-yaml
32+
include $(MAKES)/shell.mk
1233

13-
ys-test: $(YS)
14-
prove -v test/
34+
v ?=
1535

16-
distclean:
17-
$(RM) -r .cache
36+
37+
# Test rules:
38+
test: $(TEST-DEPS)
39+
go test$(if $v, -v)
40+
41+
42+
# Clean rules:
43+
realclean:
44+
45+
distclean: realclean
46+
$(RM) -r $(ROOT)/.cache

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ b:
168168
## Testing with `make`
169169

170170
Running `make test` in this directory should just work.
171-
You don't need to have `go` installed and even if you do the Makefile will
171+
You don't need to have `go` installed and even if you do the `GNUmakefile` will
172172
ignore it and setup / cache its own version under `.cache/`.
173173

174174
The only things you need are:
@@ -182,7 +182,9 @@ Some `make` commands are:
182182

183183
* `make test`
184184
* `make test GO-VERSION=1.2.34`
185-
* `make distclean` - Remove `.cache/`
185+
* `make shell` Start a shell with the local `go` environment
186+
* `make shell GO-VERSION=1.2.34`
187+
* `make distclean` - Removes `.cache/`
186188

187189

188190
## License

test/test.t

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)