diff options
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..96607d2 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,94 @@ +# 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: +# Includes a nice way to dynamically generate dependencies as self-reported by all the files. +# 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 +BASHCDIR = $(SHAREDIR)/bash-completion/completions +SUDOERSDIR = $(SYSCONFDIR)/sudoers.d + +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) +truebin :=$(shell which true) +uniqbin :=$(shell which uniq) +xargsbin :=$(shell which xargs) + +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}' | ${awkbin} 'BEGIN{cmd="${xargsbin} -n1"} $$0 !~ /\(/{print $$0 | cmd ; close(cmd);} $$0 ~ /\(/{print;}' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/$$/$(SEPARATOR)/' | ${xargsbin} + +deplist_opts: + @${echobin} "el7" 1>&2 + @${echobin} "devuan" 1>&2 + +install: + @${echobin} Installing files to ${DESTDIR} + ${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} \ + ${APPSDIR} ${APPDIR} ${DOCDIR} ${BASHCDIR} ${SUDOERSDIR} \ + ${LIBEXECDIR}/${APPNAME} + ${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} + ${installbin} -m 0644 -t ${BASHCDIR} ${SRCDIR}/usr/share/bash-completion/completions/* + ${installbin} -m 0640 -t ${SUDOERSDIR} ${SRCDIR}/etc/sudoers.d/* + ${installbin} -m 0755 -t ${LIBEXECDIR}/${APPNAME} ${SRCDIR}/usr/libexec/${APPNAME}/* + # 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." |