Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/ https://fsfe.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # -----------------------------------------------------------------------------
  2. # Makefile for FSFE website build, preparation for news subdirectory
  3. # -----------------------------------------------------------------------------
  4. .PHONY: all
  5. .SECONDEXPANSION:
  6. # -----------------------------------------------------------------------------
  7. # Copy news archive template to each of the years
  8. # -----------------------------------------------------------------------------
  9. # All years for which a subdirectory exists
  10. ARCH_YEARS := $(sort $(wildcard [0-9][0-9][0-9][0-9]))
  11. # No archive for the current year
  12. ARCH_YEARS := $(filter-out $(lastword $(ARCH_YEARS)),$(ARCH_YEARS))
  13. # ... and the year before
  14. ARCH_YEARS := $(filter-out $(lastword $(ARCH_YEARS)),$(ARCH_YEARS))
  15. # Languages in which the template exists
  16. ARCH_LANGS := $(suffix $(basename $(wildcard archive-template.??.xhtml)))
  17. # .xhtml files to generate
  18. ARCH_XHTML := $(foreach year,$(ARCH_YEARS),$(foreach lang,$(ARCH_LANGS),$(year)/index$(lang).xhtml))
  19. all: $(ARCH_XHTML)
  20. $(ARCH_XHTML): %.xhtml: archive-template$$(suffix $$*).xhtml
  21. @echo "* Creating $@"
  22. @# $(dir $@) returns YYYY/, we abuse the slash for closing the sed command
  23. @sed 's/:YYYY:/$(dir $@)g' $< > $@
  24. # .sources files to generate
  25. ARCH_SOURCES := $(foreach year,$(ARCH_YEARS),$(year)/index.sources)
  26. all: $(ARCH_SOURCES)
  27. $(ARCH_SOURCES): %.sources:
  28. @echo "* Creating $@"
  29. @echo "news/$(dir $@)news-*:[]\nnews/$(dir $@).news-*:[]\nlocalmenuinfo:[]\n" > $@
  30. # .xsl files to generate
  31. ARCH_XSL := $(foreach year,$(ARCH_YEARS),$(year)/index.xsl)
  32. all: $(ARCH_XSL)
  33. $(ARCH_XSL): %.xsl: news.xsl
  34. @echo "* Creating $@"
  35. @sed -r 's/(import href=")/\1..\//; s/(\.\.\/about)/..\/\1/' $< > $@
  36. # -----------------------------------------------------------------------------
  37. # Remove generated .xml files where original .xhtml file does not exist anymore
  38. # -----------------------------------------------------------------------------
  39. # note the reversal of target <-> prerequisite relationship
  40. # make will execute thew command for all xhtml files (targets) that
  41. # do not exist, in doing so it will not make the target, but rather
  42. # remove the xml file that generated it
  43. # All currently existing generated .xml files
  44. GENERATED_XML := $(wildcard */.*.xml)
  45. # List of corresponding source files (foo/.bar.xx.xml -> foo/bar.xx.xhtml)
  46. GENERATED_XML_SOURCES := $(patsubst %.xml,%.xhtml,$(subst /.,/,$(GENERATED_XML)))
  47. all: $(GENERATED_XML_SOURCES)
  48. %.xhtml:
  49. @echo '* Removing $(subst /,/.,$*).xml'
  50. @rm '$(subst /,/.,$*).xml'
  51. # -----------------------------------------------------------------------------
  52. # Generate .xml files from .xhtml files
  53. # -----------------------------------------------------------------------------
  54. # All existing .xhtml files
  55. XHTML := $(shell ls */*.??.xhtml | xargs grep -l '<html newsdate')
  56. # List of .xml files to generate
  57. XML := $(patsubst %.xhtml,%.xml,$(subst /,/.,$(XHTML)))
  58. all: $(XML)
  59. XMLSOURCE = $(patsubst %.xml,%.xhtml,$(subst /.,/,$@))
  60. %.xml: $$(XMLSOURCE) xhtml2xml.xsl
  61. @echo '* Generating $@'
  62. @xsltproc --stringparam link '/news/$(basename $(basename $<)).html' xhtml2xml.xsl '$<' > '$@'