build: refactor makefile to be gnu compatible
All checks were successful
build and upload / build (push) Successful in 15s
All checks were successful
build and upload / build (push) Successful in 15s
This commit is contained in:
62
Makefile
62
Makefile
@@ -1,42 +1,42 @@
|
||||
ifeq ($(CARGO_PKG_VERSION),)
|
||||
CARGO_PKG_VERSION := 0.0.0
|
||||
endif
|
||||
SHELL := /bin/sh
|
||||
|
||||
ifeq ($(APP_NAME),)
|
||||
APP_NAME := feddy
|
||||
endif
|
||||
PROJECT ?= $(shell grep "^name =" Cargo.toml | cut -d '"' -f 2)
|
||||
VERSION ?= $(shell grep "^version =" Cargo.toml | cut -d '"' -f 2)
|
||||
|
||||
build: clean
|
||||
-include Makefile.config
|
||||
|
||||
INSTALL ?= install
|
||||
INSTALL_PROGRAM ?= $(INSTALL) -m 755
|
||||
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||
|
||||
.PHONY: build format rpm install uninstall
|
||||
|
||||
build:
|
||||
cargo build --release
|
||||
./target/release/$(APP_NAME) --generate=bash > completions.bash
|
||||
./target/release/$(APP_NAME) --generate=zsh > completions.zsh
|
||||
./target/release/$(APP_NAME) --generate=fish > completions.fish
|
||||
|
||||
clean:
|
||||
rm -f completions.bash
|
||||
rm -f completions.zsh
|
||||
rm -f completions.fish
|
||||
|
||||
format:
|
||||
cargo fmt --all
|
||||
|
||||
# PREFIX is environment variable, but if it is not set, then set default value
|
||||
ifeq ($(PREFIX),)
|
||||
PREFIX := /usr/local
|
||||
endif
|
||||
rpm:
|
||||
rm -rf $(HOME)/rpmbuild
|
||||
rpmdev-setuptree
|
||||
tar -czf $(HOME)/rpmbuild/SOURCES/$(PROJECT)-$(VERSION).tar.gz \
|
||||
--transform "s|^|$(PROJECT)-$(VERSION)/|" \
|
||||
data \
|
||||
src \
|
||||
Cargo.toml \
|
||||
Cargo.lock \
|
||||
configure \
|
||||
Makefile \
|
||||
README.md \
|
||||
LICENSE
|
||||
|
||||
cp $(PROJECT).spec $(HOME)/rpmbuild/SPECS/$(PROJECT).spec
|
||||
rpmbuild -ba $(HOME)/rpmbuild/SPECS/$(PROJECT).spec
|
||||
|
||||
install:
|
||||
install -d $(PREFIX)/bin/
|
||||
install -m 755 target/release/$(APP_NAME) $(PREFIX)/bin/
|
||||
install -d /usr/share/bash-completion/completions/
|
||||
install -m 644 completions.bash /usr/share/bash-completion/completions/$(APP_NAME)
|
||||
install -d /usr/share/zsh/site-functions/
|
||||
install -m 644 completions.zsh /usr/share/zsh/site-functions/_$(APP_NAME)
|
||||
install -d /usr/share/fish/vendor_completions.d/
|
||||
install -m 644 completions.fish /usr/share/fish/vendor_completions.d/$(APP_NAME).fish
|
||||
$(INSTALL) -d $(DESTDIR)$(bindir)
|
||||
$(INSTALL_PROGRAM) target/release/$(PROJECT) $(DESTDIR)$(bindir)/$(PROJECT)
|
||||
|
||||
uninstall:
|
||||
rm -f $(PREFIX)/bin/$(APP_NAME)
|
||||
rm -f /usr/share/bash-completion/completions/$(APP_NAME)
|
||||
rm -f /usr/share/zsh/site-functions/_$(APP_NAME)
|
||||
rm -f /usr/share/fish/vendor_completions.d/$(APP_NAME).fish
|
||||
rm -f $(DESTDIR)$(bindir)/$(PROJECT)
|
||||
Reference in New Issue
Block a user