]> Lady’s Gitweb - Vocab/blob - GNUmakefile
Add R·F·C 5005 link relations
[Vocab] / GNUmakefile
1 # SPDX-FileCopyrightText: 2023, 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
2 # SPDX-License-Identifier: MPL-2.0
3
4 SHELL = /bin/sh
5
6 # Copyright © 2023–2025 Lady [@ Ladys Computer].
7 #
8 # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
9 # If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
10
11 CP := cp
12 FIND := find
13 GIT := git
14 MKDIR := mkdir
15 PRINTF := printf
16 RM := rm
17 SED := sed
18 TEST := test
19 TOUCH := touch
20 XARGS := xargs
21
22 DATADIR := data
23 SRCDIR := site
24 BUILDDIR := build
25 BUILDTARGET := .grass
26 DESTDIR := public
27
28 THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
29
30 SHUSHE := .⛩📰
31 MAKEOPTS := CP='$(CP)' FIND='$(FIND)' GIT='$(GIT)' MKDIR='$(MKDIR)' PRINTF='$(PRINTF)' RM='$(RM)' SED='$(SED)' TEST='$(TEST)' TOUCH='$(TOUCH)' XARGS='$(XARGS)'
32 SHUSHEOPTS := $(MAKEOPTS) SRCDIR='$(SRCDIR)' DATADIR='$(DATADIR)' BUILDDIR='$(BUILDDIR)' DESTDIR='$(BUILDDIR)/public' EXTRAPARSERS='$(wildcard $(THISDIR)/parsers/*.xslt)' EXTRAPARSERLIBS='$(DATADIR)/ontologies/¦' EXTRATRANSFORMS='$(wildcard $(THISDIR)/transforms/*.xslt)'
33
34 YSEME := .👥📤
35 YSEMEOPTS := $(MAKEOPTS) BUILDTARGET='$(BUILDTARGET)' DESTDIR='$(DESTDIR)' SERVERPATH='lady/vocab'
36
37 xmls := $(wildcard $(DATADIR)/*/*)
38
39 # ━ § Call out to ⛩📰 书社 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
40
41 install : $(SHUSHE)/GNUmakefile build
42 @for publicfile in $(patsubst %,"%",$(shell $(FIND) '$(DESTDIR)'/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -R -f "$$publicfile"; fi; done
43 @for dir in $$($(FIND) '$(BUILDDIR)/public' -type d | $(SED) 's:$(BUILDDIR)/public/::'); do if $(TEST) '!' -d "$(DESTDIR)/$$dir"; then $(MKDIR) -p "$(DESTDIR)/$$dir"; fi; done
44 @for file in $$($(FIND) '$(BUILDDIR)/public' -type f | $(SED) 's:$(BUILDDIR)/public/::'); do $(PRINTF) '%s\n' "$$file" | $(SED) 's:/_\(.*\)_\(\..*\)$$:/(\1)\2:g;s/¦/:/g' | $(XARGS) $(PRINTF) 'Copying <%s>…\n' >&2; $(PRINTF) '%s\n' "$$file" | $(SED) 's:^:$(DESTDIR)/:;s:/_\(.*\)_\(\..*\)$$:/(\1)\2:g;s/¦/:/g' | $(XARGS) $(CP) "$(BUILDDIR)/public/$$file"; done
45 $(TOUCH) '$(BUILDTARGET)'
46
47 build : $(SHUSHE)/GNUmakefile
48 @$(RM) -R -f '$(BUILDDIR)/public'
49 @$(MAKE) -f '$<' install $(SHUSHEOPTS)
50
51 clean list listout : $(SHUSHE)/GNUmakefile
52 @$(MAKE) -f '$<' $@ $(SHUSHEOPTS)
53
54 $(BUILDDIR)/% : $(SHUSHE)/GNUmakefile FORCE
55 @$(MAKE) -f '$<' $@ $(SHUSHEOPTS)
56
57 # ━ § Call out to 👥📤 Yseme ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
58
59 dry-sync sync : $(YSEME)/GNUmakefile
60 @$(MAKE) -f '$<' $@ $(YSEMEOPTS)
61
62 # ━ § Build xmllint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
63
64 # This is temporarily required as DTD resolving requires a very new
65 # version of `xmllint´ when a filename contains non‐Ascii characters.
66 # Once `libxml2` ≥ 2.13.2 is more widely available, this subrepo and
67 # build step can probably be dropped.
68
69 .libxml2/xmllint : .libxml2/autogen.sh
70 cd .libxml2 && ./autogen.sh
71 $(MAKE) -C .libxml2
72
73 # ━ § Linting ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
74
75 lint : $(foreach xml,$(xmls),lint][$(xml)) ;
76
77 $(foreach xml,$(xmls),lint][$(xml)) : lint][% : .libxml2/xmllint
78 @.libxml2/xmllint --valid --noout '$*'
79
80 # ━ § Special targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81
82 .IGNORE : $(foreach xml,$(xmls),lint][$(xml)) ;
83
84 .PHONY : FORCE build clean dry-sync gone lint $(foreach xml,$(xmls),lint][$(xml)) list prebuild sync uninstall ;
85
86 gone : clean uninstall ;
87
88 uninstall :
89 @for publicfile in $(patsubst %,"%",$(wildcard $(DESTDIR)/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -rf "$$publicfile"; fi; done
90
91 FORCE : ;
92
93 # ━ § Make·file targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
94
95 $(SHUSHE)/GNUmakefile $(YSEME)/GNUmakefile : %/GNUmakefile : FORCE
96 $(GIT) submodule update --init '$*'
97
98 .libxml2/autogen.sh : %/autogen.sh : FORCE
99 $(GIT) submodule update --init '$*'
This page took 0.058968 seconds and 5 git commands to generate.