added automatic variables in (currently only) gnu style.

fixed a small bug: with-cwd and file-name-nondirectory was needed to build
This commit is contained in:
jottbee 2005-02-15 19:03:05 +00:00
parent 62be1f7142
commit 12aa087ddf
1 changed files with 111 additions and 164 deletions

View File

@ -14,123 +14,102 @@
"show-sqrt"
"manual.dvi" "manual.pdf" "manual.log" "manual.aux"))
(define rule-set
(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.*
;;
(md5 "mymath.o"
("config.h" "mymath.c")
(lambda ()
(run (gcc -fPIC -c ,"mymath.c"))))
(rule "libmymath.so.1.0"
(file "mymath.o"
("mymath.c" "config.h")
(run (gcc -fPIC -c ,($<))))
(file "libmymath.so.1.0"
("mymath.o")
(lambda ()
(run (gcc -shared ,"-Wl,-soname,libmymath.so.1"
-o ,"libmymath.so.1.0" ,"mymath.o"))))
(run (gcc -shared ,"-Wl,-soname,libmymath.so.1" -o ,($@) ,($<))))
;;
;; build wildio.*
;;
(rule "wildio.o"
(file "wildio.o"
("wildio.c")
(lambda ()
(run (gcc -fPIC -c ,"wildio.c"))))
(rule "libwildio.so.1.0"
(run (gcc -fPIC -c ,($<))))
(file "libwildio.so.1.0"
("wildio.o")
(lambda ()
(run (gcc -shared "-Wl,-soname,libwildio.so.1"
-o ,"libwildio.so.1.0" ,"wildio.o"))))
(run (gcc -shared "-Wl,-soname,libwildio.so.1" -o ,($@) ,($<))))
;;
;; build the program
;;
(rule "show-sqrt"
("libmymath.so.1" "libwildio.so.1" "main.c" "wildio.h" "mymath.h")
(lambda ()
(run (gcc -L ,"." -L ,my-lib-dir -rdynamic
-o ,(expand-file-name "show-sqrt" (cwd))
,(expand-file-name "main.c" (cwd))
,(expand-file-name "libwildio.so.1" (cwd))
,(expand-file-name "libmymath.so.1" (cwd)) -ldl))))
(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
;;
(rule "libmymath.so.1"
(file "libmymath.so.1"
("libmymath.so.1.0")
(lambda ()
(create-symlink "libmymath.so.1.0" "libmymath.so.1")))
(rule "libmymath.so"
(create-symlink ($<) ($@)))
(file "libmymath.so"
("libmymath.so.1")
(lambda ()
(create-symlink "libmymath.so.1" "libmymath.so")))
(rule "libwildio.so.1"
(create-symlink ($<) ($@)))
(file "libwildio.so.1"
("libwildio.so.1.0")
(lambda ()
(create-symlink "libwildio.so.1.0" "libwildio.so.1")))
(rule "libwildio.so"
(create-symlink ($<) ($@)))
(file "libwildio.so"
("libwildio.so.1")
(lambda ()
(create-symlink "libwildio.so.1" "libwildio.so")))
(rule (string-append my-lib-dir "/" "libmymath.so.1")
(create-symlink ($<) ($@)))
(file (string-append my-lib-dir "/" "libmymath.so.1")
((string-append my-lib-dir "/" "libmymath.so.1.0"))
(lambda ()
(with-cwd my-lib-dir
(create-symlink "libmymath.so.1.0" "libmymath.so.1"))))
(rule (string-append my-lib-dir "/" "libmymath.so")
(with-cwd ($@/) (create-symlink (/$<) (/$@))))
(file (string-append my-lib-dir "/" "libmymath.so")
((string-append my-lib-dir "/" "libmymath.so.1"))
(lambda ()
(with-cwd my-lib-dir
(create-symlink "libmymath.so.1" "libmymath.so"))))
(rule (string-append my-lib-dir "/" "libwildio.so.1")
(with-cwd ($@/) (create-symlink (/$<) (/$@))))
(file (string-append my-lib-dir "/" "libwildio.so.1")
((string-append my-lib-dir "/" "libwildio.so.1.0"))
(lambda ()
(with-cwd my-lib-dir
(create-symlink "libwildio.so.1.0" "libwildio.so.1"))))
(rule (string-append my-lib-dir "/" "libwildio.so")
(with-cwd ($@/) (create-symlink (/$<) (/$@))))
(file (string-append my-lib-dir "/" "libwildio.so")
((string-append my-lib-dir "/" "libwildio.so.1"))
(lambda ()
(with-cwd my-lib-dir
(create-symlink "libwildio.so.1" "libwildio.so"))))
(rule (string-append my-lib-dir "/" "libwildio.so.1.0")
(my-lib-dir "libwildio.so.1.0")
(lambda ()
(run (cp ,"libwildio.so.1.0"
,(string-append my-lib-dir "/" "libwildio.so.1.0")))))
(rule (string-append my-lib-dir "/" "libmymath.so.1.0")
(my-lib-dir "libmymath.so.1.0")
(lambda ()
(run (cp ,"libmymath.so.1.0"
,(string-append my-lib-dir "/" "libmymath.so.1.0")))))
(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
;;
(rule (string-append my-bin-dir "/" "show-sqrt")
(my-bin-dir "show-sqrt")
(lambda ()
(run (cp ,"show-sqrt"
,(string-append my-bin-dir "/" "show-sqrt")))))
(file (string-append my-bin-dir "/" "show-sqrt")
("show-sqrt" my-bin-dir)
(run (cp ,($<) ,($@))))
;;
;; build the manual
;;
(md5 "manual.dvi"
("manual.tex")
(lambda ()
(run (latex ,"manual.tex"))))
(rule "manual.pdf"
(run (latex ,($<))))
(file "manual.pdf"
("manual.dvi")
(lambda ()
(run (dvipdfm -o ,"manual.pdf" ,"manual.dvi"))))
(run (dvipdfm -o ,($@) ,($<))))
;;
;; install the manual
;;
(rule (string-append my-install-doc-dir "/" "manual.pdf")
(my-install-doc-dir "manual.pdf")
(lambda ()
(run (cp "manual.pdf"
,(string-append my-install-doc-dir "/" "manual.pdf")))))
(file (string-append my-install-doc-dir "/" "manual.pdf")
("manual.pdf" my-install-doc-dir)
(run (cp ,($<) ,($@))))
;;
;; install all
;;
(rule "install"
(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")
@ -139,56 +118,32 @@
(string-append my-lib-dir "/" "libwildio.so")
(string-append my-bin-dir "/" "show-sqrt")
(string-append my-install-doc-dir "/" "manual.pdf"))
(lambda ()
(display "install done.\n")))
(display "install done.\n"))
;;
;; create checksums.md5
;;
(once "checksums.md5"
("manual.tex" "main.c" "mymath.c"
"mymath.h" "wildio.c" "wildio.h" "config.h")
(lambda ()
(let ((outport (open-output-file (expand-file-name "checksums.md5"
(cwd)))))
(with-current-output-port outport (display ""))
(close-output-port outport))))
(rule "config.h"
()
(lambda ()
(let ((outport (open-output-file
(expand-file-name "config.h" (cwd)))))
(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)))))
;;
;; clean rules
;; clean files
;;
(always "clean"
()
(lambda ()
(for-each (lambda (f)
(delete-filesys-object (expand-file-name f (cwd))))
clean-files)))
clean-files))
;;
;; clean rules
;; clean files
;;
(always "mrproper"
("clean")
(lambda ()
(for-each (lambda (f)
(delete-filesys-object (expand-file-name f (cwd))))
(list "checksums.md5"))))
(list "checksums.md5")))
;;
;; uninstall all
;;
(always "uninstall"
()
(lambda ()
("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")
@ -211,38 +166,30 @@
;;
(once image-dir
()
(lambda ()
(create-directory image-dir)))
(create-directory image-dir))
(once prefix
(image-dir)
(lambda ()
(create-directory prefix)))
(create-directory prefix))
(once my-lib-dir
(prefix)
(lambda ()
(create-directory my-lib-dir)))
(create-directory my-lib-dir))
(once my-bin-dir
(prefix)
(lambda ()
(create-directory my-bin-dir)))
(create-directory my-bin-dir))
(once my-share-dir
(prefix)
(lambda ()
(create-directory my-share-dir)))
(create-directory my-share-dir))
(once my-doc-dir
(my-share-dir)
(lambda ()
(create-directory my-doc-dir)))
(create-directory my-doc-dir))
(once my-install-doc-dir
(my-doc-dir)
(lambda ()
(create-directory my-install-doc-dir)))
(create-directory my-install-doc-dir))
;;
;; a small test
;;
(always "test"
("install")
(lambda ()
(let ((proggy (expand-file-name "show-sqrt" my-bin-dir)))
(display "testing ") (display proggy) (newline)
(setenv "LD_LIBRARY_PATH" my-lib-dir)
@ -250,4 +197,4 @@
(run (,proggy ,"2.0"))
(display "# sqrt 5.0:\n")
(run (,proggy ,"5.0"))
(display "ok.\n"))))))
(display "ok.\n")))))