2023-11-19 21:33:18 +01:00
|
|
|
.DEFAULT_GOAL := build
|
2021-02-11 21:21:22 +01:00
|
|
|
|
2023-11-19 21:33:18 +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
|
2023-11-19 21:33:18 +01:00
|
|
|
GOOS := $(shell go env GOOS)
|
|
|
|
GOARCH := $(shell go env GOARCH)
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
|
|
|
build-all:
|
|
|
|
GOOS=linux GOARCH=amd64 make build
|
2021-02-12 18:22:03 +01:00
|
|
|
GOOS=linux GOARCH=arm make build
|
2021-02-11 21:21:22 +01:00
|
|
|
|
2021-03-04 13:43:49 +01:00
|
|
|
build-prod:
|
2021-03-04 15:06:48 +01:00
|
|
|
GOOS=linux GOARCH=arm RELEASE=prod make build
|
2021-03-04 13:43:49 +01:00
|
|
|
|
2022-02-06 15:37:50 +01:00
|
|
|
build-cloud:
|
|
|
|
GOOS=linux GOARCH=amd64 RELEASE=cloud make build
|
|
|
|
|
2023-04-17 20:28:06 +02:00
|
|
|
build-arm64:
|
|
|
|
GOOS=linux GOARCH=arm64 RELEASE=prod make build
|
|
|
|
|
|
|
|
build-armhf:
|
|
|
|
GOOS=linux GOARCH=arm RELEASE=prod make build
|
|
|
|
|
2023-11-05 11:47:42 +01:00
|
|
|
build-amd64:
|
|
|
|
GOOS=linux GOARCH=amd64 RELEASE=prod 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 ./...
|
2021-06-08 22:40:53 +02:00
|
|
|
|
|
|
|
test-with-coverage:
|
|
|
|
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
|
2023-03-11 13:58:54 +01:00
|
|
|
|
2023-06-10 17:29:54 +02:00
|
|
|
install:
|
2023-11-05 12:19:09 +01:00
|
|
|
sudo systemctl stop edgeboxctl || true
|
2023-10-28 18:43:18 +02:00
|
|
|
sudo rm -rf /usr/local/bin/edgeboxctl /usr/local/sbin/edgeboctl /lib/systemd/system/edgeboxctl.service
|
2023-03-20 00:54:42 +01:00
|
|
|
sudo cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl
|
2023-10-28 18:43:18 +02:00
|
|
|
sudo cp ./bin/edgeboxctl /usr/local/sbin/edgeboxctl
|
2023-03-20 00:54:42 +01:00
|
|
|
sudo cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service
|
|
|
|
sudo systemctl daemon-reload
|
2023-03-11 13:58:54 +01:00
|
|
|
@echo "Edgeboxctl installed successfully"
|
2023-06-10 17:29:54 +02:00
|
|
|
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
|
|
|
|
|
|
|
|
install-prod: build-prod install
|
|
|
|
install-cloud: build-cloud install
|
|
|
|
install-arm64: build-arm64 install
|
|
|
|
install-armhf: build-armhf install
|
2023-11-05 11:47:42 +01:00
|
|
|
install-amd64: build-amd64 install
|
2023-06-10 17:29:54 +02:00
|
|
|
|
|
|
|
start:
|
|
|
|
systemctl start edgeboxctl
|
|
|
|
|
|
|
|
stop:
|
|
|
|
systemctl stop edgeboxctl
|
|
|
|
|
|
|
|
log: start
|
|
|
|
journalctl -fu edgeboxctl
|