Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Dependencies:
  2. # 0. bash, sed, GNU coreutils
  3. # -> Pretty much all functionality
  4. # 1. inkscape
  5. # -> SVG cropping
  6. # -> SVG to PNG conversion (better support than ImageMagick)
  7. # -> SVG to PDF conversion
  8. # 2. scour
  9. # -> SVG compression
  10. # 3. pngcrush
  11. # -> PNG compression
  12. # 4. ps2pdf & ps2eps (ghostscript)
  13. # -> PDF compression (Inkscape supports only uncompressed PDFs)
  14. # -> EPS generation
  15. # 5. convert (ImageMagick)
  16. # -> multi-resolution favicon creation
  17. # 6. python3
  18. # -> Custom script for generating the logo layouts from master SVG
  19. # 7. pdftk
  20. # -> PDF reproducible builds
  21. # 8. exiftool
  22. # -> PDF reproducible builds
  23. # 9. qpdf
  24. # -> PDF reproducible builds
  25. OUTDIR := build
  26. ICONDIR := ${OUTDIR}/icon
  27. TEXTVARIANTS := word tagline1 tagline2
  28. SOLIDTEXTBGS := $(TEXTVARIANTS:%=%-whitebg-blackfg) $(TEXTVARIANTS:%=%-blackbg-whitefg) $(TEXTVARIANTS:%=%-mono-blackbg-whitefg) $(TEXTVARIANTS:%=%-mono-whitebg-blackfg)
  29. CLEARTEXTBGS := $(TEXTVARIANTS:%=%-clearbg-blackfg) $(TEXTVARIANTS:%=%-clearbg-whitefg) $(TEXTVARIANTS:%=%-mono-clearbg-blackfg) $(TEXTVARIANTS:%=%-mono-clearbg-whitefg)
  30. SOLIDPICBGS := pictorial-whitebg pictorial-blackbg pictorial-mono-blackbg-whitefg pictorial-mono-whitebg-blackfg
  31. CLEARPICBGS := pictorial-clearbg
  32. SOLIDBGS := ${SOLIDTEXTBGS} ${SOLIDPICBGS}
  33. CLEARBGS := ${CLEARTEXTBGS} ${CLEARPICBGS}
  34. EXTS := $(SOLIDBGS:%=%.svg) $(SOLIDBGS:%=%.png) $(SOLIDBGS:%=%.pdf) $(SOLIDBGS:%=%.eps) $(CLEARBGS:%=%.svg) $(CLEARBGS:%=%.png) $(CLEARBGS:%=%.pdf)
  35. ICONSIZES := 256 228 196 180 167 152 144 128 120 96 76 70 64 57 48 32 24 16
  36. SIMPLEICONSIZES := 64 48 32 16
  37. ICONS := $(ICONSIZES:%=icon-%.png) icon.ico favicon.ico icon.svg
  38. FILEPREFIX := crysp-logo
  39. FILES := $(EXTS:%=${OUTDIR}/${FILEPREFIX}-%) $(ICONS:%=${ICONDIR}/${FILEPREFIX}-%)
  40. .ONESHELL:
  41. SHELL = /bin/bash
  42. all: $(FILES)
  43. ${BGS}: ${FILES}
  44. %.svg: %.1.svg
  45. scour -i "$<" -o "$@" --remove-descriptive-elements --enable-viewboxing --enable-id-stripping --enable-comment-stripping --shorten-ids --indent=none --no-line-breaks
  46. %.1.svg: %.2.svg
  47. inkscape "$<" --export-area-drawing --export-plain-svg "--export-filename=$@"
  48. %.2.svg:
  49. mkdir -p ${@D}
  50. cat master_template.svg | python3 proc-template.py "$(*F)" > "$@"
  51. %.png: %.1.png
  52. pngcrush "$<" "$@"
  53. if ((`stat -c%s "$@"` > `stat -c%s "$<"`)) ; then
  54. cp "$<" "$@"
  55. fi
  56. %.1.png: %.svg
  57. f="$@"
  58. re="^.*-([hw])([0-9]+)\.1\.png$$"
  59. if [[ $$f =~ $$re ]] ; then
  60. mode="$${BASH_REMATCH[1]}"
  61. dim="$${BASH_REMATCH[2]}"
  62. if [ "$$mode" == "h" ] ; then
  63. inkscape "$<" --export-type="png" "--export-filename=$@" "--export-height=$$dim"
  64. else
  65. inkscape "$<" --export-type="png" "--export-filename=$@" "--export-width=$$dim"
  66. fi
  67. else
  68. inkscape "$<" --export-type="png" "--export-filename=$@"
  69. fi
  70. %.pdf: %.1.pdf
  71. /bin/bash strip-pdf-metadata.sh "$<" "$@"
  72. %.1.pdf: %.2.pdf
  73. ps2pdf -dEPSCrop "$<" "$@"
  74. %.2.pdf: %.svg
  75. inkscape "$<" --export-type="pdf" "--export-filename=$@"
  76. %.eps: %.1.eps
  77. cat "$<" | ps2eps | sed -e ':a;N;$$!ba;s/\n%%CreationDate:[^\n]\+\n/\n/g' > "$@"
  78. %.1.eps: %.svg
  79. inkscape "$<" --export-type="eps" "--export-filename=$@"
  80. TMPICONSRC := ${ICONDIR}/tmp-favicon-icon-clearbg.svg
  81. COMMA := ,
  82. EMPTY :=
  83. SPACE := ${EMPTY} ${EMPTY}
  84. ${ICONDIR}/%-icon.svg: ${TMPICONSRC}
  85. cp "$<" "$@"
  86. # This file is huge because ICOs don't support compressed PNGs; they are always
  87. # RGBA (32 bits per pixel) uncompressed (no palette or anything fancy allowed).
  88. %-icon.ico: ${TMPICONSRC}
  89. convert -density 384 -background transparent "${TMPICONSRC}" -flatten -colors 256 -define "icon:auto-resize=$(subst ${SPACE},${COMMA},${ICONSIZES})" "$@"
  90. %-favicon.ico: ${TMPICONSRC}
  91. convert -density 384 -background transparent "${TMPICONSRC}" -flatten -colors 256 -define "icon:auto-resize=$(subst ${SPACE},${COMMA},${SIMPLEICONSIZES})" "$@"
  92. ${ICONDIR}/%.1.png: ${TMPICONSRC}
  93. inkscape "${TMPICONSRC}" "--export-width=$(subst .1.png,,$(subst ${ICONDIR}/${FILEPREFIX}-icon-,,$@))" "--export-height=$(subst .1.png,,$(subst ${ICONDIR}/${FILEPREFIX}-icon-,,$@))" --export-type="png" "--export-filename=$@"
  94. .PHONY: clean
  95. clean:
  96. rm -rf "${OUTDIR}"