102 lines
2.8 KiB
Scheme
102 lines
2.8 KiB
Scheme
(define-structure makefile
|
|
(export fix-broken-urls
|
|
make-all!
|
|
make-pdf!
|
|
make-ps!
|
|
make-clean!
|
|
make-mrproper!)
|
|
(open scheme-with-scsh
|
|
srfi-1
|
|
srfi-9
|
|
macros
|
|
make
|
|
to-rule-set
|
|
templates
|
|
autovars)
|
|
(begin
|
|
|
|
(define clean-files
|
|
(list "scsh-make.aux" "scsh-make.log" "scsh-make.blg"))
|
|
|
|
(define mrproper-files
|
|
(list "scsh-make.pdf" "scsh-make.ps" "scsh-make.advi"
|
|
"scsh-make.bbl" "scsh-make.dvi" "fig/mcast.eps"))
|
|
|
|
(define (rerun? target prereqs)
|
|
(let ((re (rx (: "Rerun to get cross-references right."))))
|
|
(if (file-not-exists? target)
|
|
#t
|
|
(if (null? prereqs)
|
|
#f
|
|
(let* ((inp (open-input-file (car prereqs)))
|
|
(str (port->string inp)))
|
|
(close inp)
|
|
(regexp-search re str))))))
|
|
|
|
;; fix lines with broken wrapped URLs
|
|
(define (fix-broken-urls fname)
|
|
(let* ((re (rx (: (submatch (* (- any #\newline "%")))
|
|
(submatch "%" #\newline))))
|
|
(inp (open-input-file fname))
|
|
(s (port->string inp)))
|
|
(close inp)
|
|
(with-current-output-port
|
|
(open-output-file fname)
|
|
(display (regexp-substitute/global #f re s 'pre 1 'post)))))
|
|
|
|
(define rule-set
|
|
(makefile
|
|
(common-%
|
|
(file "fig/%.eps"
|
|
("fig/%.fig")
|
|
(run (fig2dev -L "eps" ,($<) ,($@))))
|
|
(file "png/%.eps"
|
|
("png/%.png")
|
|
(run (convert ,($<) ,($@))))
|
|
(file "jpg/%.eps"
|
|
("jpg/%.jpg")
|
|
(run (convert ,($<) ,($@))))
|
|
(file "%.advi"
|
|
("%.dvi")
|
|
(run (dvicopy ,($<) ,($@))))
|
|
(file "%.pdf"
|
|
("%.ps")
|
|
(run (ps2pdf ,"-sPAPERSIZE=a4" ,($<) ,($@))))
|
|
(file "%.ps"
|
|
("%.dvi")
|
|
(run (dvips -o ,($@) ,($<))))
|
|
(once "%.dvi"
|
|
("%.aux" "%.aux" "%.aux" "%.aux")
|
|
#t)
|
|
(rerun? "%.aux"
|
|
("%.log")
|
|
(run (latex ,($*))))
|
|
(file "scsh-make.log"
|
|
("scsh-make.tex" "scsh-make.bst"
|
|
"einleitung.tex" "konzepte.tex" "makefile.tex"
|
|
"embedded.tex" "jobserver.tex" "zusammenfassung.tex"
|
|
"fig/mcast.eps" "makefile.scm")
|
|
(run (latex ,($<)))
|
|
(run (bibtex ,"scsh-make"))
|
|
(fix-broken-urls "scsh-make.bbl")
|
|
(run (latex ,"scsh-make"))))
|
|
(always "all"
|
|
("scsh-make.pdf" "scsh-make.ps" "scsh-make.advi")
|
|
(display ";;; done: building ")
|
|
(display ($@))
|
|
(newline))
|
|
(always "clean"
|
|
()
|
|
(for-each (lambda (f) (delete-filesys-object f))
|
|
clean-files))
|
|
(always "mrproper"
|
|
()
|
|
(for-each (lambda (f) (delete-filesys-object f))
|
|
mrproper-files))))
|
|
|
|
(define (make-all!) (make rule-set (list "all")))
|
|
(define (make-pdf!) (make rule-set (list "scsh-make.pdf")))
|
|
(define (make-ps!) (make rule-set (list "scsh-make.ps")))
|
|
(define (make-clean!) (make rule-set (list "clean")))
|
|
(define (make-mrproper!) (make rule-set (list "mrproper")))))
|