edgeboxctl/Makefile

55 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

.DEFAULT_GOAL := build
2021-02-11 21:21:22 +01:00
PROJECT ?= github.com/edgebox-iot/edgeboxctl
2021-02-11 21:21:22 +01:00
RELEASE ?= dev
COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_DIR = bin
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
2021-02-11 21:21:22 +01:00
2023-11-19 22:33:54 +01:00
build-all: clean
2021-02-11 21:21:22 +01:00
GOOS=linux GOARCH=amd64 make build
GOOS=linux GOARCH=arm make build
2023-11-19 22:33:54 +01:00
GOOS=linux GOARCH=arm64 make build
2021-02-11 21:21:22 +01:00
build:
@echo "Building ${GOOS}-${GOARCH}"
GOOS=${GOOS} GOARCH=${GOARCH} go build \
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \
2021-03-04 13:48:25 +01:00
-o bin/edgeboxctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/edgeboxctl
2021-02-11 21:21:22 +01:00
clean:
2021-02-11 21:45:08 +01:00
rm -rf ${BUILD_DIR}
2021-02-11 21:21:22 +01:00
go clean
2021-06-08 14:13:22 +02:00
test:
go test -tags=unit -timeout=600s -v ./...
test-with-coverage:
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
install:
sudo systemctl stop edgeboxctl || true
sudo rm -rf /usr/local/bin/edgeboxctl /usr/local/sbin/edgeboctl /lib/systemd/system/edgeboxctl.service
2023-11-19 21:46:11 +01:00
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/bin/edgeboxctl
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/sbin/edgeboxctl
sudo cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service
sudo systemctl daemon-reload
@echo "Edgeboxctl installed successfully"
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
2023-11-19 22:33:54 +01:00
build-install: build install
start:
systemctl start edgeboxctl
stop:
systemctl stop edgeboxctl
log: start
journalctl -fu edgeboxctl