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.5KB

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