]> Lady’s Gitweb - Vocab/blob - GNUmakefile
Initial commit; initial set of vocabs
[Vocab] / GNUmakefile
1 # SPDX-FileCopyrightText: 2023-2024 Lady <https://www.ladys.computer/about/#lady>
2 # SPDX-License-Identifier: MPL-2.0
3
4 SHELL = /bin/sh
5
6 # Copyright © 2023–2024 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 DATASRCDIR := data
23 SITESRCDIR := site
24 BUILDDIR := build
25 DATABUILDDIR := build/data
26 RDFBUILDDIR := build/rdf
27 SITEBUILDDIR := build/site
28 BUILDTARGET := .grass
29 DESTDIR := public
30
31 THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
32
33 SHUSHE := .⛩📰
34 MAKEOPTS := CP='$(CP)' FIND='$(FIND)' GIT='$(GIT)' MKDIR='$(MKDIR)' PRINTF='$(PRINTF)' RM='$(RM)' SED='$(SED)' TEST='$(TEST)' TOUCH='$(TOUCH)' XARGS='$(XARGS)'
35
36 # Stage 1: Build R·D·F files to build/rdf
37 SHUSHEDATAOPTS := $(MAKEOPTS) SRCDIR='$(DATASRCDIR)' INCLUDEDIR='$(DATASRCDIR)' BUILDDIR='$(DATABUILDDIR)' DESTDIR='$(RDFBUILDDIR)' EXTRAPARSERS='$(wildcard $(THISDIR)/parsers/data/*.xslt)' EXTRAPARSERLIBS='$(DATASRCDIR)/ontologies/¦' EXTRAFINDINCLUDERULES='-not '"'"'('"'"' '"'"'('"'"' -name ontologies -o -name profiles '"'"')'"'"' -a -type d -a -prune '"'"')'"'"'' EXTRATRANSFORMS='$(wildcard $(THISDIR)/transforms/data/*.xslt)'
38
39 # Stage 2: Build the actual site
40 SHUSHESITEOPTS := $(MAKEOPTS) SRCDIR='$(SITESRCDIR)' INCLUDEDIR='$(RDFBUILDDIR)' BUILDDIR='$(SITEBUILDDIR)' DESTDIR='$(DESTDIR)' EXTRAPARSERS='$(wildcard $(THISDIR)/parsers/site/*.xslt)' EXTRATRANSFORMS='$(wildcard $(THISDIR)/transforms/site/*.xslt)'
41
42 YSEME := .👥📤
43 YSEMEOPTS := $(MAKEOPTS) BUILDTARGET='.grass' DESTDIR='$(DESTDIR)' SERVERPATH='lady/vocab'
44
45 xmls := $(wildcard $(DATASRCDIR)/*/*)
46
47 # ━ § Call out to ⛩📰 书社 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
48
49 install : $(SHUSHE)/GNUmakefile build
50 @for publicfile in $(patsubst %,"%",$(wildcard $(DESTDIR)/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -rf "$$publicfile"; fi; done
51 @for target in $$($(MAKE) -s -f '$<' listout QUIET=1 $(SHUSHEDATAOPTS)); do $(PRINTF) '%s\n' "$$target" | $(SED) 's/¦/:/g' | $(XARGS) $(PRINTF) 'Copying </%s>…\n' >&2; $(PRINTF) '%s\n' "$$target" | $(SED) 's:^:$(DESTDIR)/:;s/¦/:/g' | $(XARGS) $(CP) '$(RDFBUILDDIR)/'"$$target"; done
52 @for target in $$($(MAKE) -s -f '$<' listout QUIET=1 $(SHUSHESITEOPTS)); do for dir in $$($(FIND) "$(SITEBUILDDIR)/public/$$target" -not -name '.*' -and -type d); do if $(TEST) '!' -d "$(DESTDIR)/$$dir"; then $(PRINTF) '%s\n' "$$dir" | $(SED) 's:$(SITEBUILDDIR)/public/:$(DESTDIR)/:' | $(XARGS) $(MKDIR) -p; fi; done; for file in $$($(FIND) "$(SITEBUILDDIR)/public/$$target" -not '(' -name '.*' -or -type d ')'); do $(PRINTF) '%s\n' "$$file" | $(SED) 's:$(SITEBUILDDIR)/public/:/:;s:/_\(.*\)_\(\..*\)$$:/(\1)\2:g;s/¦/:/g' | $(XARGS) $(PRINTF) 'Copying <%s>…\n' >&2; $(PRINTF) '%s\n' "$$file" | $(SED) 's:$(SITEBUILDDIR)/public/:$(DESTDIR)/:;s:/_\(.*\)_\(\..*\)$$:/(\1)\2:g;s/¦/:/g' | $(XARGS) $(CP) "$$file"; done; done
53 $(TOUCH) '$(BUILDTARGET)'
54
55 build : $(SHUSHE)/GNUmakefile
56 @$(RM) -rf '$(RDFBUILDDIR)/profiles'
57 @$(MAKE) -f '$<' install $(SHUSHEDATAOPTS)
58 @$(MAKE) -f '$<' $(SHUSHESITEOPTS)
59
60 clean : $(SHUSHE)/GNUmakefile
61 @$(MAKE) -f '$<' $@ $(SHUSHEDATAOPTS)
62 @$(RM) -rf '$(RDFBUILDDIR)'
63 @$(MAKE) -f '$<' $@ $(SHUSHESITEOPTS)
64
65 list listout : $(SHUSHE)/GNUmakefile
66 @$(RM) -rf '$(RDFBUILDDIR)/profiles'
67 @$(MAKE) -f '$<' install $(SHUSHEDATAOPTS)
68 @$(MAKE) -f '$<' $@ $(SHUSHESITEOPTS)
69
70 $(BUILDDIR)/data/% : $(SHUSHE)/GNUmakefile FORCE
71 @$(MAKE) -f '$<' $@ $(SHUSHEDATAOPTS)
72
73 $(BUILDDIR)/rdf/% : $(SHUSHE)/GNUmakefile FORCE
74 @$(MAKE) -f '$<' $@ $(SHUSHEDATAOPTS)
75
76 $(BUILDDIR)/site/% : $(SHUSHE)/GNUmakefile FORCE
77 @$(RM) -rf '$(RDFBUILDDIR)/profiles'
78 @$(MAKE) -f '$<' install $(SHUSHEDATAOPTS)
79 @$(MAKE) -f '$<' $@ $(SHUSHESITEOPTS)
80
81 $(DESTDIR)/% : $(SHUSHE)/GNUmakefile FORCE
82 @$(RM) -rf '$(RDFBUILDDIR)/profiles'
83 @$(MAKE) -f '$<' install $(SHUSHEDATAOPTS)
84 @$(MAKE) -f '$<' $@ $(SHUSHESITEOPTS)
85
86 # ━ § Call out to 👥📤 Yseme ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
87
88 dry-sync sync : $(YSEME)/GNUmakefile
89 @$(MAKE) -f '$<' $@ $(YSEMEOPTS)
90
91 # ━ § Build xmllint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
92
93 # This is temporarily required as DTD resolving requires a very new
94 # version of `xmllint´ when a filename contains non‐Ascii characters.
95 # Once `libxml2` ≥ 2.13.2 is more widely available, this subrepo and
96 # build step can probably be dropped.
97
98 .libxml2/xmllint : .libxml2/autogen.sh
99 $(CD) .libxml2 && ./autogen.sh && ./configure
100 $(MAKE) -C .libxml2
101
102 # ━ § Linting ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
103
104 lint : $(foreach xml,$(xmls),lint][$(xml)) ;
105
106 $(foreach xml,$(xmls),lint][$(xml)) : lint][% : .libxml2/xmllint
107 @.libxml2/xmllint --valid --noout '$*'
108
109 # ━ § Special targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
110
111 .IGNORE : $(foreach xml,$(xmls),lint][$(xml)) ;
112
113 .PHONY : FORCE build clean dry-sync gone lint $(foreach xml,$(xmls),lint][$(xml)) list prebuild sync uninstall ;
114
115 gone : clean uninstall ;
116
117 uninstall :
118 @for publicfile in $(patsubst %,"%",$(wildcard $(DESTDIR)/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -rf "$$publicfile"; fi; done
119
120 FORCE : ;
121
122 # ━ § Make·file targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
123
124 $(SHUSHE)/GNUmakefile $(YSEME)/GNUmakefile : %/GNUmakefile : FORCE
125 $(GIT) submodule update --init '$*'
126
127 .libxml2/autogen.sh : %/autogen.sh : FORCE
128 $(GIT) submodule update --init '$*'
This page took 0.108404 seconds and 5 git commands to generate.