;;;; Build Utilities
;;; package: (ffi build)
-(define (compile-bundle)
- (with-system-library-directories
- '("./")
- (lambda ()
- (if (eq? microcode-id/compiled-code-type 'C)
- (fluid-let ((compiler:invoke-c-compiler? #f))
- (compile-dir)
- (c-compile-pkgs))
- (compile-dir)))))
-
(define (compile-shim)
(run-command (append cc-cmdline-prefix (command-line))))
(define (link-shim)
(run-command (append CCLD LDFLAGS (command-line) MODULE_LDFLAGS)))
-(define (install-bundle)
- (let* ((name (working-directory-name))
- (target-dir (->namestring (system-library-pathname name #f))))
- (run-command (list "rm" "-rf" target-dir))
- (run-command (list "mkdir" target-dir))
- (run-command (append (list "install" "-m" "644")
- (command-line)
- (list target-dir)))))
-
(define (install-shim libname)
- (run-command (list "install" "-m" "644"
- (string-append libname "-shim.so")
- (string-append libname "-types.bin")
- (string-append libname "-const.bin")
- (->namestring (system-library-directory-pathname)))))
+ (let ((library-dir (->namestring
+ (system-library-directory-pathname libname))))
+ (run-command (list "rm" "-rf" library-dir))
+ (run-command (list "mkdir" library-dir))
+ (run-command (append (list "install" "-m" "644")
+ (command-line) (list library-dir)))
+ (run-command (list "install" "-m" "644"
+ (string-append libname "-shim.so")
+ (string-append libname "-types.bin")
+ (string-append libname "-const.bin")
+ (->namestring
+ (pathname-new-directory
+ library-dir
+ (except-last-pair
+ (pathname-directory library-dir))))))))
+
+(define (generate-shim library #!optional prefix)
+ (let ((-const (string-append library"-const"))
+ (-const.c (string-append library"-const.c"))
+ (-const.o (string-append library"-const.o")))
+ (c-generate library prefix)
+ (run-command (append CC CFLAGS (list "-c" -const.c)))
+ (run-command (append CC LDFLAGS (list "-o" -const -const.o)))
+ (run-command (list (->namestring
+ (merge-pathnames -const (working-directory-pathname)))))
+ (sf -const)))
\f
(define (parse-words string)
(burst-string string char-set:whitespace #t))
+(define CC (parse-words "@CC@"))
+(define CFLAGS (parse-words "@CFLAGS@"))
(define CCLD (parse-words "@CCLD@"))
(define LDFLAGS (parse-words "@LDFLAGS@"))
(define MODULE_LDFLAGS (parse-words "@MODULE_LDFLAGS@"))
(car command) (cdr command)
'working-directory (working-directory-pathname))))
(if (not (zero? code))
- (error "Process exited with error code:" code command))))))
-
-(define (compile-dir)
- (let ((name (working-directory-name)))
- (if (file-exists? (pathname-new-type name "sf"))
- (begin
- (load (pathname-new-type name "sf"))
- (load (pathname-new-type name "cbf")))
- (load "compile"))))
-
-(define (c-compile-pkgs)
- (let* ((name (working-directory-name))
- (root
- (if (string=? name "star-parser")
- "parser"
- name))
- (compile-pkg
- (lambda (os)
- (cbf-conditionally (string-append root "-" os ".pkd")))))
- (compile-pkg "unx")
- (compile-pkg "w32")
- (compile-pkg "os2")))
-
-(define (cbf-conditionally pathname)
- (let ((input (pathname-default-type pathname "bin"))
- (file-type (if (eq? microcode-id/compiled-code-type 'C)
- "c" "com")))
- (if (file-modification-time<? (pathname-new-type pathname file-type)
- input)
- (compile-file input))))
\ No newline at end of file
+ (error "Process exited with error code:" code command))))))
\ No newline at end of file
MIT_SCHEME_EXE = mit-scheme
EXE = '$(MIT_SCHEME_EXE)' --batch-mode
-build: gdbm-shim.so gdbm-types.bin gdbm-const.bin
- echo "(compile-bundle)" | $(EXE)
+build: gdbm-shim.so
+ echo '(load "compile")' | $(EXE)
check:
echo '(load "check")' | $(EXE)
install: build
- echo "(install-bundle)" | $(EXE) -- *.com *.bci *.pkd make.scm
- echo '(install-shim "gdbm")' | $(EXE)
+ echo '(install-shim "gdbm")' | $(EXE) -- *.com *.bci *.pkd make.scm
clean:
rm -f gdbm-const.scm gdbm-const gdbm-const.c gdbm-shim.c
gdbm-shim.o: gdbm-shim.c gdbm-shim.h
echo '(compile-shim)' | $(EXE) -- -c $<
-gdbm-shim.c gdbm-const.c gdbm-types.bin: gdbm-shim.h gdbm.cdecl
+gdbm-shim.c: gdbm.cdecl gdbm-shim.h
echo '(generate-shim "gdbm" "#include \"gdbm-shim.h\"")' | $(EXE)
-gdbm-const.bin: gdbm-const.scm
- echo '(sf "gdbm-const")' | $(EXE)
-
-gdbm-const.scm: gdbm-const
- ./gdbm-const
-
-gdbm-const: gdbm-const.o
- $(CC) $(LDFLAGS) -o $@ $^
-
-gdbm-const.o: gdbm-const.c gdbm-shim.h
- $(CC) $(CFLAGS) -c $<
-
.PHONY: build install clean
\ No newline at end of file
(define (generate-shim library #!optional prefix)
(load-ffi-quietly)
- ((environment-lookup (->environment '(ffi)) 'c-generate) library prefix))
+ ((environment-lookup (->environment '(ffi)) 'generate-shim) library prefix))
(define (compile-shim)
(load-ffi-quietly)
(load-ffi-quietly)
((environment-lookup (->environment '(ffi)) 'install-shim) library))
-(define (compile-bundle)
- (load-ffi-quietly)
- ((environment-lookup (->environment '(ffi)) 'compile-bundle)))
-
-(define (install-bundle)
- (load-ffi-quietly)
- ((environment-lookup (->environment '(ffi)) 'install-bundle)))
-
(define (load-ffi-quietly)
(if (not (name->package '(FFI)))
- (with-notification
- (lambda (port) (write-string "Loading FFI option" port))
- (lambda ()
- (fluid-let ((load/suppress-loading-message? #t))
- (load-option 'ffi))))))
+ (let ((kernel (lambda ()
+ (fluid-let ((load/suppress-loading-message? #t))
+ (load-option 'FFI)))))
+ (if (nearest-cmdl/batch-mode?)
+ (kernel)
+ (with-notification (lambda (port)
+ (write-string "Loading FFI option" port))
+ kernel)))))
\f
(define calloutback-stack '())