mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
47 lines
1.2 KiB
Makefile
47 lines
1.2 KiB
Makefile
|
ifeq ($(shell git tag --points-at HEAD),)
|
||
|
# Not currently on a tag
|
||
|
VERSION := $(shell git describe --tags | sed 's/-.*/-next/') # v1.2.3-next
|
||
|
else
|
||
|
# On a tag
|
||
|
VERSION := $(shell git tag --points-at HEAD)
|
||
|
endif
|
||
|
|
||
|
COMMIT := $(shell git rev-parse --verify HEAD)
|
||
|
|
||
|
INSTALL := install -o root -g root
|
||
|
INSTALL_DIR := /usr/local/bin
|
||
|
DESKTOP_DIR := /usr/share/applications
|
||
|
|
||
|
.PHONY: all build install desktop clean uninstall fmt
|
||
|
|
||
|
all: build
|
||
|
|
||
|
build:
|
||
|
@echo "Downloading dependencies"
|
||
|
@go env -w GO111MODULE=on ; go mod download
|
||
|
@echo "Building binary"
|
||
|
@go env -w GO111MODULE=on CGO_ENABLED=0 ; go build -ldflags="-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.builtBy=Makefile"
|
||
|
|
||
|
install:
|
||
|
@echo "Installing Amfora to $(INSTALL_DIR)"
|
||
|
@$(INSTALL) -m 755 amfora $(INSTALL_DIR)
|
||
|
|
||
|
desktop:
|
||
|
@echo "Setting up desktop file"
|
||
|
@$(INSTALL) -m 644 amfora.desktop $(DESKTOP_DIR)
|
||
|
@update-desktop-database $(DESKTOP_DIR)
|
||
|
|
||
|
clean:
|
||
|
@echo "Removing Amfora binary in local directory"
|
||
|
@$(RM) amfora
|
||
|
|
||
|
uninstall:
|
||
|
@echo "Removing Amfora from $(INSTALL_DIR)"
|
||
|
@$(RM) $(INSTALL_DIR)/amfora
|
||
|
@echo "Removing desktop file"
|
||
|
-@$(RM) $(DESKTOP_DIR)/amfora.desktop
|
||
|
-@update-desktop-database $(DESKTOP_DIR)
|
||
|
|
||
|
fmt:
|
||
|
go fmt ./...
|