]> Lady’s Gitweb - Shushe/blobdiff - GNUmakefile
Fix magic file generation in non‐default location
[Shushe] / GNUmakefile
index 72712c8521086ebaec9269aedbb958141ecedfc4..d1a7f6ec0eff1a6f33d4f118244b3330ba9f133a 100644 (file)
@@ -16,6 +16,7 @@ override define makefileinfo
 ║│                                                            │║
 ║│ • cat                                                      │║
 ║│ • cp                                                       │║
+║│ • date                                                     │║
 ║│ • echo                                                     │║
 ║│ • file                                                     │║
 ║│ • find                                                     │║
@@ -25,6 +26,7 @@ override define makefileinfo
 ║│ • rm                                                       │║
 ║│ • sed                                                      │║
 ║│ • sleep                                                    │║
+║│ • stat                                                     │║
 ║│ • test                                                     │║
 ║│ • touch                                                    │║
 ║│ • tr (requires support for `-d´)                           │║
@@ -79,6 +81,7 @@ endef
 # different implementation, you can override the appropriate variable.
 CAT := cat
 CP := cp
+DATE := date
 ECHO := echo
 FILE := file
 FIND := find
@@ -88,6 +91,7 @@ PRINTF := printf
 RM := rm
 SED := sed
 SLEEP := sleep
+STAT := stat
 TEST := test
 TOUCH := touch
 TR := tr
@@ -242,7 +246,7 @@ override sourcefile = $(foreach file,$1,$(if $(filter about:shushe?include=%,$(f
 # This file is created after a reload due to type changes, and is
 # removed after. Requiring it ensures that file classifications are
 # up‐to‐date immediately after the reload.
-override typeupdates := $(if $(wildcard $(BUILDDIR)/.update-types),$(BUILDDIR)/.update-types,)
+override typeupdates := $(wildcard $(BUILDDIR)/.update-types)
 
 # (callable) Get the location of the transformed X·M·L files for the
 # given source files.
@@ -332,6 +336,21 @@ $(call compiled,$(recursivefiles)): $(BUILDDIR)/public/%:
 # Phony rules; always consider these out‐of‐date.
 .PHONY: all default clean gone info install list $(call compiled,$(recursivefiles));
 
+ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies),)
+# Reload this make·file if the dependency graph has changed.
+#
+# This graph is a dependency for some of the variables that this
+# make·file uses, so it’s important to ensure that they are actually
+# up‐to‐date prior to executing any later rules.
+#
+# This recipe only exists after types have been updated or when the
+# dependency graph already exists.
+$(THISDIR)/GNUmakefile:: $(BUILDDIR)/dependencies
+       $(silent)$(TOUCH) $(THISDIR)/GNUmakefile
+       $(silent)$(RM) -f $(BUILDDIR)/.update-types
+       @$(PRINTF) '%b\n' '\0033[1mDependency graph updated. Restarting…\0033[22m'
+endif
+
 ifeq ($(wildcard $(BUILDDIR)/.update-types),)
 # Reload this make·file if any of the magic files or parsers have
 # changed.
@@ -343,25 +362,10 @@ ifeq ($(wildcard $(BUILDDIR)/.update-types),)
 # the restart have a more current time·stamp.
 $(THISDIR)/GNUmakefile:: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(THISDIR)/lib/parser2types.xslt
        $(silent)$(TOUCH) $(THISDIR)/GNUmakefile
-       $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types)
        $(silent)$(RM) -f $(call quote,$(BUILDDIR)/dependencies)
        @$(PRINTF) '%b\n' '\0033[1mMagic file or parsers have updated. Restarting…\0033[22m'
        $(silent)$(SLEEP) 1
-endif
-
-ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies),)
-# Reload this make·file if the dependency graph has changed.
-#
-# This graph is a dependency for some of the variables that this
-# make·file uses, so it’s important to ensure that they are actually
-# up‐to‐date prior to executing any later rules.
-#
-# This recipe only exists after types have been updated or when the
-# dependency graph already exists.
-$(THISDIR)/GNUmakefile:: $(BUILDDIR)/dependencies
-       $(silent)$(TOUCH) $(THISDIR)/GNUmakefile
-       $(silent)$(RM) -f $(BUILDDIR)/.update-types
-       @$(PRINTF) '%b\n' '\0033[1mDependency graph updated. Restarting…\0033[22m'
+       $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types)
 endif
 
 # ─ ¶ Build Targets ───────────────────────────────────────────────────
@@ -374,8 +378,7 @@ endif
 $(BUILDDIR)/magic.mgc: $(wildcard $(MAGICDIR)/*)
        @$(ECHO) "Compiling new magic…"
        $(silent)$(call ensuredirectory,$(dir $@))
-       $(silent)$(FILE) -C -m $(call quote,$(MAGICDIR))
-       $(silent)$(MV) $(call quote,$(MAGICDIR).mgc) $(call quote,$(BUILDDIR)/magic.mgc)
+       $(silent)cd $(call quote,$(BUILDDIR)) && $(FILE) -C -m $(call quote,$(realpath $(MAGICDIR)))
 
 # Generate the main parser.
 $(BUILDDIR)/parser.catalog: $(PARSERS)
@@ -386,12 +389,6 @@ $(BUILDDIR)/parser.xslt: $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parse
        @$(ECHO) "Generating main parser…"
        $(silent)$(XSLTPROC) -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2parser.xslt) $(call quote,$<)
 
-# Note updates to parsers or magic.
-#
-# This file is actually generated as part of the make·file restart
-# process, so it doesn’t need any recipes.
-$(BUILDDIR)/.update-types: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(THISDIR)/lib/parser2types.xslt ;
-
 # Parse the files.
 #
 # Even plain X·M·L files are parsed, because they may contain X·H·T·M·L
@@ -431,7 +428,7 @@ $(BUILDDIR)/transform.xslt: $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalog
 $(call compiled,$(compilablefiles)): $(BUILDDIR)/public/%: $$(call parsed,$(SRCDIR)/%) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$(SRCDIR)/%))
        $(silent)$(call ensuredirectory,$(dir $@))
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
-       $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam catalog 'catalog' $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam catalog 'catalog' --stringparam buildtime '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam srctime '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(SRCDIR)/$*))' --stringparam path $(call quote,/$*) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
 $(call compiled,$(filter $(assetfiles),$(sourcefiles))): $(BUILDDIR)/public/%: $(SRCDIR)/%
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
        $(silent)$(call ensuredirectory,$(dir $@))
This page took 0.025188 seconds and 4 git commands to generate.