(define image-dir "../../image") (define prefix (string-append image-dir "/" "usr")) (define my-lib-dir (string-append prefix "/" "lib")) (define my-bin-dir (string-append prefix "/" "bin")) (define my-share-dir (string-append prefix "/" "share")) (define my-doc-dir (string-append my-share-dir "/" "doc")) (define my-install-doc-dir (string-append my-doc-dir "/" "show-sqrt-1.0")) (define clean-files (list "wildio.o" "mymath.o" "libwildio.so.1.0" "libmymath.so.1.0" "libwildio.so.1" "libmymath.so.1" "libwildio.so" "libmymath.so" "show-sqrt" "manual.dvi" "manual.pdf" "manual.log" "manual.aux")) (define file-set (makefile ;; ;; create a configfile ;; (md5 "config.h" () (let ((outport (open-output-file ($@)))) (with-current-output-port outport (display "#ifndef MY_DELTA_MAX\n") (display "#define MY_DELTA_MAX 0.000000001\n") (display "#endif\n") (close-output-port outport)))) ;; ;; build libmymath.* ;; (file "mymath.o" ("mymath.c" "config.h") (run (gcc -fPIC -c ,($<)))) (file "libmymath.so.1.0" ("mymath.o") (run (gcc -shared ,"-Wl,-soname,libmymath.so.1" -o ,($@) ,($<)))) ;; ;; build wildio.* ;; (file "wildio.o" ("wildio.c") (run (gcc -fPIC -c ,($<)))) (file "libwildio.so.1.0" ("wildio.o") (run (gcc -shared "-Wl,-soname,libwildio.so.1" -o ,($@) ,($<)))) ;; ;; build the program ;; (md5 "show-sqrt" ("main.c" "libmymath.so.1" "libwildio.so.1" "wildio.h" "mymath.h") (run (gcc -L ,(cwd) -L ,my-lib-dir -rdynamic -o ,($@) ,($<) ,"libwildio.so.1" ,"libmymath.so.1" -ldl))) ;; ;; install libs ;; (file "libmymath.so.1" ("libmymath.so.1.0") (create-symlink ($<) ($@))) (file "libmymath.so" ("libmymath.so.1") (create-symlink ($<) ($@))) (file "libwildio.so.1" ("libwildio.so.1.0") (create-symlink ($<) ($@))) (file "libwildio.so" ("libwildio.so.1") (create-symlink ($<) ($@))) (file (string-append my-lib-dir "/" "libmymath.so.1") ((string-append my-lib-dir "/" "libmymath.so.1.0")) (with-cwd ($@/) (create-symlink (/$<) (/$@)))) (file (string-append my-lib-dir "/" "libmymath.so") ((string-append my-lib-dir "/" "libmymath.so.1")) (with-cwd ($@/) (create-symlink (/$<) (/$@)))) (file (string-append my-lib-dir "/" "libwildio.so.1") ((string-append my-lib-dir "/" "libwildio.so.1.0")) (with-cwd ($@/) (create-symlink (/$<) (/$@)))) (file (string-append my-lib-dir "/" "libwildio.so") ((string-append my-lib-dir "/" "libwildio.so.1")) (with-cwd ($@/) (create-symlink (/$<) (/$@)))) (file (string-append my-lib-dir "/" "libwildio.so.1.0") ("libwildio.so.1.0" my-lib-dir) (run (cp ,($<) ,($@)))) (file (string-append my-lib-dir "/" "libmymath.so.1.0") ("libmymath.so.1.0" my-lib-dir) (run (cp ,($<) ,($@)))) ;; ;; install the program ;; (file (string-append my-bin-dir "/" "show-sqrt") ("show-sqrt" my-bin-dir) (run (cp ,($<) ,($@)))) ;; ;; build the manual ;; (md5 "manual.dvi" ("manual.tex") (run (latex ,($<)))) (file "manual.pdf" ("manual.dvi") (run (dvipdfm -o ,($@) ,($<)))) ;; ;; install the manual ;; (file (string-append my-install-doc-dir "/" "manual.pdf") ("manual.pdf" my-install-doc-dir) (run (cp ,($<) ,($@)))) ;; ;; install all ;; (always "install" ((string-append my-lib-dir "/" "libmymath.so.1.0") (string-append my-lib-dir "/" "libwildio.so.1.0") (string-append my-lib-dir "/" "libmymath.so.1") (string-append my-lib-dir "/" "libwildio.so.1") (string-append my-lib-dir "/" "libmymath.so") (string-append my-lib-dir "/" "libwildio.so") (string-append my-bin-dir "/" "show-sqrt") (string-append my-install-doc-dir "/" "manual.pdf")) (display "install done.\n")) ;; ;; clean files ;; (always "clean" () (for-each (lambda (f) (delete-filesys-object (expand-file-name f (cwd)))) clean-files)) ;; ;; clean files ;; (always "mrproper" ("clean") (for-each (lambda (f) (delete-filesys-object (expand-file-name f (cwd)))) (list "checksums.md5"))) ;; ;; uninstall all ;; (always "uninstall" ("clean") (begin (display "uninstall: \n") (for-each (lambda (f) (display "remove: ") (display f) (newline) (delete-filesys-object f)) (list (string-append my-lib-dir "/" "libmymath.so.1.0") (string-append my-lib-dir "/" "libwildio.so.1.0") (string-append my-lib-dir "/" "libmymath.so.1") (string-append my-lib-dir "/" "libwildio.so.1") (string-append my-lib-dir "/" "libmymath.so") (string-append my-lib-dir "/" "libwildio.so") (string-append my-bin-dir "/" "show-sqrt") (string-append my-install-doc-dir "/" "manual.pdf") my-install-doc-dir my-doc-dir my-share-dir my-lib-dir my-bin-dir prefix image-dir)) (display "uninstall done.\n"))) ;; ;; install dirs ;; (once image-dir () (create-directory image-dir)) (once prefix (image-dir) (create-directory prefix)) (once my-lib-dir (prefix) (create-directory my-lib-dir)) (once my-bin-dir (prefix) (create-directory my-bin-dir)) (once my-share-dir (prefix) (create-directory my-share-dir)) (once my-doc-dir (my-share-dir) (create-directory my-doc-dir)) (once my-install-doc-dir (my-doc-dir) (create-directory my-install-doc-dir)) ;; ;; a small test ;; (always "test" ("install") (let ((proggy (expand-file-name "show-sqrt" my-bin-dir))) (display "testing ") (display proggy) (newline) (setenv "LD_LIBRARY_PATH" my-lib-dir) (display "# sqrt 2.0:\n") (run (,proggy ,"2.0")) (display "# sqrt 5.0:\n") (run (,proggy ,"5.0")) (display "ok.\n")))))