Skip to content

Commit 0c277dc

Browse files
committed
build: add make targets for build test and install
1 parent d6afb2f commit 0c277dc

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
SHELL := /bin/sh
2+
3+
GO ?= go
4+
BINARY ?= flare-edge-cli
5+
PACKAGE ?= ./cmd/flare-edge-cli
6+
BINDIR ?= bin
7+
BUILD_OUTPUT := $(BINDIR)/$(BINARY)
8+
9+
# Prefer standard user-local bin directories and fall back to ~/.local/bin.
10+
INSTALL_DIR ?= $(shell \
11+
if [ -n "$$XDG_BIN_HOME" ]; then \
12+
printf '%s\n' "$$XDG_BIN_HOME"; \
13+
elif [ -d "$$HOME/.local/bin" ]; then \
14+
printf '%s\n' "$$HOME/.local/bin"; \
15+
elif [ -d "$$HOME/bin" ]; then \
16+
printf '%s\n' "$$HOME/bin"; \
17+
else \
18+
printf '%s\n' "$$HOME/.local/bin"; \
19+
fi)
20+
21+
.PHONY: build test install
22+
23+
build:
24+
@mkdir -p "$(BINDIR)"
25+
$(GO) build -o "$(BUILD_OUTPUT)" $(PACKAGE)
26+
27+
test:
28+
$(GO) test ./...
29+
30+
install: build
31+
@mkdir -p "$(INSTALL_DIR)"
32+
install -m 0755 "$(BUILD_OUTPUT)" "$(INSTALL_DIR)/$(BINARY)"
33+
@printf 'Installed %s to %s\n' "$(BINARY)" "$(INSTALL_DIR)"

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,18 @@ The implementation is intentionally biased toward agent use:
7474
Build the binary from the repository root:
7575

7676
```bash
77-
go build
77+
make build
7878
```
7979

80-
That produces a local `./flare-edge-cli` binary.
80+
That produces a local `./bin/flare-edge-cli` binary.
81+
82+
Install it into a user-local bin directory:
83+
84+
```bash
85+
make install
86+
```
87+
88+
The install target prefers `XDG_BIN_HOME` when set, then an existing `~/.local/bin`, then `~/bin`, and otherwise creates `~/.local/bin`. You can override the destination explicitly with `make install INSTALL_DIR=/path/to/bin`.
8189

8290
You can also run it directly during development:
8391

@@ -465,6 +473,9 @@ Attach a route or custom domain:
465473
Useful local commands:
466474

467475
```bash
476+
make build
477+
make test
478+
make install
468479
go test ./...
469480
go vet ./...
470481
go test -race ./...

0 commit comments

Comments
 (0)