Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ## Locations
  2. SRCDIR=src
  3. outdir=out
  4. distdir=dist
  5. ## Extra headers for generated HTML
  6. rss_header='<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="rss.xml" />'
  7. atom_header='<link rel="alternate" type="application/atom+xml" title="Atom Feed" href="atom.xml" />'
  8. extra_headers=$(rss_header)$(atom_header)$(track_header)
  9. ## Files
  10. _STATIC_FILES=$(shell find static -type f -name \*)
  11. STATIC_OUT=$(patsubst static/%,out/%,$(_STATIC_FILES))
  12. _PAGES=$(shell find src/*.texi)
  13. BLOG_PAGES=$(patsubst src/%.texi,%.html,$(_PAGES))
  14. LATEST_FILE=$(shell ls -1 src/posts/*-*-*.texi|tail -1)
  15. LATEST_NODE=$(shell awk '/@node / {$$1=""; gsub(/^ /,""); print $$0}' ${LATEST_FILE})
  16. LATEST_DATE=$(shell grep @date ${LATEST_FILE}|cut -d" " -f 2)
  17. #POSTS=$(shell find src/posts/*.texi)
  18. _POSTS=$(shell ls -1r src/posts/*.texi | tr \\n ,)
  19. POSTS=$(shell ls -rm src/posts/*texi)
  20. #POSTS_PAGES=$(patsubst src/%.texi,%.html,$(_POSTS))
  21. #POSTS=$(wildcard src/*.texi)
  22. HTML_POSTS=$(shell for f in out/*html; do awk -v _fname=$$f '/id="_article_date"/ { if (match($$0, /_article_date">(.*)</, a)) print a[1] " " _fname}' $$f; done|sort -r|awk '{print $$2}'|tr \\n ,)
  23. ## Rules
  24. .PHONY: all test posts.texi info last-update dist nav
  25. all: src/posts.texi src/config.texi src/index.html $(STATIC_OUT) atom.xml rss.xml nav
  26. test:
  27. @echo EXTRA_HEAD=$(extra_headers)
  28. # -c TOC_LINKS=0
  29. src/index.html: src/posts.texi src/config.texi
  30. @texi2any -c USE_XML_SYNTAX=0 -c SIMPLE_MENU=0 -c MENU_SYMBOL='&#9642;&nbsp;' -c COPIABLE_LINKS=1 \
  31. -c AVOID_MENU_REDUNDANCY=0 -c TOC_LINKS=0 -c NODE_NAME_IN_INDEX=0 -c NODE_NAME_IN_MENU=1 -c SECTION_NAME_IN_TITLE=1 -c FORMAT_MENU="menu" \
  32. -c MENU_ENTRY_COLON=" " -c CHECK_NORMAL_MENU_STRUCTURE=1 -c PROGRAM_NAME_IN_FOOTER=1 -c SHOW_TITLE=1 -c DATE_IN_HEADER=1 \
  33. -c NO_CUSTOM_HTML_ATTRIBUTE=1 -c EXTRA_HEAD=$(extra_headers) --html --css-ref=styles/brutex.css \
  34. -c HIGHLIGHT_SYNTAX="pygments" -c CONTENTS_OUTPUT_LOCATION="separate_element" \
  35. --no-number-sections -o $(outdir) -I static/ --internal-links=out/int-links.txt src/index.texi
  36. out/%: static/%
  37. @mkdir -p $(@D)
  38. @cp -r $< $@
  39. src/config.texi: src/config.texi.m4 src/config.m4
  40. # @echo Latest: ${LATEST_FILE} ${LATEST_DATE} "${LATEST_NODE}"
  41. @m4 -D__latest_date=${LATEST_DATE} -D__latest_file=${LATEST_FILE} -D__latest_node="${LATEST_NODE}" -I src -I src/lib $< > $@
  42. clean:
  43. @echo "Removed output dir"
  44. @rm -rf $(outdir) $(distdir)
  45. @echo "Removed generated files"
  46. @rm -f src/config.texi src/posts.texi
  47. info: src/posts.texi src/config.texi
  48. @texi2any -I static/ src/index.texi -o out/website.info
  49. txt: src/posts.texi src/config.texi
  50. @texi2any -I static/ src/index.texi --plaintext -o out/website.txt
  51. pdf: src/posts.texi src/config.texi
  52. @texi2any -I static/ src/index.texi --pdf -o out/website.pdf
  53. dist: all
  54. @mkdir -p $(distdir)
  55. @tar zcvf $(distdir)/website.tar.gz $(outdir)
  56. rss.xml: src/rss.m4 src/index.html
  57. @m4 -D__html_files=$(HTML_POSTS) -I src -I src/lib $< > out/$@
  58. atom.xml: src/atom.m4 src/index.html
  59. @m4 -D__html_files=$(HTML_POSTS) -I src -I src/lib $< > out/$@
  60. src/posts.texi: src/posts.m4
  61. @m4 -D__post_files="$(POSTS)" -I src -I src/lib $< > $@
  62. ## Add a "Top" navigation button. This should be doable using texi2any
  63. ## (which would be better)
  64. nav: src/index.html
  65. @awk -i inplace '{ if (match($$ 0,/\[.*Contents.*\]\[.*Index.*\]/,a)) { gsub(/<\/p>/,"[<a href=\"index.html\">Top</a>] </p>"); print } else { print }}' $(outdir)/*html