2005-02-24 09:30:07 -05:00
|
|
|
;;;
|
2005-02-04 03:05:55 -05:00
|
|
|
;;; MAKEFILE:
|
|
|
|
;;; =========
|
2005-02-24 09:30:07 -05:00
|
|
|
;;;
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;; <makefile> ::= '(' + "makefile" + <makerule-clause>* + ')'
|
2005-02-15 06:29:08 -05:00
|
|
|
;;; <makerule-clause> ::= <file-clause>
|
2005-02-24 09:30:07 -05:00
|
|
|
;;; | <all-clause>
|
2005-02-04 03:05:55 -05:00
|
|
|
;;; | <md5-clause>
|
|
|
|
;;; | <always-clause>
|
|
|
|
;;; | <once-clause>
|
2005-02-24 09:30:07 -05:00
|
|
|
;;; | <common-file-clause>
|
|
|
|
;;; | <common-all-clause>
|
|
|
|
;;; | <common-md5-clause>
|
|
|
|
;;; | <common-always-clause>
|
|
|
|
;;; | <common-once-clause>
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;;
|
2005-01-20 05:18:07 -05:00
|
|
|
(define-syntax makefile
|
|
|
|
(syntax-rules ()
|
2005-02-24 09:30:07 -05:00
|
|
|
((makefile ?rule0 ...)
|
|
|
|
(sort-rules () () ?rule0 ...))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
2005-02-24 09:30:07 -05:00
|
|
|
;;; Each rule will be transformed into something similar to this:
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
2005-02-24 09:30:07 -05:00
|
|
|
;;; (cons ()
|
|
|
|
;;; ("target" ("prereq0" ...) is-out-of-date? (lambda () ?action0 ...)))
|
|
|
|
;;;
|
|
|
|
;;; or this
|
|
|
|
;;;
|
|
|
|
;;; (cons ("target" ("prereq0" ...) is-out-of-date? (lambda () ?action0 ...)
|
|
|
|
;;; ()))
|
|
|
|
;;;
|
|
|
|
;;; The car of each result then goes into the file-rules-list while the
|
|
|
|
;;; cdr goes into the common-rules-list. At the end those elements in each
|
|
|
|
;;; of the file-rules-list and the common-rules-list being empty lists are
|
|
|
|
;;; removed. The result are the cons-ed remaining lists.
|
|
|
|
;;;
|
|
|
|
(define-syntax sort-rules
|
|
|
|
(syntax-rules ()
|
|
|
|
((sort-rules (?file0 ...) (?common0 ...))
|
|
|
|
(let ((file-rules (remove null? (list ?file0 ...)))
|
|
|
|
(common-rules (remove null? (list ?common0 ...))))
|
|
|
|
(cons file-rules common-rules)))
|
|
|
|
((sort-rules (?file1 ...) (?common1 ...) ?rule0 ?rule1 ...)
|
|
|
|
(let ((rule-result ?rule0))
|
|
|
|
(let ((common0 (cdr rule-result))
|
|
|
|
(file0 (car rule-result)))
|
|
|
|
(sort-rules (file0 ?file1 ...) (common0 ?common1 ...) ?rule1 ...))))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; MAKERULE-CLAUSES:
|
|
|
|
;;; =================
|
|
|
|
;;;
|
|
|
|
;;;
|
|
|
|
;;; <file-clause>
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
2005-01-18 10:45:27 -05:00
|
|
|
(define-syntax makefile-rule
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((makefile-rule ?target ?prereqs ?action0 ...)
|
|
|
|
(file ?target ?prereqs ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
|
|
|
(define-syntax is-out-of-date?
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((is-out-of-date? ?target ?prereqs ?action0 ...)
|
|
|
|
(file ?target ?prereqs ?action0 ...))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(file-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-tmpvars
|
2005-02-04 03:05:55 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((target ?target)
|
2005-02-15 06:29:08 -05:00
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
2005-02-24 09:30:07 -05:00
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-is-out-of-date? target tmp1 ...)
|
|
|
|
(make-file-build-func target prereqs thunk))
|
|
|
|
(list))))
|
|
|
|
((file-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
2005-01-18 10:45:27 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-24 09:30:07 -05:00
|
|
|
(file-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
|
|
|
;;;
|
2005-02-24 09:30:07 -05:00
|
|
|
;;; <all-clause>
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
2005-02-24 09:30:07 -05:00
|
|
|
(define-syntax all
|
|
|
|
(syntax-rules ()
|
|
|
|
((makefile-rule ?target ?prereqs ?action0 ...)
|
|
|
|
(file-all ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax all-out-of-date?
|
|
|
|
(syntax-rules ()
|
|
|
|
((all-out-of-date? ?target ?prereqs ?action0 ...)
|
|
|
|
(file-all ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax file-all
|
|
|
|
(syntax-rules ()
|
|
|
|
((file-all ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(file-all-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax file-all-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((file-all-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-all-out-of-date? target tmp1 ...)
|
|
|
|
(make-all-build-func target prereqs thunk))
|
|
|
|
(list))))
|
|
|
|
((file-all-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(file-all-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <md5-clause>
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
(define-syntax md5
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((md5 ?target ?prereqs ?action0 ...)
|
|
|
|
(file-md5 ?target ?prereqs ?action0 ...))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-md5
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-md5 ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(file-md5-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-md5-tmpvars
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-md5-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((target ?target)
|
2005-02-15 06:29:08 -05:00
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
2005-02-24 09:30:07 -05:00
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-md5-sum-changed? target tmp1 ...)
|
|
|
|
(make-md5-build-func target prereqs thunk))
|
|
|
|
(list))))
|
|
|
|
((file-md5-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
2005-01-18 10:45:27 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-24 09:30:07 -05:00
|
|
|
(file-md5-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;; <always-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax phony
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((phony ?target ?prereqs ?action0 ...)
|
|
|
|
(file-always ?target ?prereqs ?action0 ...))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax always
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((always ?target ?prereqs ?action0 ...)
|
|
|
|
(file-always ?target ?prereqs ?action0 ...))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax is-out-of-date!
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((is-out-of-date! ?target ?prereqs ?action0 ...)
|
|
|
|
(file-always ?target ?prereqs ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-always
|
2005-02-04 03:05:55 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-always ?target ?prereqs ?action0 ...)
|
|
|
|
(file-always-tmpvars () ?target ?prereqs ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-always-tmpvars
|
2005-02-04 03:05:55 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-always-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((target ?target)
|
2005-02-15 06:29:08 -05:00
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
2005-02-24 09:30:07 -05:00
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-is-out-of-date! target tmp1 ...)
|
|
|
|
(make-always-build-func target prereqs thunk))
|
|
|
|
(list))))
|
|
|
|
((file-always-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-24 09:30:07 -05:00
|
|
|
(file-always-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <once-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax once
|
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((once ?target ?prereqs ?action0 ...)
|
|
|
|
(file-once ?target ?prereqs ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-once
|
2005-02-04 03:05:55 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-once ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(file-once-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
2005-02-04 03:05:55 -05:00
|
|
|
|
2005-02-15 06:29:08 -05:00
|
|
|
(define-syntax file-once-tmpvars
|
2005-02-04 03:05:55 -05:00
|
|
|
(syntax-rules ()
|
2005-02-15 06:29:08 -05:00
|
|
|
((file-once-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((target ?target)
|
2005-02-15 06:29:08 -05:00
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
2005-02-24 09:30:07 -05:00
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-once target tmp1 ...)
|
|
|
|
(make-once-build-func target prereqs thunk))
|
|
|
|
(list))))
|
|
|
|
((file-once-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(file-once-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;; COMMON-MAKERULE-CLAUSES:
|
|
|
|
;;; ========================
|
|
|
|
;;;
|
|
|
|
;;;
|
|
|
|
;;;
|
|
|
|
;;; <common-file-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax common-file
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(common-file-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list)
|
|
|
|
(list target
|
|
|
|
prereqs
|
|
|
|
(make-common-is-out-of-date? target tmp1 ...)
|
|
|
|
(make-common-file-build-func target prereqs thunk)))))
|
|
|
|
((common-file-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(common-file-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <common-all-clause>
|
|
|
|
;;;
|
|
|
|
;;; to achieve consistency only file will use the file-tmpvars
|
|
|
|
;;; macro directly and all other macros use this clause
|
|
|
|
;;;
|
|
|
|
(define-syntax common-all
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-all ?target ?prereqs ?action0 ...)
|
|
|
|
(common-file-all ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-all
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-all ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(common-file-all-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-all-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-all-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list)
|
|
|
|
(list target
|
|
|
|
prereqs
|
|
|
|
(make-common-all-out-of-date? target tmp1 ...)
|
|
|
|
(make-common-all-build-func target prereqs thunk)))))
|
|
|
|
((common-file-all-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(common-file-all-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <common-md5-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax common-md5
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-md5 ?target ?prereqs ?action0 ...)
|
|
|
|
(common-file-md5 ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-md5
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-md5 ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(common-file-md5-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-md5-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-md5-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list)
|
|
|
|
(list target
|
|
|
|
prereqs
|
|
|
|
(make-common-md5-sum-changed? target tmp1 ...)
|
|
|
|
(make-common-md5-build-func target prereqs thunk)))))
|
|
|
|
((common-file-md5-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(common-file-md5-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <common-always-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax common-always
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-always ?target ?prereqs ?action0 ...)
|
|
|
|
(common-file-always ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-always
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-always ?target ?prereqs ?action0 ...)
|
|
|
|
(common-file-always-tmpvars () ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-always-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-always-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list)
|
|
|
|
(list target
|
|
|
|
prereqs
|
|
|
|
(make-common-is-out-of-date! target tmp1 ...)
|
|
|
|
(make-common-always-build-func target prereqs thunk)))))
|
|
|
|
((common-file-always-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(common-file-always-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <common-once-clause>
|
|
|
|
;;;
|
|
|
|
(define-syntax common-once
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-once ?target ?prereqs ?action0 ...)
|
|
|
|
(common-file-once ?target ?prereqs ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-once
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-once ?target (?prereq0 ...) ?action0 ...)
|
|
|
|
(common-file-once-tmpvars () ?target (?prereq0 ...) ?action0 ...))))
|
|
|
|
|
|
|
|
(define-syntax common-file-once-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((common-file-once-tmpvars (tmp1 ...) ?target () ?action0 ...)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...))
|
|
|
|
(thunk (lambda () ?action0 ...)))
|
|
|
|
(cons (list)
|
|
|
|
(list target
|
|
|
|
prereqs
|
|
|
|
(make-common-once target tmp1 ...)
|
|
|
|
(make-common-once-build-func target prereqs thunk)))))
|
|
|
|
((common-file-once-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...)
|
|
|
|
?action0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-24 09:30:07 -05:00
|
|
|
(common-file-once-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...)
|
|
|
|
?action0 ...)))))
|