X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/d37062ed3c7a06adb006b405441d79fb0e134451..7774c4b6785613043477b9b05216762e680385fd:/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile index a674178..90b769f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,27 +1,37 @@ +# SPDX-FileCopyrightText: 2023, 2024 Lady +# SPDX-License-Identifier: MPL-2.0 + SHELL = /bin/sh # ━ § BASIC INFORMATION ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ override define makefileinfo ╭────────────────────────────╮ -╔╡ ⁌ ⛩️📰 书社 ∷ GNUmakefile ╞════════════════════════════════╗ +╔╡ ⁌ ⛩️📰 书社 ∷ GNUmakefile ╞═════════════════════════════════╗ ║╰────────────────────────────╯ ║ ╟┬ ¶ Prerequisites ───────────────────────────────────────────┬╢ ║│ │║ ║│ Requires G·N·U Make, at least version 3.81, a version of │║ ║│ uuencode with base64 support, and the various programs │║ ║│ offered by libxml2 and libxslt. Beyond this, only programs │║ -║│ required by Posix are used, altho there is a chance of │║ +║│ required by Posix are required, altho there is a chance of │║ ║│ version incompatibilities. The full list of program │║ ║│ requirements is as follows :— │║ ║│ │║ +║│ • awk │║ ║│ • cat │║ +║│ • cksum │║ ║│ • cp │║ ║│ • date │║ ║│ • echo │║ ║│ • file │║ ║│ • find │║ +║│ • grep │║ +║│ • git (optional) │║ +║│ • ln │║ ║│ • mkdir (requires support for `-p´) │║ ║│ • mv │║ +║│ • od (requires support for `-t x1´) │║ +║│ • pax (only when generating archives) │║ ║│ • printf │║ ║│ • rm │║ ║│ • sed │║ @@ -31,6 +41,8 @@ override define makefileinfo ║│ • touch │║ ║│ • tr (requires support for `-d´) │║ ║│ • uuencode (requires support for `-m´ and `-r´) │║ +║│ • uudecode (requires support for `-m´ and `-r´) │║ +║│ • xargs (requires support for `-0´) │║ ║│ • xmlcatalog (provided by libxml2) │║ ║│ • xmllint (provided by libxml2) │║ ║│ • xsltproc (provided by libxslt) │║ @@ -41,13 +53,14 @@ override define makefileinfo ║╰────────────────────────────────────────────────────────────╯║ ╟┬ ¶ Usage ───────────────────────────────────────────────────┬╢ ║│ │║ -║│ • `make all´: Compile, but do not install, all files. │║ +║│ • `make all´ (default): Compile, but do not install, all │║ +║│ files. │║ ║│ │║ ║│ • `make clean´: Remove `BUILDDIR´. │║ ║│ │║ -║│ • `make gone´: Remove installed files. │║ +║│ • `make gone´: Remove `BUILDDIR´ and installed files. │║ ║│ │║ -║│ • `make help´ (default): Print this message. │║ +║│ • `make help´: Print this message. │║ ║│ │║ ║│ • `make install´: Compile all files and install in │║ ║│ `DESTDIR´. │║ @@ -55,6 +68,13 @@ override define makefileinfo ║│ • `make list´: List all recognized source files and their │║ ║│ classification (including media type and dependencies). │║ ║│ │║ +║│ • `make listout´: List out the destinations of all │║ +║│ resulting files (relative to `DESTDIR´), e·g for │║ +║│ processing by another script. │║ +║│ │║ +║│ • `make uninstall´: Remove installed files, but not │║ +║│ `BUILDDIR´. │║ +║│ │║ ║│ Set `VERBOSE=1´ to see the text of commands as they are │║ ║│ executed. │║ ║│ │║ @@ -77,16 +97,22 @@ endef # Programs needed to run this make·file. # -# If these are not installed on your computer, or you need to use a -# different implementation, you can override the appropriate variable. +# If these are not installed on your computer, or you need to use a different implementation, you can override the appropriate variable. +AWK := awk CAT := cat +CKSUM := cksum CP := cp DATE := date ECHO := echo FILE := file FIND := find +GIT := git +GREP := grep +LN := ln MKDIR := mkdir MV := mv +OD := od +PAX := pax PRINTF := printf RM := rm SED := sed @@ -95,85 +121,120 @@ STAT := stat TEST := test TOUCH := touch TR := tr +UUDECODE := uudecode UUENCODE := uuencode +XARGS := xargs XMLCATALOG := xmlcatalog XMLLINT := xmllint XSLTPROC := xsltproc +# This variable is not used in normal execution. +# +# In the archiving `MODE´, it provides the X·M·L file from which the archive should be constructed. +SRC := + +# This variable is not used in normal execution. +# +# In the archiving `MODE´, it provides a user‐friendly name for the archive. +NAME := + # The directory which contains the source files. +# +# Multiple directories can be given so long as files with the same name do not exist in each. SRCDIR := sources -# The directory which contains “includes”: Files which may be included -# in other files but for which no final output will be generated. +# The directory which contains “includes”: +# Files which may be included in other files but for which no final output will be generated. # -# This can be inside of `SOURCES_DIRECTORY´ if desired. +# Multiple directories can be given so long as files with the same name do not exist in each. +# +# These can be inside of `SRCDIR´ directories if desired. INCLUDEDIR := sources/includes # The directory in which to generate temporary buildfiles. +# +# This variable is also used by the archiving `MODE´. BUILDDIR := build # The directory into which to output files on `make install´. +# +# This variable is also used by the archiving `MODE´. DESTDIR := public -# The location of this Makefile (and related ⛩️📰 书社 files), -# relative to the current working directory. +# The location of this Makefile (and related ⛩️📰 书社 files), relative to the current working directory. # # By default, this is inferred from the variable `MAKEFILE_LIST´. +# +# This variable is also used by the archiving `MODE´. THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -# The location of the magic files to use when determining media types. -# -# One is provided as part of this repository, but you can override it -# if you need different media type detection. +# Configuration of `find´. # -# Your computer probably has a more comprehensive one installed at -# `/usr/share/file/magic´, but it is not recommended that you use this -# directly. Instead, link or copy just the files you expect to need for -# your project. -MAGICDIR := $(patsubst ./%,%,$(THISDIR)/magic) +# By default, `find´ will ignore files which begin with a period and those which are likely to cause problems for `make´. +EXTRAFINDRULES := +EXTRAFINDINCLUDERULES := +FINDRULES := ! '(' '(' -name '[.-]*' -o -name '*[][*?:|$$%\#\\; ]*' -o -name '*[)]' ')' -a -prune ')'$(if $(EXTRAFINDRULES), -a $(EXTRAFINDRULES),) +FINDINCLUDERULES := $(FINDRULES)$(if $(EXTRAFINDINCLUDERULES), -a $(EXTRAFINDINCLUDERULES),) -# Configuration of `find´. +# The list of magic files to use when determining media types. +# +# Some are provided as part of this repository, but you can add more if you need different media type detection. # -# By default, `find´ will not follow symlinks and will use extended -# regular expressions, ignoring hidden files and those which begin with -# a period. -FINDOPTS := -PE -FINDRULES := -flags -nohidden -and -not -name '.*' +# Your computer probably has several already installed at `/usr/share/file/magic´. +EXTRAMAGIC := +MAGIC := $(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/magic/*)) $(EXTRAMAGIC)) # The list of parsers for plaintext file types. # -# Which parsers are provided will influence which kinds of files are -# recognized as plaintext. -# -# Each parser ⁜must⁜ have a template which matches ⁜only⁜ X·H·T·M·L -# `')" +# (callable) Sanitize and wrap the provided plaintext file in X·M·L, printing to `stdout´. +override wrapplaintext = $(TR) '\000\013\014' '\032\011\012' < $(call quote,$1) | $(SED) "$$($(PRINTF) '%b' 's/]]>/]]]]>/g\ns/\0357\0277\0276/�/g\ns/\0357\0277\0277/�/g\n$$!s/\\r$$//g\ns/\\r/\\n/g\n$$!s/\0302\0205$$//g\ns/\0302\0205/\\n/g;s/\0342\0200\0250/\\n/g;s/[\0001-\0010]/�/g;s/[\0016-\0037]/�/g')" | $(XARGS) -0 $(PRINTF) '%b%s]]>\n' '\n