# File: Makefile for logout-manager # Location: logout-manager source package # Author: bgstack15 # Startdate: 2020-03-10 # Title: Makefile for logout-manager 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 Makefile # Improve: # Document: # Dependencies: APPNAME = logout-manager APPVERSION = 0.0.1 SRCDIR = $(CURDIR) prefix = /usr SYSCONFDIR = $(DESTDIR)/etc DEFAULTDIR = $(DESTDIR)/etc/sysconfig # for debian use '$(DESTDIR)/etc/default' BINDIR = $(DESTDIR)$(prefix)/bin SHAREDIR = $(DESTDIR)$(prefix)/share LIBEXECDIR = $(DESTDIR)$(prefix)/libexec DOCDIR = $(SHAREDIR)/doc/$(APPNAME) APPDIR = $(SHAREDIR)/$(APPNAME) APPSDIR = $(SHAREDIR)/applications awkbin :=$(shell which awk) cpbin :=$(shell which cp) echobin :=$(shell which echo) findbin :=$(shell which find) grepbin :=$(shell which grep) installbin :=$(shell which install) rmbin :=$(shell which rm) sedbin :=$(shell which sed) sortbin :=$(shell which sort) truebin :=$(shell which true) xargsbin :=$(shell which xargs) lnbin :=$(shell which ln) 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' -A5 -riIE dependencies $(SRCDIR) | awk -v 'distro=$(DISTRO)' 'tolower($$0) ~ distro {$$1="";$$2="";print}' | sort | uniq | xargs deplist_opts: @${echobin} "el7" 1>&2 @${echobin} "devuan" 1>&2 install: @${echobin} Installing files to ${DESTDIR} ${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} ${APPSDIR} ${APPDIR} ${DOCDIR} ${cpbin} -pr ${SRCDIR}/etc/*.* ${SYSCONFDIR} ${cpbin} -pr ${SRCDIR}/etc/sysconfig/* ${DEFAULTDIR} ${cpbin} -pr ${SRCDIR}/usr/bin/* ${BINDIR} ${cpbin} -pr ${SRCDIR}/usr/share/applications/* ${APPSDIR} ${cpbin} -pr ${SRCDIR}/usr/share/${APPNAME}/*.* ${APPDIR} ${cpbin} -pr ${SRCDIR}/usr/share/doc/${APPNAME}/* ${DOCDIR} # symlink, when alternatives is not being used ${lnbin} -s logout-manager-gtk.py ${BINDIR}/logout-manager uninstall: @${echobin} SRCDIR=${SRCDIR} ${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" ) ${DEFAULTDIR}/${APPNAME} ${BINDIR}/logout-manager # absolute minimum directories to remove #${rmbin} -rf ${APPDIR} ${SYSCONFDIR}/${APPNAME} ${DOCDIR} # remove all installed directories that are now blank. rmdir ${DEFAULTDIR} 2>/dev/null ; 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."