mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-15 23:46:12 +00:00
Update Makefile and add version flag
This commit is contained in:
@@ -1,32 +1,35 @@
|
||||
SHELL := /bin/bash
|
||||
# Installation paths
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
SYSCONFDIR := $(PREFIX)/etc
|
||||
|
||||
ifeq ($(PREFIX),)
|
||||
PREFIX := /usr/local
|
||||
endif
|
||||
ifeq ($(BINDIR),)
|
||||
BINDIR := $(PREFIX)/bin
|
||||
endif
|
||||
ifeq ($(SYSCONFDIR),)
|
||||
SYSCONFDIR := $(PREFIX)/etc
|
||||
endif
|
||||
ifeq ($(GO),)
|
||||
GO := $(shell type -a -P go | head -n 1)
|
||||
endif
|
||||
# Compilers and tools
|
||||
GO ?= go
|
||||
|
||||
# Build-time variables
|
||||
VERSION ?= $(shell git describe --tags --dirty)
|
||||
|
||||
build:
|
||||
mkdir -p build
|
||||
cd src; $(GO) build -ldflags "-w -X 'main.systemConfigDir=$(SYSCONFDIR)'" -o ../build/stormfetch stormfetch
|
||||
cd src; $(GO) build -ldflags "-w -X 'main.StormfetchVersion=$(VERSION)' -X 'main.SystemConfigDir=$(SYSCONFDIR)'" -o ../build/stormfetch stormfetch
|
||||
|
||||
install: build/stormfetch config/
|
||||
mkdir -p $(DESTDIR)$(BINDIR)
|
||||
mkdir -p $(DESTDIR)$(SYSCONFDIR)/stormfetch/
|
||||
cp build/stormfetch $(DESTDIR)$(BINDIR)/stormfetch
|
||||
cp -r config/. $(DESTDIR)$(SYSCONFDIR)/stormfetch/
|
||||
# Create directoriy
|
||||
install -dm755 $(DESTDIR)$(BINDIR)
|
||||
# Install binary
|
||||
install -m755 build/stormfetch $(DESTDIR)$(BINDIR)/stormfetch
|
||||
|
||||
run: build/stormfetch
|
||||
build/stormfetch
|
||||
install-config:
|
||||
# Create directory
|
||||
install -dm755 $(DESTDIR)$(SYSCONFDIR)
|
||||
# Install files
|
||||
cp -r config $(DESTDIR)$(SYSCONFDIR)/stormfetch/
|
||||
|
||||
uninstall:
|
||||
-rm -f $(DESTDIR)$(BINDIR)/stormfetch
|
||||
-rm -rf $(DESTDIR)$(SYSCONFDIR)/stormfetch
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
|
||||
.PHONY: build
|
||||
.PHONY: build install install-config uninstall clean
|
||||
|
||||
Reference in New Issue
Block a user