added some files:
sample makefile for building tex-stuff makefile-diplom.scm pkg-def.scm
This commit is contained in:
parent
64ca70eed3
commit
f73ab42ff6
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/scsh -s
|
||||
!#
|
||||
(define targets-prereqs
|
||||
; f : which file to scan
|
||||
; i-dirs : the directories where to look for include files
|
||||
(lambda (f i-dirs)
|
||||
(let ; calling gcc-cmd returns
|
||||
; all dependencies in one entire string
|
||||
((raw-deps (lambda (file dirs)
|
||||
; full command string
|
||||
(let ((gcc-cmd (lambda (my-file ds)
|
||||
; build the include args for gcc e.g.
|
||||
; ("-I." "-I.." "-I/usr/include")
|
||||
(let ((i-args (lambda (d)
|
||||
(let
|
||||
((add-prefix
|
||||
(lambda (p s)
|
||||
(map
|
||||
string-append
|
||||
(circular-list p)
|
||||
s))))
|
||||
(add-prefix "-I" d)))))
|
||||
(append
|
||||
(list "gcc" "-M")
|
||||
(i-args ds)
|
||||
(list my-file))))))
|
||||
(run/string ,(gcc-cmd file dirs)))))
|
||||
; cook-deps returns a list like ("target:" "filename" "otherfile" ...)
|
||||
(cook-deps (lambda (rdeps)
|
||||
(let
|
||||
; merge all \ -separated lines
|
||||
; into one entire line
|
||||
((unbreak-lines (lambda (str)
|
||||
(regexp-substitute/global
|
||||
#f
|
||||
(rx (: (* white)
|
||||
#\\
|
||||
#\newline
|
||||
(* white)))
|
||||
str
|
||||
'pre " " 'post)))
|
||||
; break a string into tokens
|
||||
; "a space delimeted string" ->
|
||||
; ("a" "space" "delimited" "string")
|
||||
(extract-f-l (lambda (s)
|
||||
(string-tokenize s char-set:graphic))))
|
||||
(extract-f-l (unbreak-lines rdeps)))))
|
||||
; splits a list of strings into a target and its prerequisites
|
||||
; by searching for an element with a colon as the last character
|
||||
; returns a pair list and needs the list of dependencies
|
||||
(t-p-pair (lambda (deps-l)
|
||||
(let
|
||||
; deletes the last character colon...
|
||||
((delete-colon (lambda (target)
|
||||
(regexp-substitute/global
|
||||
#f
|
||||
(rx (: #\: eos))
|
||||
target
|
||||
'pre 'post)))
|
||||
; as list-index returns the element no
|
||||
; starting at 0, last-target-element
|
||||
; increases this index by 1
|
||||
(last-target-element
|
||||
(lambda (str-l)
|
||||
; tests if a target-candidate (tc) is a target
|
||||
; a tc is a target if its last character is
|
||||
; a colon...
|
||||
(let ((is-target? (lambda (tc)
|
||||
(regexp-search
|
||||
(rx (: any #\: eos))
|
||||
tc))))
|
||||
(+ 1 (list-index is-target? str-l))))))
|
||||
(cond
|
||||
((null? deps-l) #f)
|
||||
(else
|
||||
(cons
|
||||
; this is a pair list -> the colon can be deleted
|
||||
(map delete-colon
|
||||
(take deps-l (last-target-element deps-l)))
|
||||
(list
|
||||
(drop deps-l (last-target-element deps-l))))))))))
|
||||
(t-p-pair (cook-deps (raw-deps f i-dirs))))))
|
||||
|
||||
(define add-entry
|
||||
(lambda (k d a)
|
||||
(let
|
||||
((tp (lambda (f i)
|
||||
(targets-prereqs f i))))
|
||||
(alist-cons (car (tp k d)) (cdr (tp k d)) a))))
|
||||
|
||||
(define include-dirs
|
||||
(list
|
||||
"./"
|
||||
"/usr/include"
|
||||
"/usr/src/linux/include"))
|
||||
|
||||
(define target-lookup-table
|
||||
(add-entry
|
||||
"./scanme.c"
|
||||
include-dirs
|
||||
'()))
|
||||
|
||||
(define target-lookup-table
|
||||
(add-entry
|
||||
"./it.h"
|
||||
include-dirs
|
||||
target-lookup-table))
|
||||
|
||||
(display target-lookup-table)
|
||||
(newline)
|
|
@ -0,0 +1,101 @@
|
|||
(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")))))
|
|
@ -0,0 +1,33 @@
|
|||
(define-package "scsh-make"
|
||||
(0 1)
|
||||
((install-lib-version (1 0)))
|
||||
(write-to-load-script
|
||||
`((config)
|
||||
(load ,(absolute-file-name "packages.scm"
|
||||
(get-directory 'scheme #f)))))
|
||||
(install-file "SYNTAX" 'doc)
|
||||
(install-file "README" 'doc)
|
||||
(install-file "COPYING" 'doc)
|
||||
(install-file "autovars.scm" 'scheme)
|
||||
(install-file "cml-pe.scm" 'scheme)
|
||||
(install-file "collect-channels.scm" 'scheme)
|
||||
(install-file "common-rules.scm" 'scheme)
|
||||
(install-file "dfs.scm" 'scheme)
|
||||
(install-file "gcc-m.scm" 'scheme)
|
||||
(install-file "jobd.scm" 'scheme)
|
||||
(install-file "job.scm" 'scheme)
|
||||
(install-file "macros.scm" 'scheme)
|
||||
(install-file "make-rule-no-cml.scm" 'scheme)
|
||||
(install-file "make-rule.scm" 'scheme)
|
||||
(install-file "make.scm" 'scheme)
|
||||
(install-file "mcast-channels.scm" 'scheme)
|
||||
(install-file "packages.scm" 'scheme)
|
||||
(install-file "rule-cand.scm" 'scheme)
|
||||
(install-file "templates.scm" 'scheme)
|
||||
(install-file "to-rule-set.scm" 'scheme))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue