diff --git a/lib/chibi/snow/commands.scm b/lib/chibi/snow/commands.scm index e5af46b2..000b0407 100644 --- a/lib/chibi/snow/commands.scm +++ b/lib/chibi/snow/commands.scm @@ -1781,21 +1781,36 @@ (else ".so")))) (so-flags (cond-expand (macosx '("-dynamiclib" "-Oz")) (else '("-fPIC" "-shared" "-Os")))) - (cc-cmd (append cc cflags so-flags - (if local-test? '("-Iinclude" "-L.") '()) - `("-o" ,so-file ,c-file "-lchibi-scheme")))) - (and (or (file-exists? c-file) - (and (file-exists? stub-file) - (or (and (system? (append chibi-ffi (list stub-file))) - (file-exists? c-file)) - (yes-or-no? cfg "couldn't generate c from stub: " - stub-file " - install anyway?"))) - (yes-or-no? cfg "can't find ffi stub or c source for: " - base " - install anyway?")) - (or (system? cc-cmd) - (yes-or-no? cfg "couldn't compile chibi ffi c code: " - c-file " - install anyway?")) - (lp (cdr ls)))))))) + (lib-flags + (map (lambda (lib) (string-append "-l" lib)) + (library-foreign-dependencies impl cfg library))) + (ffi-cmd + `(,@chibi-ffi + "-c" "-cc" ,(car cc) + "-f" ,(string-join cflags " ") + "-f" ,(string-join lib-flags " ") + ,@(if local-test? '("-f" "-Iinclude -L.") '()) + ,@(if (pair? (cdr cc)) + (list "-f" (string-join (cdr cc) " ")) + '()) + ,stub-file)) + (cc-cmd + `(,@cc ,@cflags ,@so-flags + ,@(if local-test? '("-Iinclude" "-L.") '()) + "-o" ,so-file ,c-file "-lchibi-scheme" + ,@lib-flags))) + (when (or (and (file-exists? c-file) + (or (system? cc-cmd) + (yes-or-no? + cfg "couldn't compile chibi ffi c code: " + c-file " - install anyway?"))) + (and (file-exists? stub-file) + (or (system? ffi-cmd) + (yes-or-no? cfg "couldn't compile stub: " + stub-file " - install anyway?"))) + (yes-or-no? cfg "can't find ffi stub or c source for: " + base " - install anyway?")) + (lp (cdr ls)))))))) (define (chicken-builder impl cfg library dir) (let* ((library-file (make-path dir (get-library-file cfg library))) diff --git a/lib/chibi/snow/package.scm b/lib/chibi/snow/package.scm index eb42781d..52f837d8 100644 --- a/lib/chibi/snow/package.scm +++ b/lib/chibi/snow/package.scm @@ -394,6 +394,11 @@ (lambda (x) (or (and (pair? x) (eq? 'depends (car x)) (cdr x)) '())) (cdr (library-for-impl impl cfg lib)))) +(define (library-foreign-dependencies impl cfg lib) + (append-map + (lambda (x) (or (and (pair? x) (eq? 'foreign-depends (car x)) (cdr x)) '())) + (cdr (library-for-impl impl cfg lib)))) + (define (parse-library-name str) (cond ((pair? str) str) diff --git a/lib/chibi/snow/package.sld b/lib/chibi/snow/package.sld index 2fcb3c00..38ad66f7 100644 --- a/lib/chibi/snow/package.sld +++ b/lib/chibi/snow/package.sld @@ -14,7 +14,7 @@ library-name->path library->path get-library-file find-library-file library-url library-name parse-library-name library-name->path library-analyze library-include-files library-dependencies - library-shared-include-files + library-shared-include-files library-foreign-dependencies library-rewrite-includes library-file-name get-program-file program-name program-install-name invalid-package-reason valid-package?