1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-12-04 14:46:29 -05:00

Makefile

This commit is contained in:
makeworld 2020-09-02 11:05:14 -04:00
parent f8899fc382
commit 038df04648
3 changed files with 58 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# Binaries
amfora
amfora.exe
amfora-*
build
dist

46
Makefile Normal file
View File

@ -0,0 +1,46 @@
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 ./...

View File

@ -27,7 +27,7 @@ It fully passes Sean Conman's client torture test, including the new Unicode tes
### Binary
Download a binary from the [releases](https://github.com/makeworld-the-better-one/amfora/releases) page. On Unix-based systems you might have to make the file executable with `chmod +x <filename>`. You should also move the binary to `/usr/local/bin/`.
Download a binary from the [releases](https://github.com/makeworld-the-better-one/amfora/releases) page. On Unix-based systems you might have to make the file executable with `chmod +x <filename>`. You rename the file to just `amfora` for easy access, and move it to `/usr/local/bin/`.
On Windows, make sure you click "Advanced > Run anyway" after double-clicking, or something like that.
@ -59,17 +59,19 @@ brew upgrade amfora
### From Source
This section is for programmers who want to install from source. Make sure you're using Go 1.13 at least, as earlier versions will fail to build.
Install latest release:
The recommended way of installing Amfora fom source is using the Makefile. Note that this requires GNU Make, so use the `gmake` (not `make`) command on macOS. You may have to install it with `brew install make`. On Windows, you can install [Chocolatey](https://chocolatey.org/install) and run `choco install make`.
This is not designed to work on Windows.
```
go env -w GO111MODULE=on
go get github.com/makeworld-the-better-one/amfora
git clone https://github.com/makeworld-the-better-one/amfora
cd amfora
make
sudo make install # Not for Windows!
sudo make desktop # Optional, installs .desktop file
```
Install latest commit:
```
go env -w GO111MODULE=on
go get github.com/makeworld-the-better-one/amfora@master
```
Because you installed with the Makefile, running `amfora -v` will tell you exactly what commit the binary was built from.
## Usage