;;; MAKEFILE: ;;; ========= ;;; (define-syntax makefile ;;; (syntax-rules () ;;; ((makefile ?rule0 ...) ;;; (let ((rule-candidates '())) ;;; (let* ((rule-candidates (?rule0 rule-candidates)) ;;; ...) ;;; rule-candidates))))) ;;; ;;; ::= '(' + "makefile" + * + ')' ;;; ::= ;;; | ;;; | ;;; | ;;; ;;; (define-syntax makefile (syntax-rules () ((makefile) (list)) ((makefile ?rule0 ?rule1 ...) (?rule0 (makefile ?rule1 ...))))) ;;; ;;; ;;; ;;; to achieve consistency only rule will use the rule-tmpvars ;;; macro directly and all other macros use this clause ;;; (define-syntax makefile-rule (syntax-rules () ((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)))) (define-syntax rule (syntax-rules () ((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) (let ((tmp2 ?prereq0)) (rule-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk))))) ;;; ;;; ;;; ;;; 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)))) (define-syntax rule-md5 (syntax-rules () ((rule-md5 ?target (?prereq0 ...) ?thunk) (rule-md5-tmpvars () ?target (?prereq0 ...) ?thunk)))) (define-syntax rule-md5-tmpvars (syntax-rules () ((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) (let ((tmp2 ?prereq0)) (rule-md5-tmpvars (tmp1 ... tmp2) ?target (?prereq1 ...) ?thunk))))) ;;; ;;; ;;; ;;; 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)))) (define-syntax always (syntax-rules () ((always ?target ?prereqs ?thunk) (rule-always ?target ?prereqs ?thunk)))) (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))))) ;;; ;;; ;;; ;;; 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)))))