master test.scm
 1(use-modules (util)
 2	     (srfi srfi-1)
 3	     (srfi srfi-13))
 4
 5;; a needs c so put it first
 6;; a then put a
 7;; then b
 8;; then x
 9;; c -> a -> b -> x
10
11(define t-list '())
12(define m-list '())
13(define v-list '())
14(define f-list (file-read
15		(if (> (length (command-line)) (+ 1 1)) (cadr (command-line)) "Makefile")
16		))
17
18(do ((l 0 (+ l 1)))
19    ((>= l (length f-list)))
20(if (or (and
21	 (string-contains (list-ref f-list l) ":")
22	 (string-contains (list-ref f-list l) "$("))
23	(string-contains (list-ref f-list l) "="))
24    (if (string-contains (list-ref f-list l) "=")
25	(set! v-list (cons (var-parse (var-expand (list-ref f-list l) v-list)) v-list))     
26	)
27    ))
28
29(do ((l (- (length f-list) 1) (- l 1)))
30    ((< l 0))
31  (if (string-contains (list-ref f-list l) ":")
32      (set! m-list (cons (line-parse (var-expand (list-ref f-list l) v-list)) m-list))
33      ))
34      
35
36
37;; (display m-list)
38;; (newline)(newline)
39
40;; (list-sort (car (list-ref m-list 0)) m-list)(newline)
41;; (list-sort "goon" m-list)
42
43(define t-line)
44(call/cc (lambda (break)
45(do ((i 0 (+ i 1)))
46    ((>= i (length f-list)))
47  (if (and (string-contains (list-ref f-list i) ":")
48	   (string=? (car (line-parse (list-ref f-list i))) (caddr (command-line))))
49  (begin (set! t-line i)(break))
50		))
51  ))
52(set! t-list (list-sort (car (line-parse (list-ref f-list t-line))) m-list))
53(set! t-list (delete-duplicates t-list equal?))
54(display t-list)(newline)
55
56(do ((i 0 (+ i 1)))
57    ((>= i (length t-list)))
58  (call/cc
59   (lambda (break)
60     (do ((o 0 (+ o 1)))
61         ((>= o (length f-list)))
62       (if (and
63            (string-contains (list-ref f-list o) ":")
64            (string=?
65             (car (line-parse (list-ref f-list o)))
66             (list-ref t-list i)))
67           (begin
68             (do ((r (+ o 1) (+ r 1)))
69                 ((or (>= r (length f-list))
70                      (string-null? (list-ref f-list r))
71                      (not (char=? (string-ref (list-ref f-list r) 0)
72                                   #\tab))))
73	       (if (char=? (string-ref (list-ref f-list r) 1) #\@)
74		   (system (string-delete #\@ (substring (list-ref f-list r)1)))
75		   
76		   (begin
77		     (format #t "~a~%" (var-expand (string-delete #\tab (list-ref f-list r)) v-list))
78
79		     (if (string-contains (list-ref f-list r) "$(")
80			 (system (var-expand (substring (list-ref f-list r) 1)v-list)))
81		     (break)))))))
82     )))
83;; => (1 2 3 4 5)
84
85;; (display (list-ref (list-ref (list-ref m-list 0) 1) 0))
86