scsh-make/examples/test-embed.scm

87 lines
2.3 KiB
Scheme
Raw Normal View History

(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")))