2005-02-04 03:05:55 -05:00
|
|
|
;;; MAKEFILE:
|
|
|
|
;;; =========
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-01-19 09:50:45 -05:00
|
|
|
;;; (define-syntax makefile
|
|
|
|
;;; (syntax-rules ()
|
2005-01-20 05:18:07 -05:00
|
|
|
;;; ((makefile ?rule0 ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
;;; (let ((rule-candidates '()))
|
|
|
|
;;; (let* ((rule-candidates (?rule0 rule-candidates))
|
2005-01-20 05:18:07 -05:00
|
|
|
;;; ...)
|
2005-02-04 03:05:55 -05:00
|
|
|
;;; rule-candidates)))))
|
2005-01-20 05:18:07 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;; <makefile> ::= '(' + "makefile" + <makerule-clause>* + ')'
|
|
|
|
;;; <makerule-clause> ::= <rule-clause>
|
|
|
|
;;; | <md5-clause>
|
|
|
|
;;; | <always-clause>
|
|
|
|
;;; | <once-clause>
|
|
|
|
;;;
|
|
|
|
;;;
|
2005-01-20 05:18:07 -05:00
|
|
|
(define-syntax makefile
|
|
|
|
(syntax-rules ()
|
2005-02-04 03:05:55 -05:00
|
|
|
((makefile) (list))
|
|
|
|
((makefile ?rule0 ?rule1 ...) (?rule0 (makefile ?rule1 ...)))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;; <rule-clause>
|
|
|
|
;;;
|
|
|
|
;;; to achieve consistency only rule will use the rule-tmpvars
|
|
|
|
;;; macro directly and all other macros use this clause
|
|
|
|
;;;
|
2005-01-18 10:45:27 -05:00
|
|
|
(define-syntax makefile-rule
|
|
|
|
(syntax-rules ()
|
2005-02-04 03:05:55 -05:00
|
|
|
((makefile-rule ?target ?prereqs ?thunk) (rule ?target ?prereqs ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax is-out-of-date?
|
|
|
|
(syntax-rules ()
|
|
|
|
((is-out-of-date? ?target ?prereqs ?thunk) (rule ?target ?prereqs ?thunk))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax rule
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-04 03:05:55 -05:00
|
|
|
((rule ?target (?prereq0 ...) ?thunk)
|
|
|
|
(rule-tmpvars () ?target (?prereq0 ...) ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax rule-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((rule-tmpvars (tmp1 ...) ?target () ?thunk)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...)))
|
|
|
|
(lambda (rule-candidates)
|
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-is-out-of-date? target tmp1 ...)
|
|
|
|
(make-rule-build-func target prereqs ?thunk))
|
|
|
|
rule-candidates))))
|
|
|
|
((rule-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...) ?thunk)
|
2005-01-18 10:45:27 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-04 03:05:55 -05:00
|
|
|
(rule-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <md5-clause>
|
|
|
|
;;;
|
|
|
|
;;; to achieve consistency only rule-md5 will use the rule-md5-tmpvars
|
|
|
|
;;; macro directly and all other macros use this clause
|
|
|
|
;;;
|
|
|
|
(define-syntax md5
|
|
|
|
(syntax-rules ()
|
|
|
|
((md5 ?target ?prereqs ?thunk) (rule-md5 ?target ?prereqs ?thunk))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax rule-md5
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-04 03:05:55 -05:00
|
|
|
((rule-md5 ?target (?prereq0 ...) ?thunk)
|
|
|
|
(rule-md5-tmpvars () ?target (?prereq0 ...) ?thunk))))
|
2005-01-18 10:45:27 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax rule-md5-tmpvars
|
2005-01-18 10:45:27 -05:00
|
|
|
(syntax-rules ()
|
2005-02-04 03:05:55 -05:00
|
|
|
((rule-md5-tmpvars (tmp1 ...) ?target () ?thunk)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...)))
|
|
|
|
(lambda (rule-candidates)
|
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-md5-sum-changed? target tmp1 ...)
|
|
|
|
(make-md5-build-func target prereqs ?thunk))
|
|
|
|
rule-candidates))))
|
|
|
|
((rule-md5-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...) ?thunk)
|
2005-01-18 10:45:27 -05:00
|
|
|
(let ((tmp2 ?prereq0))
|
2005-02-04 03:05:55 -05:00
|
|
|
(rule-md5-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk)))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
;;;
|
|
|
|
;;; <always-clause>
|
|
|
|
;;;
|
|
|
|
;;; to achieve consistency only rule-always will use the rule-always-tmpvars
|
|
|
|
;;; macro directly and all other macros use this clause
|
|
|
|
;;;
|
|
|
|
(define-syntax phony
|
|
|
|
(syntax-rules ()
|
|
|
|
((phony ?target ?prereqs ?thunk) (rule-always ?target ?prereqs ?thunk))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax always
|
|
|
|
(syntax-rules ()
|
|
|
|
((always ?target ?prereqs ?thunk) (rule-always ?target ?prereqs ?thunk))))
|
2005-01-19 09:50:45 -05:00
|
|
|
|
2005-02-04 03:05:55 -05:00
|
|
|
(define-syntax is-out-of-date!
|
|
|
|
(syntax-rules ()
|
|
|
|
((is-out-of-date! ?target ?prereqs ?thunk)
|
|
|
|
(rule-always ?target ?prereqs ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax rule-always
|
|
|
|
(syntax-rules ()
|
|
|
|
((rule-always ?target (?prereq0 ...) ?thunk)
|
|
|
|
(rule-always-tmpvars () ?target (?prereq0 ...) ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax rule-always-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((rule-always-tmpvars (tmp1 ...) ?target () ?thunk)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...)))
|
|
|
|
(lambda (rule-candidates)
|
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-is-out-of-date! target tmp1 ...)
|
|
|
|
(make-always-build-func target prereqs ?thunk))
|
|
|
|
rule-candidates))))
|
|
|
|
((rule-always-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...) ?thunk)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(rule-always-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk)))))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; <once-clause>
|
|
|
|
;;;
|
|
|
|
;;; to achieve consistency only rule-once will use the rule-once-tmpvars
|
|
|
|
;;; macro directly and all other macros use this clause
|
|
|
|
;;;
|
|
|
|
(define-syntax once
|
|
|
|
(syntax-rules ()
|
|
|
|
((once ?target ?prereqs ?thunk)
|
|
|
|
(rule-once ?target ?prereqs ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax rule-once
|
|
|
|
(syntax-rules ()
|
|
|
|
((rule-once ?target (?prereq0 ...) ?thunk)
|
|
|
|
(rule-once-tmpvars () ?target (?prereq0 ...) ?thunk))))
|
|
|
|
|
|
|
|
(define-syntax rule-once-tmpvars
|
|
|
|
(syntax-rules ()
|
|
|
|
((rule-once-tmpvars (tmp1 ...) ?target () ?thunk)
|
|
|
|
(let ((target ?target)
|
|
|
|
(prereqs (list tmp1 ...)))
|
|
|
|
(lambda (rule-candidates)
|
|
|
|
(cons (list target
|
|
|
|
prereqs
|
|
|
|
(make-once target tmp1 ...)
|
|
|
|
(make-once-build-func target prereqs ?thunk))
|
|
|
|
rule-candidates))))
|
|
|
|
((rule-once-tmpvars (tmp1 ...) ?target (?prereq0 ?prereq1 ...) ?thunk)
|
|
|
|
(let ((tmp2 ?prereq0))
|
|
|
|
(rule-once-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk)))))
|