# File: Makefile for keyboard-leds-trayicons # Location: keyboard-leds-trayicons source package # Author: bgstack15 # Startdate: 2020-03-17 # Title: Makefile for keyboard-leds-trayicons source package # Purpose: To use traditional Unix make utility # History: # Usage: # Reference: # https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile/26339924#26339924 # https://stackoverflow.com/questions/19105241/how-do-you-conditionally-call-a-target-based-on-a-target-variable-makefile/19107231#19107231 # https://stackoverflow.com/questions/5917576/sort-a-text-file-by-line-length-including-spaces # https://superuser.com/questions/352289/bash-scripting-test-for-empty-directory/667100#667100 # bgscripts and logout-manager Makefile # Improve: # Document: # Includes a nice way to dynamically generate dependencies as self-reported by all the files. # Dependencies: APPNAME = keyboard-leds-trayicons APPVERSION = 0.0.2 SRCDIR = $(CURDIR) prefix = /usr SYSCONFDIR = $(DESTDIR)/etc BINDIR = $(DESTDIR)$(prefix)/bin SHAREDIR = $(DESTDIR)$(prefix)/share DOCDIR = $(SHAREDIR)/doc/${APPNAME} MANDIR = $(SHAREDIR)/man APPSDIR = $(SHAREDIR)/applications ICONDIR = $(SHAREDIR)/icons SYSCONFDIR = $(DESTDIR)/etc XDGAUTODIR = $(SYSCONFDIR)/xdg/autostart awkbin :=$(shell which awk) cpbin :=$(shell which cp) echobin :=$(shell which echo) findbin :=$(shell which find) grepbin :=$(shell which grep) installbin :=$(shell which install) lnbin :=$(shell which ln) rmbin :=$(shell which rm) sedbin :=$(shell which sed) sortbin :=$(shell which sort) trbin :=$(shell which tr) truebin :=$(shell which true) uniqbin :=$(shell which uniq) xargsbin :=$(shell which xargs) md2manbin :=$(shell which go-md2man) gzipbin :=$(shell which gzip) SEPARATOR ?=, all: ${echobin} "No compilation in this package." .PHONY: clean install uninstall list deplist deplist_opts list: @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' deplist: @if test -z "$(DISTRO)" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." ; exit 1 ; fi @${grepbin} -h --exclude='Makefile' --exclude-dir='doc' -A5 -riIE dependencies $(SRCDIR) | ${awkbin} -v 'distro=$(DISTRO)' 'tolower($$0) ~ distro {$$1="";$$2="";print}' | ${trbin} ',' '\n' | ${sedbin} -r -e 's/^\s*//;' -e 's/\*$$//;' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/$$/$(SEPARATOR)/' | ${xargsbin} deplist_opts: @${echobin} "devuan" 1>&2 install: install_files install_man install_files: @${echobin} Installing files to ${DESTDIR} ${installbin} -d ${SYSCONFDIR} ${BINDIR} ${DOCDIR} \ ${APPSDIR} ${ICONDIR}/hicolor/scalable/status ${XDGAUTODIR} ${installbin} -m 0644 -t ${SYSCONFDIR} ${SRCDIR}/etc/*.* ${installbin} -m 0755 -t ${BINDIR} ${SRCDIR}/usr/bin/* ${installbin} -m 0644 -t ${ICONDIR}/hicolor/scalable/status ${SRCDIR}/usr/share/icons/hicolor/scalable/status/* ${installbin} -m 0644 -t ${XDGAUTODIR} ${SRCDIR}/etc/xdg/autostart/* ${installbin} -m 0644 -t ${APPSDIR} ${SRCDIR}/usr/share/applications/* ${installbin} -m 0644 -t ${DOCDIR} ${SRCDIR}/usr/share/doc/keyboard-leds-trayicons/* install_man: ifeq ($(md2manbin),) @${echobin} Cannot install man pages, because go-md2man is not found. @false endif ${installbin} -d ${MANDIR}/man1 ${MANDIR}/man5 ${md2manbin} < ${SRCDIR}/usr/share/man/man1/keyboard-leds-trayicons.1.md | ${gzipbin} > ${MANDIR}/man1/keyboard-leds-trayicons.1.gz ${md2manbin} < ${SRCDIR}/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md | ${gzipbin} > ${MANDIR}/man5/keyboard-leds-trayicons.conf.5.gz uninstall: @${echobin} SRCDIR=${SRCDIR} ${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" ) $$( ${findbin} ${SRCDIR}/usr/share/man ! -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" -r -e 's/\.md$$/.gz/;' ) # remove all installed directories that are now blank. for word in $$( ${findbin} ${SRCDIR} -mindepth 1 -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" | ${awkbin} '{ print length, $$0 }' | sort -rn | ${awkbin} '{print $$2}' ) ; do ${findbin} $${word} -mindepth 1 1>/dev/null 2>&1 | read 1>/dev/null 2>&1 || { rmdir "$${word}" 2>/dev/null || ${truebin} ; } ; done clean: -${echobin} "target $@ not implemented yet! Gotta say unh."