epee-service/Makefile

60 lines
1.7 KiB
Makefile
Raw Normal View History

2023-03-19 15:07:40 +01:00
EXTENSION ?=
DIST_DIR ?= dist/
GOOS ?= linux
ARCH ?= $(shell uname -m)
BUILDINFOSDET ?=
2023-03-21 16:22:45 +01:00
GOARCH = $(shell echo $(ARCH) | sed 's/x86_64/amd64/g')
2023-03-19 15:07:40 +01:00
SOFT_NAME := epee_service
SOFT_VERSION := $(shell git describe --tags $(git rev-list --tags --max-count=1))
VERSION_PKG := $(shell echo $(SOFT_VERSION) | sed 's/^v//g')
ARCH := x86_64
LICENSE := AGPL-3
URL := https://git.gnous.eu/enpls/epee-service
DESCRIPTION := EnPLS Epee (Enpls Proxy EnginE) Utility Service
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
LDFLAGS := '-X main.version=$(SOFT_VERSION) -X main.buildinfos=$(BUILDINFOS)'
2023-03-21 16:22:45 +01:00
GOARCH := amd64
2023-03-19 15:09:44 +01:00
OUTPUT_SOFT := $(DIST_DIR)epee-$(SOFT_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
2023-03-19 15:07:40 +01:00
.PHONY: vet
vet:
go vet main.go
.PHONY: test
test:
go test -v ./...
.PHONY: prepare
prepare:
mkdir -p $(DIST_DIR)
.PHONY: clean
clean:
rm -rf $(DIST_DIR)
.PHONY: build
build: prepare
2023-03-21 16:22:45 +01:00
@echo Building binary for $(GOOS)/$(GOARCH)
env GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags $(LDFLAGS) -o $(OUTPUT_SOFT)
2023-03-19 15:07:40 +01:00
.PHONY: package-deb
package-deb: prepare
fpm -s dir -t deb -n $(SOFT_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE)" \
--package $(DIST_DIR) \
2023-03-21 16:22:45 +01:00
$(OUTPUT_SOFT)=/usr/bin/epee-service \
extra/epee.service=/usr/lib/systemd/system/epee.service
2023-03-19 15:07:40 +01:00
.PHONY: package-rpm
package-rpm: prepare
fpm -s dir -t rpm -n $(SOFT_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE) "\
--package $(DIST_DIR) \
2023-03-21 16:22:45 +01:00
$(OUTPUT_SOFT)=/usr/bin/epee-service \
extra/epee.service=/usr/lib/systemd/system/epee.service