From: Matt Birkholz Date: Sun, 15 Sep 2013 03:48:26 +0000 (-0700) Subject: Add install-load-option. X-Git-Tag: release-9.2.0~112 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=35b7c8ea7bfdffdc6eb4f25b9b57ac742dfdad91;p=mit-scheme.git Add install-load-option. Use install-load-option in the four FFI wrappers' Makefiles (and the GNU convention of lowercasing internal makefile variables). Delete corresponding instruction from their READMEs. Presume there is an optiondb.scm in the system library path and that its directory is writable by the installer. --- diff --git a/src/blowfish/Makefile.in b/src/blowfish/Makefile.in index 63629147c..34019eaa0 100644 --- a/src/blowfish/Makefile.in +++ b/src/blowfish/Makefile.in @@ -21,7 +21,7 @@ # 02110-1301, USA. MIT_SCHEME_EXE = mit-scheme -EXE = '$(MIT_SCHEME_EXE)' --batch-mode +exe = '$(MIT_SCHEME_EXE)' --batch-mode CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ @@ -29,13 +29,14 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ all: blowfish-shim.so blowfish-types.bin blowfish-const.bin - echo '(load "compile")' | $(EXE) + echo '(load "compile")' | $(exe) check: - echo '(load "check")' | $(EXE) + echo '(load "check")' | $(exe) install: - echo '(install-shim "blowfish")' | $(EXE) -- *.com *.bci *.pkd make.scm + echo '(install-shim "blowfish")' | $(exe) -- *.com *.bci *.pkd make.scm + echo '(install-load-option "blowfish")' | $(exe) clean: rm -f blowfish-const.scm blowfish-const blowfish-const.c @@ -52,21 +53,21 @@ maintainer-clean: distclean rm -rf autom4te.cache blowfish-shim.so: blowfish-shim.o blowfish-adapter.o - echo "(link-shim)" | $(EXE) -- $(LDFLAGS) -o $@ $^ $(LIBS) + echo "(link-shim)" | $(exe) -- $(LDFLAGS) -o $@ $^ $(LIBS) blowfish-adapter.o: blowfish-adapter.c blowfish-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< blowfish-shim.o: blowfish-shim.c blowfish-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< blowfish-shim.c blowfish-const.c blowfish-types.bin: \ blowfish.cdecl blowfish-shim.h echo '(generate-shim "blowfish" "#include \"blowfish-shim.h\"")' \ - | $(EXE) + | $(exe) blowfish-const.bin: blowfish-const.scm - echo '(sf "blowfish-const")' | $(EXE) + echo '(sf "blowfish-const")' | $(exe) blowfish-const.scm: blowfish-const ./blowfish-const diff --git a/src/blowfish/README b/src/blowfish/README index f535d29e5..400ff5ac3 100644 --- a/src/blowfish/README +++ b/src/blowfish/README @@ -8,15 +8,10 @@ built outside the core build tree in the customary way: make all check install The install target copies a shared library shim and compiled Scheme -files into the system library path. You can override the default -command name "mit-scheme" (and thus the system library path) by -setting MIT_SCHEME_EXE. +files into the system library path, and re-writes the optiondb.scm +found there. You can override the default command name "mit-scheme" +(and thus the system library path) by setting MIT_SCHEME_EXE. -To load via load-option, install the following in your optiondb.scm: - - (define-load-option 'BLOWFISH - (guarded-system-loader '(blowfish) "blowfish")) - -You will need to import the bindings you want to use. They are not -exported to the global environment because they would conflict with -the exports from (runtime blowfish). +To use: (load-option 'BLOWFISH) and import the bindings you want. +They are not exported to the global environment because they would +conflict with the exports from (runtime blowfish). diff --git a/src/ffi/build.scm.in b/src/ffi/build.scm.in index 36f36d623..a28788350 100644 --- a/src/ffi/build.scm.in +++ b/src/ffi/build.scm.in @@ -53,6 +53,37 @@ USA. library-dir (except-last-pair (pathname-directory library-dir)))))))) + +(define (install-load-option name #!optional directory) + (guarantee-string name 'INSTALL-OPTION) + (let ((dir (if (default-object? directory) name directory))) + (guarantee-string dir 'INSTALL-OPTION) + (rewrite-file (system-library-pathname "optiondb.scm") + (lambda (in out) + (rewrite-optiondb name dir in out))))) + +(define (rewrite-file name rewriter) + (let ((tmp (pathname-new-type name "tmp"))) + (call-with-exclusive-output-file tmp + (lambda (out) + (call-with-input-file name + (lambda (in) + (rewriter in out))))) + (rename-file tmp name))) + +(define (rewrite-optiondb name dirname in out) + (do ((line (read-line in) (read-line in))) + ((eof-object? line)) + (write-string line out) + (newline out)) + (fresh-line out) + (newline out) + (write-string "(define-load-option '" out) + (write-string name out) + (newline out) + (write-string " (standard-system-loader \"" out) + (write-string dirname out) + (write-string "\"))" out)) (define (parse-words string) (burst-string string char-set:whitespace #t)) @@ -74,13 +105,6 @@ USA. (system-library-pathname "mit-scheme.h"))))) (parse-words "@CFLAGS@ @MODULE_CFLAGS@"))) -(define (working-directory-name) - (let ((name (pathname-name (directory-pathname-as-file - (working-directory-pathname))))) - (if (and (string? name) (not (string-null? name))) - name - (error "Could not find the current working directory name.")))) - (define (run-command command) (with-notification (lambda (port) diff --git a/src/ffi/ffi.pkg b/src/ffi/ffi.pkg index 685b23eb5..002e4e333 100644 --- a/src/ffi/ffi.pkg +++ b/src/ffi/ffi.pkg @@ -46,4 +46,5 @@ FFI System Packaging |# generate-shim compile-shim link-shim - install-shim)) \ No newline at end of file + install-shim + install-load-option)) \ No newline at end of file diff --git a/src/gdbm/Makefile b/src/gdbm/Makefile index 874937749..0024150a9 100644 --- a/src/gdbm/Makefile +++ b/src/gdbm/Makefile @@ -21,16 +21,17 @@ # 02110-1301, USA. MIT_SCHEME_EXE = mit-scheme -EXE = '$(MIT_SCHEME_EXE)' --batch-mode +exe = '$(MIT_SCHEME_EXE)' --batch-mode all: gdbm-shim.so gdbm-types.bin gdbm-const.bin - echo '(load "compile")' | $(EXE) + echo '(load "compile")' | $(exe) check: - echo '(load "check")' | $(EXE) + echo '(load "check")' | $(exe) install: - echo '(install-shim "gdbm")' | $(EXE) -- *.com *.bci *.pkd make.scm + echo '(install-shim "gdbm")' | $(exe) -- *.com *.bci *.pkd make.scm + echo '(install-load-option "gdbm2" "gdbm")' | $(exe) clean distclean maintainer-clean: rm -f gdbm-const.scm gdbm-const gdbm-const.c gdbm-shim.c @@ -39,19 +40,19 @@ clean distclean maintainer-clean: rm -f gdbm-check.db gdbm-shim.so: gdbm-shim.o gdbm-adapter.o - echo "(link-shim)" | $(EXE) -- -o $@ $^ -lgdbm + echo "(link-shim)" | $(exe) -- -o $@ $^ -lgdbm gdbm-adapter.o: gdbm-adapter.c gdbm-shim.h - echo '(compile-shim)' | $(EXE) -- -c $< + echo '(compile-shim)' | $(exe) -- -c $< gdbm-shim.o: gdbm-shim.c gdbm-shim.h - echo '(compile-shim)' | $(EXE) -- -c $< + echo '(compile-shim)' | $(exe) -- -c $< gdbm-shim.c gdbm-const.c gdbm-types.bin: gdbm.cdecl gdbm-shim.h - echo '(generate-shim "gdbm" "#include \"gdbm-shim.h\"")' | $(EXE) + echo '(generate-shim "gdbm" "#include \"gdbm-shim.h\"")' | $(exe) gdbm-const.bin: gdbm-const.scm - echo '(sf "gdbm-const")' | $(EXE) + echo '(sf "gdbm-const")' | $(exe) gdbm-const.scm: gdbm-const ./gdbm-const diff --git a/src/gdbm/README b/src/gdbm/README index b59f067f0..fee1fa66b 100644 --- a/src/gdbm/README +++ b/src/gdbm/README @@ -8,17 +8,11 @@ you know you have libgdbm installed, you should win with this command: make all check install The install target copies a shared library shim and compiled Scheme -files into the system library path. You can override the default -command name "mit-scheme" (and thus the system library path) by -setting MIT_SCHEME_EXE. +files into the system library path, and re-writes the optiondb.scm +found there. You can override the default command name "mit-scheme" +(and thus the system library path) by setting MIT_SCHEME_EXE. -To load via load-option, install the following in your optiondb.scm: - - (define-load-option 'GDBM2 (guarded-system-loader '(gdbm) "gdbm")) - -You will need to call it GDBM2 while GDBM refers to the original -microcode module. - -You will need to import the bindings you want to use. They are not -exported to the global environment because they would conflict with -the exports from (runtime gdbm). +The option is currently called GDBM2 until GDBM no longer refers to +the original microcode module. You will need to import the bindings +you want to use. They are not exported to the global environment +because they would conflict with the exports from (runtime gdbm). diff --git a/src/md5/Makefile.in b/src/md5/Makefile.in index dd0f845dc..306f91909 100644 --- a/src/md5/Makefile.in +++ b/src/md5/Makefile.in @@ -21,7 +21,7 @@ # 02110-1301, USA. MIT_SCHEME_EXE = mit-scheme -EXE = '$(MIT_SCHEME_EXE)' --batch-mode +exe = '$(MIT_SCHEME_EXE)' --batch-mode CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ @@ -29,13 +29,14 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ all: md5-shim.so md5-types.bin md5-const.bin - echo '(load "compile")' | $(EXE) + echo '(load "compile")' | $(exe) check: - echo '(load "check")' | $(EXE) + echo '(load "check")' | $(exe) install: - echo '(install-shim "md5")' | $(EXE) -- *.com *.bci *.pkd make.scm + echo '(install-shim "md5")' | $(exe) -- *.com *.bci *.pkd make.scm + echo '(install-load-option "md5")' | $(exe) clean: rm -f md5-const.scm md5-const md5-const.c md5-shim.c @@ -51,19 +52,19 @@ maintainer-clean: distclean rm -rf autom4te.cache md5-shim.so: md5-shim.o md5-adapter.o - echo "(link-shim)" | $(EXE) -- $(LDFLAGS) -o $@ $^ $(LIBS) + echo "(link-shim)" | $(exe) -- $(LDFLAGS) -o $@ $^ $(LIBS) md5-adapter.o: md5-adapter.c md5-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< md5-shim.o: md5-shim.c md5-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< md5-shim.c md5-const.c md5-types.bin: md5.cdecl md5-shim.h - echo '(generate-shim "md5" "#include \"md5-shim.h\"")' | $(EXE) + echo '(generate-shim "md5" "#include \"md5-shim.h\"")' | $(exe) md5-const.bin: md5-const.scm - echo '(sf "md5-const")' | $(EXE) + echo '(sf "md5-const")' | $(exe) md5-const.scm: md5-const ./md5-const diff --git a/src/md5/README b/src/md5/README index bbabe599d..de928cc8f 100644 --- a/src/md5/README +++ b/src/md5/README @@ -9,15 +9,10 @@ way: make all check install The install target copies a shared library shim and compiled Scheme -files into the system library path. You can override the default -command name "mit-scheme" (and thus the system library path) by -setting MIT_SCHEME_EXE. +files into the system library path, and re-writes the optiondb.scm +found there. You can override the default command name "mit-scheme" +(and thus the system library path) by setting MIT_SCHEME_EXE. -To load via load-option, install the following in your optiondb.scm: - - (define-load-option 'MD5 - (guarded-system-loader '(md5) "md5")) - -You will need to import the bindings you want to use. They are not -exported to the global environment because they would conflict with -the exports from (runtime crypto). +To use: (load-option 'MD5) and import the bindings you want. They are +not exported to the global environment because they would conflict +with the exports from (runtime crypto). diff --git a/src/mhash/Makefile.in b/src/mhash/Makefile.in index 0a82d9acf..8b2383607 100644 --- a/src/mhash/Makefile.in +++ b/src/mhash/Makefile.in @@ -21,7 +21,7 @@ # 02110-1301, USA. MIT_SCHEME_EXE = mit-scheme -EXE = '$(MIT_SCHEME_EXE)' --batch-mode +exe = '$(MIT_SCHEME_EXE)' --batch-mode CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ @@ -29,13 +29,14 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ all: mhash-shim.so mhash-types.bin mhash-const.bin - echo '(load "compile")' | $(EXE) + echo '(load "compile")' | $(exe) check: - echo '(load "check")' | $(EXE) + echo '(load "check")' | $(exe) install: - echo '(install-shim "mhash")' | $(EXE) -- *.com *.bci *.pkd make.scm + echo '(install-shim "mhash")' | $(exe) -- *.com *.bci *.pkd make.scm + echo '(install-load-option "mhash")' | $(exe) clean: rm -f mhash-const.scm mhash-const mhash-const.c mhash-shim.c @@ -51,19 +52,19 @@ maintainer-clean: distclean rm -rf autom4te.cache mhash-shim.so: mhash-shim.o mhash-adapter.o - echo "(link-shim)" | $(EXE) -- $(LDFLAGS) -o $@ $^ $(LIBS) + echo "(link-shim)" | $(exe) -- $(LDFLAGS) -o $@ $^ $(LIBS) mhash-adapter.o: mhash-adapter.c mhash-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< mhash-shim.o: mhash-shim.c mhash-shim.h - echo '(compile-shim)' | $(EXE) -- $(CPPFLAGS) $(CFLAGS) -c $< + echo '(compile-shim)' | $(exe) -- $(CPPFLAGS) $(CFLAGS) -c $< mhash-shim.c mhash-const.c mhash-types.bin: mhash.cdecl mhash-shim.h - echo '(generate-shim "mhash" "#include \"mhash-shim.h\"")' | $(EXE) + echo '(generate-shim "mhash" "#include \"mhash-shim.h\"")' | $(exe) mhash-const.bin: mhash-const.scm - echo '(sf "mhash-const")' | $(EXE) + echo '(sf "mhash-const")' | $(exe) mhash-const.scm: mhash-const ./mhash-const diff --git a/src/mhash/README b/src/mhash/README index 528bd107a..6aca4b097 100644 --- a/src/mhash/README +++ b/src/mhash/README @@ -9,15 +9,10 @@ way: make all check install The install target copies a shared library shim and compiled Scheme -files into the system library path. You can override the default -command name "mit-scheme" (and thus the system library path) by -setting MIT_SCHEME_EXE. +files into the system library path, and re-writes the optiondb.scm +found there. You can override the default command name "mit-scheme" +(and thus the system library path) by setting MIT_SCHEME_EXE. -To load via load-option, install the following in your optiondb.scm: - - (define-load-option 'MHASH - (guarded-system-loader '(mhash) "mhash")) - -You will need to import the bindings you want to use. They are not -exported to the global environment because they would conflict with -the exports from (runtime crypto). +To use: (load-option 'MHASH) and import the bindings you want. They +are not exported to the global environment because they would conflict +with the exports from (runtime crypto). diff --git a/src/runtime/ffi.scm b/src/runtime/ffi.scm index 87f2d4e0f..29e0c7ba7 100644 --- a/src/runtime/ffi.scm +++ b/src/runtime/ffi.scm @@ -541,6 +541,11 @@ USA. (load-ffi-quietly) ((environment-lookup (->environment '(ffi)) 'install-shim) library)) +(define (install-load-option name #!optional directory) + (load-ffi-quietly) + ((environment-lookup (->environment '(ffi)) 'install-load-option) + name directory)) + (define (load-ffi-quietly) (if (not (name->package '(FFI))) (let ((kernel (lambda () diff --git a/src/runtime/option.scm b/src/runtime/option.scm index c44330376..e703034a5 100644 --- a/src/runtime/option.scm +++ b/src/runtime/option.scm @@ -130,4 +130,10 @@ USA. (define (force* value) (cond ((procedure? value) (force* (value))) ((promise? value) (force* (force value))) - (else value))) \ No newline at end of file + (else value))) + +(define (standard-system-loader name) + (let ((here (merge-pathnames (directory-pathname name) + (directory-pathname (current-load-pathname))))) + (lambda () + (with-working-directory-pathname here (lambda () (load "make")))))) \ No newline at end of file diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index b710d8820..a0caea3c6 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -3013,7 +3013,8 @@ USA. load-option local-load-options standard-load-options - standard-option-loader)) + standard-option-loader + standard-system-loader)) (define-package (runtime parser) (files "parse") @@ -3338,7 +3339,8 @@ USA. generate-shim compile-shim link-shim - install-shim) + install-shim + install-load-option) (initialization (initialize-package!))) (define-package (runtime program-copier)