diff options
author | B. Stack <bgstack15@gmail.com> | 2023-07-13 09:56:51 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-07-13 09:56:51 -0400 |
commit | 3fcd32aa6d295ac62fe0e526931fc556a4060343 (patch) | |
tree | 244c95a3ed1cf21c4cb2705276062d98cd7e10ae /src/Makefile | |
download | fix-alttab-3fcd32aa6d295ac62fe0e526931fc556a4060343.tar.gz fix-alttab-3fcd32aa6d295ac62fe0e526931fc556a4060343.tar.bz2 fix-alttab-3fcd32aa6d295ac62fe0e526931fc556a4060343.zip |
initial commit
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..5e2d00f --- /dev/null +++ b/src/Makefile @@ -0,0 +1,106 @@ +# File: Makefile for fix-alttab +# Location: fix-alttab source package +# Author: bgstack15 +# Startdate: 2023-07-10-2 16:27 +# SPDX-License-Identifier: GPL-3.0 +# Title: Makefile for fix-alttab source package +# Project: fix-alttab +# Purpose: To use traditional Unix make utility +# History: +# Usage: +# Reference: +# outbound Makefile +# Improve: +# Document: +# Dependencies: +# build-devuan: bgscripts-core, txt2man + +APPNAME = fix-alttab +APPVERSION = 0.0.1 +SRCDIR = $(CURDIR) +prefix = /usr +SYSCONFDIR = $(DESTDIR)/etc +DEFAULTDIR = $(DESTDIR)/etc/sysconfig# for debian use '$(DESTDIR)/etc/default' +LIBEXECDIR = $(DESTDIR)$(prefix)/libexec +SHAREDIR = $(DESTDIR)$(prefix)/share +DOCDIR = $(SHAREDIR)/doc/$(APPNAME) +MANDIR = $(SHAREDIR)/man +BINDIR = $(DESTDIR)$(prefix)/bin + +# variables for deplist +DEPTYPE = dep +SEPARATOR = , + +awkbin :=$(shell which awk) +chmodbin :=$(shell which chmod) +cpbin :=$(shell which cp) +echobin :=$(shell which echo) +falsebin :=$(shell which false) +findbin :=$(shell which find) +grepbin :=$(shell which grep) +gzipbin :=$(shell which gzip) +installbin :=$(shell which install) +rmbin :=$(shell which rm) +rmdirbin :=$(shell which rmdir) +sedbin :=$(shell which sed) +sortbin :=$(shell which sort) +truebin :=$(shell which true) +uniqbin :=$(shell which uniq) +xargsbin :=$(shell which xargs) +txt2manwrapper :=/usr/bin/txt2man-wrapper + +with_man ?= YES + +all: build_man + -@#echo "Nothing to build." && ${truebin} + +ifeq ($(with_man),YES) +install: build_man install_files +else +install: install_files +endif + +.PHONY: clean install install_files build_man 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: + @# deplist 2020-04-18 input must be comma separated + @# DEPTYPE( dep , rec , sug ) for depends, recommends, or suggests + @if test -z "${DISTRO}" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." 1>&2 ; exit 1 ; fi + @if ! ${echobin} "${DEPTYPE}" | grep -qE "^(dep|rec|sug)$$" ; then ${echobin} "Please run \`make deplist\` with DEPTYPE= one of: dep, rec, sug. Undefined will use \`dep\`. Aborted." 1>&2 ; exit 1; fi + @${grepbin} -h --exclude-dir='doc' -riIE "\<${DEPTYPE}-" ${SRCDIR} | ${awkbin} -v "domain=${DISTRO}" -v "deptype=${DEPTYPE}" 'tolower($$2) ~ deptype"-"domain {$$1="";$$2="";print}' | tr ',' '\n' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/^\s*//' -e "s/\s*\$$/${SEPARATOR}/" | ${xargsbin} + +deplist_opts: + @# deplist_opts 2020-04-18 find all available dependency domains + @${grepbin} -h -o -riIE '\<(dep|rec|sug)-[^\ :]+:' ${SRCDIR} | ${sedbin} -r -e 's/(dep|rec|sug)-//;' -e 's/:$$//;' | ${sortbin} | ${uniqbin} 1>&2 + +install_files: + @ls usr/share/man/man*/*gz 1>/dev/null 2>&1 && echo "Including man pages." || : + @${echobin} Installing files to ${DESTDIR} + for td in $$( ${findbin} ${SRCDIR} -type d ! -name '.*.swp' ! -name 'Makefile' ! -name '.gitignore' ! -name 'README.md' -printf '%P\n' | ${sedbin} -r -e "s:etc/sysconfig:${DEFAULTDIR}:" -e "s:${DESTDIR}/?::" ) ; do ${installbin} -m0755 -d ${DESTDIR}/$${td} ; done + for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -name '.*.swp' ! -name 'Makefile' ! -name '.gitignore' ! -name 'README.md' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated)/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done + @# sysconfig/default dir + ${installbin} -m0644 -t ${DEFAULTDIR} ${SRCDIR}/etc/sysconfig/* + @# grab the project readme from above dir src/ + ${installbin} -m0644 -t ${DOCDIR} ${SRCDIR}/../README.md + +MAN_TXT:=$(wildcard usr/share/man/man*/*.txt) +MAN_GZ:= $(subst .txt,.gz,$(MAN_TXT)) + +build_man: $(MAN_GZ) + +$(MAN_GZ): %.gz: %.txt + ${txt2manwrapper} - < $< | ${gzipbin} > $@ + +uninstall: + @${echobin} SRCDIR=${SRCDIR} + ${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d -printf '%p\n' | ${sedbin} -r -e "s:/etc/sysconfig:${DEFAULTDIR}:" -e "s:^${SRCDIR}:${DESTDIR}:" -e "s:${DESTDIR}${DESTDIR}:${DESTDIR}:" ) + + # remove all installed directories that are now blank. + ${rmdirbin} ${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 }' | ${sortbin} -rn | ${awkbin} '{print $$2}' ) ; do ${findbin} $${word} -mindepth 1 1>/dev/null 2>&1 | read 1>/dev/null 2>&1 || { ${rmdirbin} "$${word}" 2>/dev/null || ${truebin} ; } ; done + +clean: + -@#${echobin} "target $@ not implemented yet! Gotta say unh." && ${falsebin} + -${rmbin} -f usr/share/man/man*/*.gz || : |