Add desktop and icon rules to Makefile, document icon installation (#80)

Co-authored-by: NRK <nrk@disroot.org>
This commit is contained in:
Guilherme Rugai Freire 2021-09-22 23:17:52 -03:00 committed by GitHub
parent 9e22f32c07
commit de9a285ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 16 deletions

View File

@ -17,6 +17,9 @@ AUTORELOAD = inotify
# CFLAGS, any optimization flags goes here # CFLAGS, any optimization flags goes here
CFLAGS ?= -std=c99 -Wall -pedantic CFLAGS ?= -std=c99 -Wall -pedantic
# icons that will be installed via `make icon`
ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
ifeq ($(HAVE_LIBEXIF), 1) ifeq ($(HAVE_LIBEXIF), 1)
OPTIONAL_LIBS += -lexif OPTIONAL_LIBS += -lexif
else else
@ -37,7 +40,7 @@ LDLIBS = -lImlib2 -lX11 -lXft -lfontconfig $(OPTIONAL_LIBS)
OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \ OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \
thumbs.o util.o window.o thumbs.o util.o window.o
.PHONY: all clean install uninstall .PHONY: all clean install uninstall icon
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .c .o .SUFFIXES: .c .o
@ -78,6 +81,27 @@ version.h: Makefile .git/index
clean: clean:
$(RM) *.o nsxiv $(RM) *.o nsxiv
desktop:
@echo "INSTALL nsxiv.desktop"
mkdir -p $(DESTDIR)$(PREFIX)/share/applications
cp nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications
icon:
@echo "INSTALL icon"
for f in $(ICONS); do \
dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
mkdir -p "$$dir"; \
cp "icon/$$f" "$$dir/nsxiv.png"; \
chmod 644 "$$dir/nsxiv.png"; \
done
icon_cleanup:
@echo "REMOVE icon"
for f in $(ICONS); do \
dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
rm -f "$$dir/nsxiv.png"; \
done
install: all install: all
@echo "INSTALL bin/nsxiv" @echo "INSTALL bin/nsxiv"
install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv
@ -89,11 +113,13 @@ install: all
@echo "INSTALL share/nsxiv/" @echo "INSTALL share/nsxiv/"
install -Dt $(DESTDIR)$(DOCPREFIX)/examples examples/* install -Dt $(DESTDIR)$(DOCPREFIX)/examples examples/*
uninstall: uninstall: icon_cleanup
@echo "REMOVE bin/nsxiv" @echo "REMOVE bin/nsxiv"
rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv
@echo "REMOVE nsxiv.1" @echo "REMOVE nsxiv.1"
rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1
@echo "REMOVE nsxiv.desktop"
rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop
@echo "REMOVE share/nsxiv/" @echo "REMOVE share/nsxiv/"
rm -rf $(DESTDIR)$(DOCPREFIX) rm -rf $(DESTDIR)$(DOCPREFIX)

View File

@ -79,9 +79,19 @@ Installing nsxiv:
# make install # make install
Please note, that this requires root privileges. Installing desktop entry:
# make desktop
Installing icons:
# make icon
Please note, that these requires root privileges.
By default, nsxiv is installed using the prefix "/usr/local", so the full path By default, nsxiv is installed using the prefix "/usr/local", so the full path
of the executable will be "/usr/local/bin/nsxiv". of the executable will be "/usr/local/bin/nsxiv", the `.desktop` entry will be
"/usr/local/share/applications/nsxiv.desktop" and the icon path will be
"/usr/local/share/icons/hicolor/{size}/apps/nsxiv.png".
You can install nsxiv into a directory of your choice by changing this command to: You can install nsxiv into a directory of your choice by changing this command to:

View File

@ -1,12 +0,0 @@
PREFIX = /usr/local
ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
all:
install:
for f in $(ICONS); do \
dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
mkdir -p "$$dir"; \
cp "$$f" "$$dir/nsxiv.png"; \
chmod 644 "$$dir/nsxiv.png"; \
done