small sample scsh-script using make in scsh

This commit is contained in:
jottbee 2005-03-10 09:49:34 +00:00
parent e9b3d3d6ec
commit c0ece4c94b
2 changed files with 87 additions and 1 deletions

86
examples/test-embed.scm Normal file
View File

@ -0,0 +1,86 @@
(define at-uni? #t)
(define pred string=?)
(define obj-rules
(list
(file-rx (rx (: (submatch "") (submatch (+ any)) (submatch ".o")))
(list "%.c" "%.h")
(lambda () (run (gcc -fPIC -c ,(string-append ($*) ".c")))))))
(define lib-rules
(list
(md5-% "lib%.so.1.0"
(list "%.o")
(lambda () (run (gcc -shared
,(string-append "-Wl,-soname," ($=*) ".so.1")
-o ,($@) ,($<)))))
(file-% "lib%.so.1"
(list "lib%.so.1.0")
(lambda () (create-symlink ($<) ($@))))
(file-% "lib%.so"
(list "lib%.so.1")
(lambda () (create-symlink ($<) ($@))))))
(define tex-rules
(list
(file-% "%.dvi"
(list "%.tex")
(lambda () (run (latex ,($<)))))
(file-% "%.pdf"
(list "%.dvi")
(lambda () (run (dvipdfm -o ,($@) ,($<)))))
(file-% "%.ps"
(list "%.dvi")
(lambda () (run (dvips -o ,($@) ,($<)))))))
(define proggy
(if at-uni?
(file->rc "show-sqrt"
(list "main.c" "libmymath.so.1"
"libwildio.so.1" "wildio.h" "mymath.h")
(lambda () (run (gcc -L ,(cwd) ,(ldflags) -rdynamic
-o ,($@) ,($<)
,"libwildio.so.1" ,"libmymath.so.1" -lc))))
(file->rc "show-sqrt"
(list "main.c" "libmymath.so.1"
"libwildio.so.1" "wildio.h" "mymath.h")
(lambda () (run (gcc -L ,(cwd) -rdynamic -o ,($@) ,($<)
,"libwildio.so.1" ,"libmymath.so.1" -ldl))))))
(define manuals
(let* ((prefixes (list "a" "b" "c" "d")))
(append
(map (lambda (pre)
(string-append pre "-manual.dvi"))
prefixes)
(map (lambda (pre)
(string-append pre "-manual.ps"))
prefixes)
(map (lambda (pre)
(string-append pre "-manual.pdf"))
prefixes))))
(define install
(always->rc "install"
(append (list "show-sqrt") manuals)
(lambda ()
(for-each (lambda (f) (display ">>> ") (display f) (newline)) ($+))
(display "install done.\n"))))
(define clean
(always->rc "clean"
(list)
(lambda ()
(for-each (lambda (f)
(delete-filesys-object (expand-file-name f (cwd))))
(append manuals (list "show-sqrt"))))))
(define rcs (list proggy install clean))
(define commons (append obj-rules lib-rules tex-rules))
(define rules (rcs+commons->rules pred rcs commons))
;; (define rule-set (rules->rule-set rules))
(define done (make rules (list "clean" "install")))

View File

@ -37,7 +37,7 @@
(let ((maybe-fname (find (lambda (current)
(pred fname (car current)))
rcs)))
(if maybe-fname maybe-fname (error "lookup-fname: fname not found."))))
(if maybe-fname maybe-fname #f)))
(define (lookup-rule pred fname rules)
(let ((maybe-rule (find (lambda (current)