blob: 64078233c7448b70a440c2ecc9751b70d96c5f54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# 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:
# exclude-raw: go-md2man
# exclude-devuan: go-md2man
APPNAME = logout-manager
APPVERSION = 0.0.4
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
APPDIR = $(SHAREDIR)/$(APPNAME)
APPSDIR = $(SHAREDIR)/applications
BASHCDIR = $(SHAREDIR)/bash-completion/completions
DOCDIR = $(SHAREDIR)/doc/$(APPNAME)
MANDIR = $(SHAREDIR)/man
SUDOERSDIR = $(SYSCONFDIR)/sudoers.d
XDGAUTODIR = $(SYSCONFDIR)/xdg/autostart
awkbin :=$(shell which awk)
cpbin :=$(shell which cp)
echobin :=$(shell which echo)
findbin :=$(shell which find)
grepbin :=$(shell which grep)
gzipbin :=$(shell which gzip)
installbin :=$(shell which install)
lnbin :=$(shell which ln)
md2manbin :=$(shell which go-md2man)
rmbin :=$(shell which rm)
sedbin :=$(shell which sed)
sortbin :=$(shell which sort)
truebin :=$(shell which true)
uniqbin :=$(shell which uniq)
xargsbin :=$(shell which xargs)
SEPARATOR ?=,
all:
@${echobin} "No compilation in this package."
.PHONY: clean install uninstall list deplist deplist_opts install_files install_man
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
@# deplist 2020-03-24 input must be comma separated
@${grepbin} -h --exclude-dir='doc' -riIE '\<dep-' ${SRCDIR} | ${awkbin} -v "domain=${DISTRO}" 'tolower($$2) ~ "dep-"domain {$$1="";$$2="";print}' | tr ',' '\n' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/^\s*//' -e "s/\s*\$$/${SEPARATOR}/" | ${xargsbin}
deplist_opts:
@# deplist_opts 2020-03-24 find all available dependency domains
@${grepbin} -h -o -riIE '\<dep-[^\ :]+:' ${SRCDIR} | ${sedbin} -r -e 's/dep-//;' -e 's/:$$//;' | ${sortbin} | ${uniqbin} 1>&2
install: install_files install_man
install_files:
@${echobin} Installing files to ${DESTDIR}
${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} \
${APPSDIR} ${APPDIR} ${DOCDIR} ${BASHCDIR} ${SUDOERSDIR} \
${LIBEXECDIR}/${APPNAME} ${XDGAUTODIR}
${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}/*
${installbin} -m 0644 -t ${XDGAUTODIR} ${SRCDIR}/etc/xdg/autostart/*
# symlink, when alternatives is not being used
${lnbin} -s logout-manager-gtk ${BINDIR}/logout-manager || :
install_man:
ifeq ($(md2manbin),)
@${echobin} Cannot install man pages, because go-md2man is not found.
@false
endif
${installbin} -d ${MANDIR}/man1 ${MANDIR}/man5 ${MANDIR}/man7
for tm in $$( ${findbin} ${SRCDIR}/usr/share/man ! -type d -name '*[0-9].md' -printf '%P\n' ) ; do ${md2manbin} < ${SRCDIR}/usr/share/man/$${tm} | ${gzipbin} > ${MANDIR}/$${tm%%.md}.gz ; done
uninstall:
@${echobin} SRCDIR=${SRCDIR}
${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d ! -name 'Makefile' -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" -e '/man[0-9]\/.*[0-9]\.md$$/{s:\.md$$:.gz:}' ) ${DEFAULTDIR}/${APPNAME} ${BINDIR}/logout-manager
# 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."
|