X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/55fc968f72857e25fcafe6088c873f5032555c79..d94cfdc987aba3983f4945d59b02cbb062573432:/GNUmakefile?ds=inline diff --git a/GNUmakefile b/GNUmakefile index 6d68702..174f340 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 @@ -130,11 +134,13 @@ MAGICDIR := $(patsubst ./%,%,$(THISDIR)/magic) # Configuration of `find´. # -# By default, `find´ will follow symlinks and use extended regular -# expressions, ignoring hidden files and those which begin with a -# period. -FINDOPTS := -LE +# By default, `find´ will not follow symlinks and will use extended +# regular expressions, ignoring hidden files and those which begin with +# a period. +FINDOPTS := -PE FINDRULES := -flags -nohidden -and -not -name '.*' +FINDINCLUDEOPTS := $(FINDOPTS) +FINDINCLUDERULES := $(FINDRULES) # The list of parsers for plaintext file types. # @@ -189,7 +195,7 @@ override silent := $(if $(VERBOSE),,@) # (callable) Escape special characters for use in sed regular # expressions. -override sedesc = $(subst $$,\$$,$(subst *,\*,$(subst .,\.,$(subst [,\[,$(subst ^,\^,$(subst \,\\,$1)))))) +override sedesc = $(subst /,[/],$(subst $$,\$$,$(subst *,\*,$(subst .,\.,$(subst [,\[,$(subst ^,\^,$(subst \,\\,$1))))))) # Collect all of the applicable includes from the includes directory. sourceincludes := $(shell $(FIND) $(FINDOPTS) $(INCLUDEDIR) -type f '(' $(FINDRULES) ')') @@ -298,7 +304,7 @@ help: $(silent)$(PRINTF) '%b' '$(subst $(newline),\n,$(makefileinfo))' # Compile all files, or error if any are recursive. -all: $(call compiled,$(recursivefiles) $(compilablefiles) $(assetfiles)) ; +all: $(call compiled,$(recursivefiles) $(compilablefiles) $(filter $(sourcefiles),$(assetfiles))) ; # Destroy buildfiles. clean: @@ -309,7 +315,7 @@ gone: $(silent)$(RM) -rf $(BUILDDIR)/ $(call compiled,$(recursivefiles) $(compilablefiles)) # Install the compiled files into `DESTDIR´. -install: $(call installed,$(recursivefiles) $(compilablefiles) $(assetfiles)) ; +install: $(call installed,$(recursivefiles) $(compilablefiles) $(filter $(sourcefiles),$(assetfiles))) ; # List all source files and includes and their computed types. list: @@ -374,8 +380,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) @@ -425,7 +430,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 $@))