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 7.4KB

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