1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-11-03 02:37:23 -05:00
amfora/Makefile

55 lines
1.4 KiB
Makefile
Raw Normal View History

GIT_EXISTS := $(shell git status > /dev/null 2>&1 ; echo $$?)
ifeq ($(GIT_EXISTS), 0)
ifeq ($(shell git tag --points-at HEAD),)
# Not currently on a tag
VERSION := $(shell git describe --tags | sed 's/^v//; s/-.*/-next/') # 1.2.3-next
else
# On a tag
VERSION := $(shell git tag --points-at HEAD)
endif
COMMIT := $(shell git rev-parse --verify HEAD)
2020-09-02 11:05:14 -04:00
endif
ROOT_INSTALL := install -o root -g 0
2020-09-02 11:05:14 -04:00
INSTALL_DIR := /usr/local/bin
DESKTOP_DIR := ~/.local/share/applications/
2020-09-02 11:05:14 -04:00
.PHONY: all build install desktop clean uninstall fmt
all: build
build:
ifneq ($(GIT_EXISTS), 0)
# No Git repo
$(error No Git repo was found, which is needed to compile the commit and version)
endif
2020-09-02 11:05:14 -04:00
@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)"
@$(ROOT_INSTALL) -m 755 amfora $(INSTALL_DIR)
2020-09-02 11:05:14 -04:00
desktop:
@echo "Setting up desktop file"
@install -m 644 amfora.desktop $(DESKTOP_DIR)
2020-09-02 11:05:14 -04:00
@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 ./...