summaryrefslogtreecommitdiff
path: root/Makefile
blob: 72d01a7b81af1d2f2695bb1b7115bf5e6fd7c343 (plain)
  1. # expensive checks enabled: make -B flightcheck=1
  2. # Final document: make -B final=1
  3. stem = eut
  4. source_baseurl = http://euwiki.org/
  5. source_basename = EUT/2nd-edition
  6. citeproc_file = $(stem).bib
  7. templates = template.tex header.tex before.tex after.tex
  8. filters = ./pandoc-memoir ./pandoc-emphasis ./pandoc-cs1 ./pandoc-todo
  9. filters += $(if $(citeproc_file),pandoc-citeproc)
  10. filters += ./pandoc-iri
  11. markdown_includes = copyright.md colophon.md
  12. includes += $(markdown_includes:.md=.tex)
  13. localperlfilters = $(filter ./%,$(filters))
  14. title = Ensuring utmost transparency
  15. subtitle = Free Software and Open Standards under the Rules of Procedure of the European Parliament
  16. env_filter += $(citeproc_file:%=PANDOC_CITEPROC_FILE=%)
  17. env_filter += $(if $(flightcheck),NETWORK_TESTS=1)
  18. args_filter += $(filters:%=--filter %)
  19. args_meta += $(citeproc_file:%=-M bibliography=%)
  20. args_meta += -V lang=english -V langoption=variant=british
  21. args_meta += -M title="$(title) - $(subtitle)"
  22. args_meta += -V title="$(title)"
  23. args_meta += -V subtitle="$(subtitle)"
  24. args_meta += -M author="Carlo Piana, Ulf Öberg"
  25. args_meta += -V author="Carlo Piana" -V author="Ulf Öberg"
  26. args_meta += -V date=""
  27. args_meta += -M csl=oscola-no-ibid.csl
  28. args_latex += --template=template.tex --latex-engine=xelatex
  29. args_latex += -H header.tex -B before.tex -A after.tex
  30. args_latex += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata"
  31. args_latex += -V documentclass=memoir -V pagestyle=plain -V headstyles=komalike -V chapterstyle=ell
  32. args_latex += -V frontmatter=yes -V classoption=titlepage -V classoption=$(if $(final),final,draft)
  33. #flavors = a4 book ebook
  34. flavors = a4 ebook
  35. args_a4 = -V papersize=a4paper -V fontsize=10pt -V classoption=twoside
  36. args_a4 += -M isbn="978-90-823692-1-2" -V coverpage="$(stem)-a4-front.pdf"
  37. args_book = -V papersize=b5paper -V fontsize=10pt -V classoption=twoside
  38. args_ebook = -V papersize=a5paper -V fontsize=12pt -V classoption=oneside -V classoption=openany
  39. args_ebook += -M isbn="978-90-823692-0-5" -V isbn-nobarcode=1 -V coverpage="$(stem)-a4-front.pdf"
  40. args_ebook += -H header-ebook.tex
  41. all: $(flavors:%=$(stem)-%.pdf)
  42. download:: get-$(stem).raw
  43. download:: get-$(stem)-front-logo2.bmp get-$(stem)-front-a4-orig.svg
  44. download:: get-$(stem)-front-photo-orig.jpg
  45. download:: get-fonts
  46. get-$(stem).raw: get-%:
  47. # FIXME: website apparently down (last checked 2017-03-30)
  48. #./mediawiki-fetch $(source_baseurl) $(source_basename) $*
  49. get-$(stem)-front-photo-orig.jpg: get-%:
  50. curl -Ro '$*' 'http://audiovisual.europarl.europa.eu/Asset.aspx?type=nl&id=52c6e976-dd19-4a10-a8f0-afebae7fddd8'
  51. get-$(stem)-front-logo2.bmp: get-%:
  52. curl -Ro '$*' 'http://siri.biks.dk/transparency/GreensEFA-EN.bmp'
  53. get-$(stem)-front-a4-orig.svg: get-%:
  54. curl -Ro '$*' 'http://siri.biks.dk/transparency/transparency_front.svg'
  55. get-fonts:
  56. curl -RLO https://github.com/cyrealtype/Lora-Cyrillic/raw/master/fonts/ttf/Lora-{Regular,Italic,Bold,BoldItalic}.ttf
  57. curl -RLo quattrocento-sans-v2.0.zip http://www.impallari.com/media/uploads/prosources/update-19-source.zip
  58. unzip -uo quattrocento-sans-v2.0.zip quattrocento-sans-v2.0/*.ttf
  59. install-fonts:
  60. mkdir -p ~/.fonts
  61. cp -ft ~/.fonts Lora-*.ttf quattrocento-sans-v2.0/*.ttf
  62. $(stem)-front-photo.jpg: $(stem)-front-photo-orig.jpg
  63. cp -f $< $@
  64. jpegoptim --strip-all --all-progressive --force $@
  65. $(stem)-front-logo2.png: $(stem)-front-logo2.bmp
  66. optipng -clobber $<
  67. $(stem)-front-a4.svg: $(stem)-front-a4-orig.svg eut-front-logo2.png eut-front-photo.jpg
  68. cp -f $< $@
  69. perl -i -pe 's,xlink:href="\K[^\"]+\.bmp,eut-front-logo2.png,' $@
  70. perl -i -pe 's,xlink:href="\K[^\"]+\.jpg,eut-front-photo.jpg,' $@
  71. $(stem)-a4-front.pdf: $(stem)-front-a4.svg
  72. inkscape -z --export-pdf=$@ $<
  73. $(stem).mw: $(stem).raw
  74. ./mediawiki-trim $< $@
  75. ./mediawiki-blockquote $@
  76. ./mediawiki-uri-escape $@
  77. ./mediawiki-matter $@
  78. $(stem).native: $(stem).mw $(localperlfilters)
  79. # validate syntax and dependencies of local Perl filters
  80. set -e; $(foreach filter,$(localperlfilters),perl -c $(filter);)
  81. # convert content from mediawiki to pandoc-native
  82. $(env_filter) pandoc -f mediawiki --smart $(args_meta) $(args_filter) -o $@ $<
  83. # tweak pandoc-native data
  84. ./native-hacks $@
  85. $(markdown_includes:.md=.tex): %.tex: %.md
  86. pandoc -f markdown -t latex --chapters -o $@ $<
  87. $(flavors:%=deps-%):: $(templates) $(includes) Makefile
  88. deps-a4:: $(deps) $(stem)-a4-front.pdf
  89. deps-ebook:: $(deps) $(stem)-a4-front.pdf header-ebook.tex
  90. $(flavors:%=$(stem)-%.pdf): $(stem)-%.pdf: $(stem).native $(deps-all) deps-%
  91. pandoc --standalone --no-tex-ligatures $(args_meta) $(args_latex) $(args_$*) -o $@ $<
  92. clean:
  93. rm -f $(foreach ext,native bib mw,$(stem:%=%.$(ext)))
  94. rm -f $(includes)
  95. distclean: clean
  96. rm -f $(stem:%=%.raw) $(stem:%=%-a4-front.pdf)