1 # SPDX-FileCopyrightText: 2023, 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
2 # SPDX-License-Identifier: MPL-2.0
6 # Copyright © 2023–2025 Lady [@ Ladys Computer].
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/>.
28 THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
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)'
35 YSEMEOPTS := $(MAKEOPTS) BUILDTARGET='$(BUILDTARGET)' DESTDIR='$(DESTDIR)' SERVERPATH='lady/vocab'
37 xmls := $(wildcard $(DATADIR)/*/*)
39 # ━ § Call out to ⛩📰 书社 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
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)'
47 build : $(SHUSHE)/GNUmakefile
48 @$(RM) -R -f '$(BUILDDIR)/public'
49 @$(MAKE) -f '$<' install $(SHUSHEOPTS)
51 clean list listout : $(SHUSHE)/GNUmakefile
52 @$(MAKE) -f '$<' $@ $(SHUSHEOPTS)
54 $(BUILDDIR)/% : $(SHUSHE)/GNUmakefile FORCE
55 @$(MAKE) -f '$<' $@ $(SHUSHEOPTS)
57 # ━ § Call out to 👥📤 Yseme ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
59 dry-sync sync : $(YSEME)/GNUmakefile
60 @$(MAKE) -f '$<' $@ $(YSEMEOPTS)
62 # ━ § Build xmllint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
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.
69 .libxml2/xmllint : .libxml2/autogen.sh
70 cd .libxml2 && ./autogen.sh
73 # ━ § Linting ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
75 lint : $(foreach xml,$(xmls),lint][$(xml)) ;
77 $(foreach xml,$(xmls),lint][$(xml)) : lint][% : .libxml2/xmllint
78 @.libxml2/xmllint --valid --noout '$*'
80 # ━ § Special targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
82 .IGNORE : $(foreach xml,$(xmls),lint][$(xml)) ;
84 .PHONY : FORCE build clean dry-sync gone lint $(foreach xml,$(xmls),lint][$(xml)) list prebuild sync uninstall ;
86 gone : clean uninstall ;
89 @for publicfile in $(patsubst %,"%",$(wildcard $(DESTDIR)/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -rf "$$publicfile"; fi; done
93 # ━ § Make·file targets ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
95 $(SHUSHE)/GNUmakefile $(YSEME)/GNUmakefile : %/GNUmakefile : FORCE
96 $(GIT) submodule update --init '$*'
98 .libxml2/autogen.sh : %/autogen.sh : FORCE
99 $(GIT) submodule update --init '$*'