Newer
Older
trm / makefile
  1. # Build a release of 'trm' using 'make'
  2. # Requires a modern 'make' like GNU.
  3.  
  4. # Uncomment One Of The Following For Early Releases
  5.  
  6. #EARLY = -Alpha
  7. #EARLY = -Beta
  8. #EARLY = -RC1
  9. VERSION = $(shell cat version)${EARLY}
  10.  
  11.  
  12. #####
  13. # Definitions Relevant To This Program
  14. #####
  15.  
  16. PROGNAME = trm
  17. PROGMAIN = trm.sh
  18.  
  19. PROGFILES = ${PROGMAIN}
  20. PROGDOCS = ${PROGMAIN}.ps
  21.  
  22. DOCS = ${PROGNAME}.1.gz \
  23. ${PROGNAME}.html \
  24. ${PROGNAME}.pdf \
  25. ${PROGNAME}.ps \
  26. ${PROGNAME}.rst \
  27. ${PROGNAME}.txt \
  28.  
  29. SUPPORT = ${PROGNAME}-license.txt \
  30. CHANGELOG.txt \
  31. WHATSNEW.txt
  32.  
  33.  
  34. #####
  35. # Nothing Should Need To Change Below This Line
  36. #####
  37.  
  38.  
  39. DIR = ${PROGNAME}-${VERSION}
  40. HEADER1 = "WHATSNEW For '${PROGNAME}' ${VERSION} (`date`)"
  41. HEADER2 = "----------------------------------------------------------------------"
  42. RELEASES = "Releases"
  43. TARBALL = ${DIR}.tar.gz
  44. TMPFILE = tmpfile
  45.  
  46.  
  47. #####
  48. # Pattern Rules
  49. #####
  50.  
  51. ###
  52. # Document Production
  53. ###
  54.  
  55. # Some Docutils installations keep the ".py" suffix for the various
  56. # frontend programs, and some do not. It's even possible there are
  57. # links from one to the other. Since the project can be checked out
  58. # on any platform, we have to check for this every time we run the
  59. # 'make'. This is irritating.
  60.  
  61. 2HTML = $(shell which rst2html.py rst2html | tr '\012' ' ' | awk '{print $$1}') --no-compact-lists
  62. 2LATEX = $(shell which rst2latex.py rst2latex | tr '\012' ' ' | awk '{print $$1}') --stylesheet=parskip --latex-preamble="\usepackage{fullpage}"
  63. 2ODT = $(shell which rst2odt.py rst2odt 2>/dev/null | head -n 1)
  64. 2MAN = $(shell which rst2man.py rst2man 2>/dev/null | head -n 1)
  65.  
  66. # TeX/LaTeX Processing
  67.  
  68. DVIPS = dvips
  69. PDFLATEX = pdflatex
  70. LATEX = latex
  71.  
  72. %.dvi : %.latex
  73. ${LATEX} $*.latex
  74.  
  75. %.html : %.rst
  76. ${2HTML} <$*.rst >$*.html
  77.  
  78. %.latex : %.rst
  79. ${2LATEX} $*.rst >$*.latex
  80.  
  81. %.1 : %.rst
  82. ${2MAN} <$*.rst >$*.1
  83.  
  84. %.1.gz: %.1
  85. @gzip -c <$*.1 >$*.1.gz
  86.  
  87. %.odt : %.rst
  88. ${2ODT} <$*.rst >$*.odt
  89.  
  90. %.pdf : %.latex
  91. ${PDFLATEX} $*.latex
  92. ${PDFLATEX} $*.latex
  93. ${PDFLATEX} $*.latex
  94.  
  95. %.ps : %.dvi
  96. ${DVIPS} $*.dvi
  97.  
  98. %.txt: %.1
  99. @groff -man -Tascii $< | col -xb >$@
  100.  
  101. ###
  102. # Pretty Print Programs & Scripts
  103. ###
  104.  
  105. %.pl.ps: %.pl
  106. @enscript -Eperl --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<
  107.  
  108. %.py.ps: %.py
  109. @enscript -Epython --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<
  110.  
  111. %.sh.ps: %.sh
  112. @enscript -Esh --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<
  113.  
  114.  
  115. #####
  116. # Actual Build Rules
  117. #####
  118.  
  119. FORCE:
  120.  
  121. CHANGELOG.txt: FORCE
  122. @git log --pretty=format:"%h%x20%an%x20%ad%x20%s" ${PROGMAIN} >CHANGELOG.txt
  123.  
  124. WHATSNEW.txt: FORCE
  125. @printf "%s\n%s\n\n" ${HEADER1} ${HEADER2} | cat - $@ >${TMPFILE}
  126. @mv ${TMPFILE} $@
  127. @emacs -nw $@
  128. @git add $@
  129.  
  130. docs: ${DOCS} ${PROGDOCS} ${SUPPORT}
  131. @chmod 644 ${DOCS} ${PROGDOCS}
  132. @chmod 644 *.gz *.txt
  133.  
  134. fixrev: FORCE
  135. @sed -i "s/^GITID.*/GITID=\'$(shell git log --pretty=format:"%h%x20%an%x20%ad"\' | head -n1)/" ${PROGNAME}.sh
  136. @sed -i "s/^VERSION.*/VERSION=\'${VERSION}'/" ${PROGNAME}.sh
  137. @sed -i "s/Id:.*/Id: \'$(shell git log --pretty=format:"%h%x20%an%x20%ad"\' | head -n1)/" ${PROGNAME}.rst
  138. @git add ${PROGNAME}.sh ${PROGNAME}.rst
  139.  
  140. release: docs fixrev ${PROGFILES}
  141. @git commit -m${HEADER1}
  142. @git push
  143. @mkdir -p ${DIR}/Docs
  144. -@mkdir -p ${RELEASES} 2>&1 >/dev/null
  145. @cp -pv ${DOCS} ${PROGDOCS} ${DIR}/Docs
  146. @cp -pv ${SUPPORT} ${PROGFILES} ${DIR}/
  147. @tar -czvf ${TARBALL} --exclude CVS ${DIR}
  148. @rm -rf ${DIR}
  149. @mv ${DIR}.tar.gz ${RELEASES}
  150.  
  151.  
  152. #####
  153. # Housekeeping
  154. #####
  155.  
  156. clean: FORCE
  157. @rm -rf ${PROGNAME}.txt CHANGELOG.txt *~ *.1 *.1.gz *.aux *.core *.dvi *.gz *html *.latex *.log *.out *.pdf *.ps tmpfile *.toc
  158.  
  159. version: FORCE
  160. @echo ${VERSION}