X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/56637a1e803cab7a53a1259d1fa4b84513a1c5b1..6773582e45aab385c96638fe9e90d811132a1005:/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile index 2de20b2..2cb311f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,29 +1,38 @@ +# 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 │║ +║│ • ls │║ ║│ • mkdir (requires support for `-p´) │║ ║│ • mv │║ ║│ • od (requires support for `-t x1´) │║ +║│ • pax (only when generating archives) │║ ║│ • printf │║ ║│ • rm │║ ║│ • sed │║ @@ -33,6 +42,7 @@ 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) │║ @@ -44,13 +54,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´. │║ @@ -58,6 +69,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. │║ ║│ │║ @@ -80,18 +98,23 @@ 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 +LS := ls MKDIR := mkdir MV := mv OD := od +PAX := pax PRINTF := printf RM := rm SED := sed @@ -100,91 +123,123 @@ 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. +# 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. # -# Multiple directories can be given so long as files with the same name -# do not exist in each. +# 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 '*"{*' -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 ignore hidden files, those which begin with a -# period, and those which are likely to cause problems for `make´. -FINDRULES := -flags -nohidden -and ! '(' '(' -name '[.-]*' -or -name '*[:|$$%]*' ')' -and -prune ')' -FINDINCLUDERULES := $(FINDRULES) +# 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