Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
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 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # -----------------------------------------------------------------------------
  2. # Makefile for FSFE website build, phase 1
  3. # -----------------------------------------------------------------------------
  4. # This Makefile is executed in the root of the source directory tree, and
  5. # creates some .xml and xhtml files as well as some symlinks, all of which
  6. # serve as input files in phase 2. The whole phase 1 runs within the source
  7. # directory tree and does not touch the target directory tree at all.
  8. # -----------------------------------------------------------------------------
  9. .PHONY: all .FORCE
  10. .FORCE:
  11. # -----------------------------------------------------------------------------
  12. # Dive into subdirectories
  13. # -----------------------------------------------------------------------------
  14. SUBDIRS := $(shell find */* -name "Makefile" | xargs dirname)
  15. all: $(SUBDIRS)
  16. $(SUBDIRS): .FORCE
  17. echo "* Preparing subdirectory $@"
  18. $(MAKE) --silent --directory=$@
  19. # -----------------------------------------------------------------------------
  20. # Handle local menus
  21. # -----------------------------------------------------------------------------
  22. # FIXME: This runs when the makefile is parsed, before maybe new *.xhtml files
  23. # are created in the news/<year>/ and events/<year>/ directories. It would be
  24. # better to move this into a separate script tools/update-localmenus.sh. It
  25. # would also be better if there was a separate .localmenu.en.xml file for each
  26. # directory.
  27. MENUSOURCES := $(shell find -name '*.xhtml' -not -name "*-template.*" | xargs grep -l '<localmenu.*</localmenu>' | sort)
  28. all: localmenuinfo.en.xml
  29. localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES)
  30. { printf '<localmenuset>'; \
  31. grep -E '<localmenu.*</localmenu>' $^ \
  32. | sed -r 's;(.*/)?(.+)\.([a-z][a-z])\.xhtml:(.+);\
  33. <menuitem language="\3"><dir>/\1</dir><link>\2.html</link>\4</menuitem>;'; \
  34. printf '</localmenuset>'; \
  35. } | xsltproc -o $@ $< -
  36. # -----------------------------------------------------------------------------
  37. # Timestamp files for regular jobs and XML inclusion in various places
  38. # -----------------------------------------------------------------------------
  39. YEAR := <?xml version="1.0" encoding="utf-8"?><dateset><date year="$(shell date +%Y)" /></dateset>
  40. MONTH := <?xml version="1.0" encoding="utf-8"?><dateset><date month="$(shell date +%Y-%m)" /></dateset>
  41. DAY := <?xml version="1.0" encoding="utf-8"?><dateset><date day="$(shell date +%Y-%m-%d)" /></dateset>
  42. all: d_year.en.xml d_month.en.xml d_day.en.xml
  43. d_day.en.xml: $(if $(findstring $(DAY),$(shell cat d_day.en.xml)),,.FORCE)
  44. printf %s\\n '$(DAY)' >$@
  45. d_month.en.xml: $(if $(findstring $(MONTH),$(shell cat d_month.en.xml)),,.FORCE)
  46. printf %s\\n '$(MONTH)' >$@
  47. d_year.en.xml: $(if $(findstring $(YEAR),$(shell cat d_year.en.xml)),,.FORCE)
  48. printf %s\\n '$(YEAR)' >$@
  49. # -----------------------------------------------------------------------------
  50. # Create XML symlinks
  51. # -----------------------------------------------------------------------------
  52. # After this step, the following symlinks will exist:
  53. # * tools/.texts-<lang>.xml for each language
  54. # * ./fundraising.<lang>.xml for each language
  55. # Each of these symlinks will point to the corresponding file without a dot at
  56. # the beginning of the filename, if present, and to the English version
  57. # otherwise. This symlinks make sure that phase 2 can easily use the right file
  58. # for each language, also as a prerequisite in the Makefile.
  59. LANGUAGES := $(shell . build/languages.sh && get_languages)
  60. TEXTS_LINKS := $(foreach lang,$(LANGUAGES),tools/.texts-$(lang).xml)
  61. all: $(TEXTS_LINKS)
  62. tools/.texts-%.xml: .FORCE
  63. if [ -f tools/texts-$*.xml ]; then \
  64. ln -sf texts-$*.xml $@; \
  65. else \
  66. ln -sf texts-en.xml $@; \
  67. fi
  68. FUNDRAISING_LINKS := $(foreach lang,$(LANGUAGES),.fundraising.$(lang).xml)
  69. all: $(FUNDRAISING_LINKS)
  70. .fundraising.%.xml: .FORCE
  71. if [ -f fundraising.$*.xml ]; then \
  72. ln -sf fundraising.$*.xml $@; \
  73. else \
  74. ln -sf fundraising.en.xml $@; \
  75. fi
  76. # -----------------------------------------------------------------------------
  77. # Create XSL symlinks
  78. # -----------------------------------------------------------------------------
  79. # After this step, each directory with source files for HTML pages contains a
  80. # symlink named .default.xsl and pointing to the default.xsl "responsible" for
  81. # this directory. These symlinks make it easier for the phase 2 Makefile to
  82. # determine which XSL script should be used to build a HTML page from a source
  83. # file.
  84. # All directories containing source files for HTML pages.
  85. # FIXME: This runs when the makefile is parsed, before maybe new *.xhtml files
  86. # are created in the news/<year>/ and events/<year>/ directories.
  87. XHTML_DIRS := $(patsubst %/,%,$(sort $(dir $(shell find -name '*.??.xhtml'))))
  88. .PHONY: default_xsl
  89. all: default_xsl
  90. default_xsl:
  91. for directory in $(XHTML_DIRS); do \
  92. dir="$${directory}"; \
  93. prefix=""; \
  94. until [ -f "$${dir}/default.xsl" -o "$${dir}" = "." ]; do \
  95. dir="$${dir%/*}"; \
  96. prefix="$${prefix}../"; \
  97. done; \
  98. ln -sf "$${prefix}default.xsl" "$${directory}/.default.xsl"; \
  99. done
  100. # -----------------------------------------------------------------------------
  101. # Update XML filelists
  102. # -----------------------------------------------------------------------------
  103. # After this step, the following files will be up to date:
  104. # * tags/tagged-<tags>.en.xhtml for each tag used. Apart from being
  105. # automatically created, these are regular source files for HTML pages, and
  106. # in phase 2 are built into pages listing all news items and events for a
  107. # tag.
  108. # * tags/.tags.??.xml with a list of the tags useed.
  109. # * <dir>/.<base>.xmllist for each <dir>/<base>.sources as well as for each
  110. # tags/tagged-<tags>.en.xhtml. These files are used in phase 2 to include the
  111. # correct XML files when generating the HTML pages. It is taken care that
  112. # these files are only updated whenever their content actually changes, so
  113. # they can serve as a prerequisite in the phase 2 Makefile.
  114. # This step is handled in an external script, because the list of files to
  115. # generate is not known when the Makefile starts - some new tags might be
  116. # introduced when generating the .xml files in the news/* subdirectories.
  117. .PHONY: xmllists
  118. all: xmllists
  119. xmllists: $(SUBDIRS)
  120. tools/update_xmllists.sh
  121. # -----------------------------------------------------------------------------
  122. # Update XSL stylesheets
  123. # -----------------------------------------------------------------------------
  124. # This step updates (actually: just touches) all XSL files which depend on
  125. # another XSL file that has changed since the last build run. The phase 2
  126. # Makefile then only has to consider the directly used stylesheet as a
  127. # prerequisite for building each file and doesn't have to worry about other
  128. # stylesheets imported into that one.
  129. .PHONY: stylesheets
  130. all: stylesheets
  131. stylesheets: $(SUBDIRS)
  132. tools/update_stylesheets.sh