diff --git a/examples/test-embed.scm b/examples/test-embed.scm new file mode 100644 index 0000000..4dd81d1 --- /dev/null +++ b/examples/test-embed.scm @@ -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"))) diff --git a/to-rule-set.scm b/to-rule-set.scm index 7f3c3c9..7112cce 100644 --- a/to-rule-set.scm +++ b/to-rule-set.scm @@ -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)