build: improve makefile

pull/143/head
buffet 2022-04-14 13:45:50 +00:00 committed by TorchedSammy
parent 7f161e6683
commit 59e81d3996
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 17 additions and 18 deletions

View File

@ -1,31 +1,30 @@
PREFIX ?= /usr PREFIX ?= /usr
DESTDIR ?=
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/share/hilbish LIBDIR ?= $(PREFIX)/share/hilbish
MY_GOFLAGS = -ldflags "-s -w"
all: dev
dev: MY_GOFLAGS = -ldflags "-s -w -X main.version=$(shell git describe --tags)"
dev: build
build: build:
@go build -ldflags "-s -w" go build $(MY_GOFLAGS)
dev: install: all
@go build -ldflags "-s -w -X main.version=$(shell git describe --tags)" install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
mkdir -p "$(DESTDIR)$(LIBDIR)"
install: cp -r libs docs emmyLuaDocs prelude .hilbishrc.lua "$(DESTDIR)$(LIBDIR)"
@install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish" grep -qxF "$(DESTDIR)$(BINDIR)/hilbish" /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells
@mkdir -p "$(DESTDIR)$(LIBDIR)"
@cp libs docs emmyLuaDocs prelude .hilbishrc.lua "$(DESTDIR)$(LIBDIR)" -r
@grep "$(DESTDIR)$(BINDIR)/hilbish" -qxF /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells
@echo "Hilbish Installed"
uninstall: uninstall:
@rm -vrf \ rm -vrf \
"$(DESTDIR)$(BINDIR)/hilbish" \ "$(DESTDIR)$(BINDIR)/hilbish" \
"$(DESTDIR)$(LIBDIR)" "$(DESTDIR)$(LIBDIR)"
@sed -i '/hilbish/d' /etc/shells sed -i '/hilbish/d' /etc/shells
@echo "Hilbish Uninstalled"
clean: clean:
@go clean go clean
all: build install .PHONY: all dev build install uninstall clean
.PHONY: install uninstall build dev clean