diff --git a/depend.mk b/depend.mk index b87a15e..9913b84 100644 --- a/depend.mk +++ b/depend.mk @@ -19,7 +19,7 @@ dvips: which dvips || sudo pkg_add ghostscript else dvips: - which dvips || sudo apt-get install texlive-full + which dvips || sudo apt install texlive-full endif .PHONY: pdf2ps @@ -28,7 +28,7 @@ pdf2ps: which pdf2ps || sudo pkg_add ghostscript else pdf2ps: - which pdf2ps || sudo apt-get install texlive-full + which pdf2ps || sudo apt install texlive-full endif .PHONY: latex @@ -37,7 +37,7 @@ latex: which latex || sudo pkg_add texlive_texmf-full else latex: - which latex || sudo apt-get install texlive-full + which latex || sudo apt install texlive-full endif .PHONY: latexmk @@ -46,7 +46,7 @@ latexmk: which latexmk || sudo pkg_add latexmk else latexmk: - which latexmk || sudo apt-get install latexmk + which latexmk || sudo apt install latexmk endif .PHONY: pax @@ -55,7 +55,7 @@ pax: which pax else pax: - which pax || sudo apt-get install pax + which pax || sudo apt install pax endif .PHONY: sed @@ -86,7 +86,7 @@ git: which git || sudo pkg_add git git-svn else git: - which git || sudo apt-get install git git-svn + which git || sudo apt install git git-svn endif .PHONY: wget @@ -95,7 +95,7 @@ wget: which wget || sudo pkg_add wget else wget: - which wget || sudo apt-get install wget + which wget || sudo apt install wget endif .PHONY: localc @@ -104,7 +104,7 @@ localc: which localc || sudo pkg_add libreoffice else localc: - which localc || sudo apt-get install libreoffice + which localc || sudo apt install libreoffice endif .PHONY: soffice @@ -113,7 +113,7 @@ soffice: which soffice || sudo pkg_add libreoffice else soffice: - which soffice || sudo apt-get install libreoffice + which soffice || sudo apt install libreoffice endif .PHONY: dia @@ -122,7 +122,7 @@ dia: which dia || sudo pkg_add dia else dia: - which dia || sudo apt-get install dia + which dia || sudo apt install dia endif .PHONY: inkscape @@ -131,7 +131,7 @@ inkscape: which inkscape || sudo pkg_add inkscape else inkscape: - which inkscape || sudo apt-get install inkscape + which inkscape || sudo apt install inkscape endif .PHONY: noweb @@ -140,7 +140,16 @@ noweb: which noweb || sudo pkg_add noweb else noweb: - which noweb || sudo apt-get install noweb + which noweb || sudo apt install noweb +endif + +.PHONY: pandoc +ifeq (${MAKE},gmake) +pandoc: + which pandoc || sudo pkg_add pandoc +else +pandoc: + which pandoc || sudo apt install pandoc endif diff --git a/haskell.mk b/haskell.mk new file mode 100644 index 0000000..aa7f8bf --- /dev/null +++ b/haskell.mk @@ -0,0 +1,3 @@ +.SUFFIXES: .hs +.hs.o: + ghc -c $< diff --git a/latexmkrc b/latexmkrc index a31b397..725b17c 100644 --- a/latexmkrc +++ b/latexmkrc @@ -18,7 +18,7 @@ sub pythontex { # side effects in creating other files. The dependence is a way # of triggering the rule to be run whenever the .pytxcode file # changes, and to do this before running latex/pdflatex again. - return system("pythontex --verbose --interpreter python:python3 \"$_[0]\"") ; + return system("pythontex --verbose --interpreter python:python3 \"$_[0]\""); } diff --git a/miun.depend.mk b/miun.depend.mk index 7d333a0..9efeb4e 100644 --- a/miun.depend.mk +++ b/miun.depend.mk @@ -7,6 +7,8 @@ MIUN_DEPEND_MK=true CONF?= /etc/mk.conf -include ${CONF} +CURRENT_URL=https://github.com/dbosk/miuntex/releases/download/v1.0 + .PHONY: clean-depends @@ -25,7 +27,7 @@ ${miunmisc-depend} ${logo-depend}: MIUNMISC_FILES= MU_logotyp_int_CMYK.eps MU_logotyp_int_CMYK.pdf MIUNMISC_FILES+= MU_logotyp_int_sv.eps MU_logotyp_int_sv.pdf -MIUNMISC_FILES+= miunmisc.ins miunmisc.dtx +MIUNMISC_FILES+= miunmisc.sty miunmisc-Swedish.dict miunmisc-English.dict ifdef INCLUDE_MIUNTEX $(foreach f,${MIUNMISC_FILES},$(eval $f: ${INCLUDE_MIUNTEX}/miunmisc/$f)) @@ -33,13 +35,9 @@ ${MIUNMISC_FILES}: ln -s $^ $@ else ${MIUNMISC_FILES}: - wget -O $@ http://ver.miun.se/latex/miunmisc/$@ + wget -O $@ ${CURRENT_URL}/$@ endif -miunmisc.pdf miunmisc.ps: miunmisc.dtx -miunmisc.sty miunmisc-Swedish.dict miunmisc-English.dict: miunmisc.ins -miunmisc.sty miunmisc-Swedish.dict miunmisc-English.dict: miunmisc.dtx - .PHONY: miunmisc miunlogo miunlogo: MU_logotyp_int_CMYK.eps MU_logotyp_int_CMYK.pdf miunlogo: MU_logotyp_int_sv.eps MU_logotyp_int_sv.pdf @@ -74,7 +72,7 @@ ${MIUNART_FILES}: ln -s $^ $@ else ${MIUNART_FILES}: - wget -O $@ http://ver.miun.se/latex/miunart/$@ + wget -O $@ ${CURRENT_URL}/$@ endif .PHONY: miunart @@ -103,7 +101,7 @@ ${MIUNASGN_FILES}: ln -s $^ $@ else ${MIUNASGN_FILES}: - wget -O $@ http://ver.miun.se/latex/miunasgn/$@ + wget -O $@ ${CURRENT_URL}/$@ endif .PHONY: miunasgn @@ -132,7 +130,7 @@ ${MIUNEXAM_FILES}: ln -s $^ $@ else ${MIUNEXAM_FILES}: - wget -O $@ http://ver.miun.se/latex/miunexam/$@ + wget -O $@ ${CURRENT_URL}/$@ endif .PHONY: miunexam @@ -154,7 +152,7 @@ ${miunlett-depend}: cd /tmp/miunlett && ${MAKE} install miunlett.cls: - wget -O $@ http://ver.miun.se/latex/miunlett/$@ + wget -O $@ ${CURRENT_URL}/$@ .PHONY: miunlett miunlett: miunlett.cls miunlogo @@ -182,7 +180,7 @@ ${MIUNPROT_FILES}: ln -s $^ $@ else ${MIUNPROT_FILES}: - wget -O $@ http://ver.miun.se/latex/miunprot/$@ + wget -O $@ ${CURRENT_URL}/$@ endif .PHONY: miunprot @@ -211,7 +209,7 @@ ${MIUNTHES_FILES}: ln -s $^ $@ else ${MIUNTHES_FILES}: - wget -O $@ http://ver.miun.se/latex/miunthes/$@ + wget -O $@ ${CURRENT_URL}/$@ endif .PHONY: miunthes diff --git a/miun.results.mk b/miun.results.mk index 3a6fb46..cc231ad 100644 --- a/miun.results.mk +++ b/miun.results.mk @@ -1,123 +1,82 @@ -# $Id$ -# Author: Daniel Bosk - ifndef MIUN_RESULTS_MK MIUN_RESULTS_MK=true -in?= ${COURSE}.txt -out?= reported.csv -report?= report.pdf - -COURSE?= -EXPADDR?= iksexp@miun.se -#MAILER?= mutt -s "resultat ${COURSE}" -a ${report} -- ${EXPADDR} -MAILER?= thunderbird -compose "to=${EXPADDR},subject='resultat ${COURSE}',attachment='file://${report}'" -REWRITES?= "s/Godkänd(G)/G/g" "s/Underkänd(U)/U/g" "s/Komplettering(Fx)/Fx/g" -FAILED?= -\|Fx\?\|U -FAILED_regex= " \(${FAILED}\)\( .*\)*$$" - -LOCALC?= localc --norestore -RM?= /bin/rm -Rf -MV?= /bin/mv -DIFF?= diff -JOIN?= join -t " " -CUT?= cut -SORT?= sort -t " " -HEAD?= head -TAIL?= tail -SED?= sed -GREP?= grep -CAT?= cat -CP?= cp -R -PAGER?= less -PASTE?= paste - +in?= new.csv +out?= reported.csv +report?= report.pdf +RESULTS_COURSE?= course identifier +RESULTS_EMAIL?= iksexp@miun.se +RESULTS_MAILER?= mutt -s "resultat ${RESULTS_COURSE}" -a ${report} -- ${RESULTS_EMAIL} +LOCALC?= localc --norestore +RM?= /bin/rm -Rf +MV?= /bin/mv +DIFF?= diff +JOIN?= join +CUT?= cut +SORT?= sort +HEAD?= head +TAIL?= tail +SED?= sed +GREP?= grep +CAT?= cat +CP?= cp -R +PAGER?= less +PASTE?= paste +LN?= ln +RESULTS_REWRITES+= "s/Godkänd(G)/G/g" "s/Underkänd(U)/U/g" +RESULTS_REWRITES+= "s/Komplettering(Fx)/Fx/g" +RESULTS_REWRITES+= "s/\"//g" +RESULTS_FAILED?= -\|Fx\?\|U +RESULTS_FAILED_regex= "\( \| \|,\)\"\?\(${RESULTS_FAILED}\)\"\?\( .*\)*$$" +RESULTS_COLUMNS?= 4 .PHONY: report -# phony target used to send results -report: ${report} ${in} - if [ ! -s ${out}.new ]; then \ - echo "No new results to report" >&2; \ +report: + if [ ! -s ${out}.diff ]; then \ + echo "No new results to report" >&2; \ else \ - ${PAGER} ${report}; \ - ${MAILER} && \ - $(call store,${in},${out}); \ + ${PAGER} ${report}; \ + ${RESULTS_MAILER} && \ + ${MV} ${out}.new ${out}; \ fi - -# create a csv for long storage of results -define store -${RM} $(2) && \ -${CUT} -f 1-3,5- $(1) | \ - ${SED} "s/ (\([a-z]\{4\}[0-9]\{4\}\))//" | \ - $(if ${REWRITES},${SED} "s/ //g",) \ - $(foreach regex,${REWRITES},| ${SED} ${regex}) > $(2) -endef - .PHONY: clean clean-results -# remove intermediate helper files clean: clean-results clean-results: - ${RM} ${report} ${report:.pdf=.csv} ${out}.new ${out}.new.pnr - -.SUFFIXES: .csv .pdf -# convert a csv to pdf -.csv.pdf: localc - #${LOCALC} --convert-to pdf $< --headless - ${LOCALC} $< - -.SUFFIXES: .csv .csv.new -# turn new results into a new csv -.csv.new.csv: - ${CP} $< $@ - -.SUFFIXES: .pdf .csv.new -# turn new results into a pdf -.csv.new.pdf: localc - ${LOCALC} --convert-to pdf $< - + ${RM} ${out}.new + ${RM} ${out}.diff ${out}.diff.id + ${RM} ${report:.pdf=.csv} + ${RM} ${report} +${out}.new: ${in} + ${CUT} -f 1-3,6- ${in} | \ + ${SED} "s/ (\([a-z]\{4\}[0-9]\{4\}\))//" \ + $(if ${RESULTS_REWRITES},| ${SED} "s/ //g", ) \ + $(foreach regex,${RESULTS_REWRITES},| ${SED} ${regex}) \ + > $@ +${out}.diff: ${out}.new + ${GREP} -v "^.\?First \?name" ${out}.new | \ + $(if ${RESULTS_FAILED},${GREP} -v ${RESULTS_FAILED_regex} |,) \ + ${DIFF} ${@:.diff=} - | ${SED} -n "/^> /s/^> //p" | ${SORT} -k 3 > $@ +${out}.diff: ${out} ${out}: - [ -r $@ ] || ln -s /dev/null $@ - -${out}.new: ${in} ${out} - ${GREP} -v "^.\?First \?name" ${in} | \ - ${CUT} -f 1-3,5- | \ - ${SED} "s/ (\([a-z]\{4\}[0-9]\{4\}\))//" | \ - $(if ${REWRITES},${SED} "s/ //g",) \ - $(foreach regex,${REWRITES},| ${SED} ${regex}) | \ - $(if ${FAILED},${GREP} -v ${FAILED_regex} |,) \ - ${DIFF} ${@:.new=} - | ${SED} -n "/^> /s/^> //p" | ${SORT} -k 3 > $@ - -.SUFFIXES: .csv.new.pnr -# filter out the userid from csv file, accept a paste of userid\t personnummer -.csv.new.csv.new.pnr: + [ -r $@ ] || ${LN} -s /dev/null $@ +.SUFFIXES: .csv .csv.diff .csv.diff.id +.csv.diff.csv.diff.id: @echo "---- userids showed in ${PAGER} ----" - ${CAT} $< | ${CUT} -f 3 | ${SORT} -k 1 | ${PAGER} - @echo "---- paste personnummer, end with C-d on a blank line (EOF) ----" + ${CAT} $< | ${CUT} -f 3 | ${PAGER} + @echo "---- paste username personnummer, end with C-d on a blank line (EOF) ----" ${CAT} > $@ - -# create the report, join personnummer and results +.SUFFIXES: .csv .pdf +.csv.pdf: + ${LOCALC} $< ${report:.csv=.pdf}: ${report:.pdf=.csv} - -${report:.pdf=.csv}: ${in} ${out}.new ${out}.new.pnr - ${HEAD} -n 1 ${in} | ${CUT} -f 1-2,5- | ${SED} "s/^/Personnr /" | \ - $(if ${REWRITES},${SED} "s/ //g",) \ - $(foreach regex,${REWRITES},| ${SED} ${regex}) > $@ - ${JOIN} -1 1 -2 3 ${out}.new.pnr ${out}.new | ${CUT} -f 2- | \ - ${SORT} -k 3 >> $@ - -### INCLUDES ### +${report:.pdf=.csv}: ${in} ${out}.diff ${out}.diff.id + ${HEAD} -n 1 ${out}.new | \ + ${CUT} -f -${RESULTS_COLUMNS} > $@ + ${JOIN} -1 1 -2 3 ${out}.diff.id ${out}.diff | ${CUT} -d " " -f 2- | \ + ${SORT} -k 2 | ${CUT} -d " " -f -${RESULTS_COLUMNS} >> $@ +.PHONY: report +report: ${report} ${in} INCLUDE_MAKEFILES?= . -INCLUDES= miun.depend.mk - -define inc -ifeq ($(findstring $(1),${MAKEFILE_LIST}),) -$(1): - wget https://raw.githubusercontent.com/dbosk/makefiles/master/$(1) -include ${INCLUDE_MAKEFILES}/$(1) -endif -endef -$(foreach i,${INCLUDES},$(eval $(call inc,$i))) - -### END INCLUDES ### +include ${INCLUDE_MAKEFILES}/miun.depend.mk endif diff --git a/noweb.mk b/noweb.mk index 6f7a0db..66ed6e6 100644 --- a/noweb.mk +++ b/noweb.mk @@ -11,12 +11,24 @@ .nw.h .c.nw.h .nw.hpp .cpp.nw.hpp .nw.hxx .cxx.nw.hxx: noweb notangle -R$@ $< | cpif $@ -# implicit rules for Python and make(1) includes -.SUFFIXES: .py.nw .mk.nw -.SUFFIXES: .py .mk -.nw.py .py.nw.py .nw.mk .mk.nw.mk: noweb +# implicit rules for Python +.SUFFIXES: .py.nw +.SUFFIXES: .py +.nw.py .py.nw.py: noweb notangle -R$@ $< | cpif $@ +# implicit rules for make(1) includes +.SUFFIXES: .mk.nw +.SUFFIXES: .mk +.nw.mk .mk.nw.mk: noweb + notangle -t2 -R$@ $< | cpif $@ + +# implicit rules for haskell +.SUFFIXES: .hs.nw +.SUFFIXES: .hs +.nw.hs .hs.nw.hs: + notangle -t2 -L -R$@ $< | cpif $@ + INCLUDE_MAKEFILES?=. include ${INCLUDE_MAKEFILES}/depend.mk diff --git a/tex.mk b/tex.mk index f72b4ec..ebfc0e7 100644 --- a/tex.mk +++ b/tex.mk @@ -20,7 +20,7 @@ WC?= wc -w # variables used to compile LaTeX documents LATEX?= latex PDFLATEX?= pdflatex -DETEXT?= detex +DETEX?= detex LATEXMK?= latexmk ${LATEXMKRC} -bibtex-cond LATEXMKRC?= DVIPS?= dvips @@ -199,14 +199,30 @@ endef .PHONY: submission submission: ${DOCUMENTS:.pdf=.submission.tex} -.SUFFIXES: .nw .py.nw .c.nw .h.nw .cpp.nw .hpp.nw .mk.nw -.nw.tex .py.nw.tex .c.nw.tex .h.nw.tex .cpp.nw.tex .hpp.nw.tex .mk.nw.tex: noweb +.SUFFIXES: .nw +.nw.tex: noweb noweave -x -n -delay -t2 $< > $@ +NOWEB_SUFFIXES+= .py.nw .c.nw .h.nw .cpp.nw .hpp.nw .mk.nw .hs.nw +.SUFFIXES: ${NOWEB_SUFFIXES} +$(foreach suffix,${NOWEB_SUFFIXES},${suffix}.tex): noweb + noweave -x -n -t2 $< > $@ + +.SUFFIXES: .md +.md.tex: pandoc + pandoc $< -t latex -o $@ + .PHONY: wc wc: for f in $^; do echo -n "$${f}: "; ${DETEX} $${f} | ${WC}; done +.SUFFIXES: .asc .tex.asc +.tex.tex.asc: + gpg -aes $(foreach recipient,${TEX_RECIPIENTS},-r ${recipient}) $< + +.tex.asc.tex: + gpg --output $@ -d $<.SUFFIXES: .gpg + ### INCLUDES ###