This is, strictly speaking, a downgrade in functionality, with the
upside of reducing reliance on non·Posix programs (namely `stat`). A
better, Posix‐compliant solution is to archive an empty file with the
correct modification time and then list out the time from that archive;
however, as far as I’m aware, it’s not possible to obtain an
implementation of the `pax` utility which actually supports this. macOS
only supports a very limited subset of the `listopt` option, and only
for pax archives (not tarballs); other implementations don’t seem to
support it at all.
║│ • rm │║
║│ • sed │║
║│ • sleep │║
║│ • rm │║
║│ • sed │║
║│ • sleep │║
║│ • test │║
║│ • touch │║
║│ • tr │║
║│ • test │║
║│ • touch │║
║│ • tr │║
RM := rm
SED := sed
SLEEP := sleep
RM := rm
SED := sed
SLEEP := sleep
TEST := test
TOUCH := touch
TR := tr
TEST := test
TOUCH := touch
TR := tr
# (callable) Get the modified time of the provided file.
#
# (callable) Get the modified time of the provided file.
#
-# This is messy; there is no portable way of using `stat´.
+# Only the date·time information available via `ls -l´ is supported; that is, only minute precision for files newer than six months, and only day precision for files which are older.
+# This is, unfortunately, the best that can be done in pure Posix as of now.
+#
+# There is an easier implementation which provides the full date·time by archiving an empty file and then reading it back out of the archive :—
+#
+# $(shell LC_TIME=POSIX TZ=UTC0 $(TOUCH) -m -r $(callquote,$1) $(BUILDDIR)/.mtime && $(PAX) -w -x ustar $(BUILDDIR)/.mtime | $(PAX) -v -o 'listopt=%(mtime=%Y-%m-%dT%H:%M:%SZ)T')
+#
+# However, it depends on the `listopt´ option in `pax´, which (despite being specified in Posix) no implementations actually support.
#
# ☡ This variable creates a subshell every time it is computed.
#
# ☡ This variable creates a subshell every time it is computed.
-override modtime = $(shell if $(STAT) --version 2> /dev/null | $(GREP) -q GNU; then $(DATE) -u -d "@$$(TZ= $(STAT) -c '%Y' $(call quote,$1))" '+%Y-%m-%dT%H:%M:%SZ'; else TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$1); fi)
+override modtime = $(shell { $(DATE) -u '+%Y-%m'; LC_TIME=POSIX TZ=UTC0 ls -q -A -l $(call quote,$1) | $(SED) 's/\([^ ]* \{1,\}\)\{5\}\(\([^ ]* \{1,\}\)\{3\}\).*/\2/;s/ \([0123456789]\) / 0\1 /;s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/;s/\([0123456789]\{2\}\) *\([0123456789]\{2\}\) *\([0123456789]\{4\}\)/\3-\1-\2T00:00:00Z/;s/\([0123456789]\{2\}\) *\([0123456789]\{2\}\) *\([0123456789:]\{5\}\)/XXXX-\1-\2T\3:00Z/'; } | $(TR) -d ' ' | $(AWK) -F '-' 'NR==1{year=$$1;month=$$2}$$1=="XXXX"&&$$2<=month{print year"-"$$2"-"$$3}$$1=="XXXX"&&$$2>month{print year-1"-"$$2"-"$$3}NR>1&&$$1!="XXXX"')
# ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
# ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
# List all source files and includes and their computed types.
list :
# List all source files and includes and their computed types.
list :
- @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m]$(if $(call dependencies,$(file))$(call recursives,$(file)), $(strip $(foreach recursive,$(call recursives,$(file)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(recursive)) $(foreach dependency,$(call dependencies,$(file)),\0033[2m•|Dependency|\0033[22m|$(dependency))))$(if $(filter $(file),$(sourcefiles)), →|<\0033[4m/$(call destination,$(file))\0033[24m>,) )) | $(TR) ' |' '\n '
+ @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m] Modified:|$(call modtime,$(file))$(if $(call dependencies,$(file))$(call recursives,$(file)), $(strip $(foreach recursive,$(call recursives,$(file)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(recursive)) $(foreach dependency,$(call dependencies,$(file)),\0033[2m•|Dependency|\0033[22m|$(dependency))))$(if $(filter $(file),$(sourcefiles)), →|<\0033[4m/$(call destination,$(file))\0033[24m>,) )) | $(TR) ' |' '\n '
# Lists out the destinations of all resulting files (relative to `DESTDIR´).
listout :
# Lists out the destinations of all resulting files (relative to `DESTDIR´).
listout :
listed, it is assumed that any Posix‐compliant implementation will
work.
listed, it is assumed that any Posix‐compliant implementation will
work.
-### `date`
-
-This is a Posix utility, but ⛩️📰 书社 currently depends on
- unspecified behaviour.
-When the G·N·U version of `stat` is being used, then the G·N·U version
- of `date` is also expected.
-
### `file`
This is a Posix utility, but ⛩️📰 书社 currently depends on
### `file`
This is a Posix utility, but ⛩️📰 书社 currently depends on
installed by default in many distributions.
Only `ustar` format support is required.
installed by default in many distributions.
Only `ustar` format support is required.
-### `stat`
-
-This is not a Posix utility, and nor is it particularly portable.
-To get around incompatibilities, ⛩️📰 书社 attempts to recognize G·N·U
- `stat` by searching for the string `GNU` when invoked with the
- `--version` option, and falls back to B·S·D behaviour otherwise.
-
### `uudecode` and `uuencode`
These are Posix utilities, but not included in the Linux Standard Base
### `uudecode` and `uuencode`
These are Posix utilities, but not included in the Linux Standard Base
- `test`
- `touch`
- `tr`
- `test`
- `touch`
- `tr`
- **`SRCTIME`:**
The time at which the source file was last modified.
- **`SRCTIME`:**
The time at which the source file was last modified.
+ Due to limitations in Posix, this time will only have minute
+ precision if the file was modified in the last six months, and will
+ only have day precision if the file is older.
+ Users should not expect this value to be particularly stable.
- **`THISREV`:**
The value of the `THISREV` variable (if present).
- **`THISREV`:**
The value of the `THISREV` variable (if present).