1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 16:50:21 +02:00

* guile-config.in: Don't import ice-9 regex; that's not available

on all systems.  Maybe someday we'll have our own...
(set-program-name!): Use basename.
(build-link): Use basename and stock string functions, instead of
string-match.
This commit is contained in:
Jim Blandy 1998-10-03 20:58:41 +00:00
parent 7265de7033
commit da5099742d

View file

@ -10,8 +10,7 @@
;;; * Implement the static library support. This requires that ;;; * Implement the static library support. This requires that
;;; some portion of the module system be done. ;;; some portion of the module system be done.
(use-modules (ice-9 regex) (use-modules (ice-9 string-fun))
(ice-9 string-fun))
;;;; main function, command-line processing ;;;; main function, command-line processing
@ -38,11 +37,7 @@
;;; appropriate f or use in error messages (i.e., with leading ;;; appropriate f or use in error messages (i.e., with leading
;;; directory names stripped). ;;; directory names stripped).
(define (set-program-name! path) (define (set-program-name! path)
(set! program-name (set! program-name (basename path)))
(cond
((string-match "/([^/]+)$" path)
=> (lambda (match) (match:substring match 1)))
(else path))))
(define (show-help args) (define (show-help args)
(cond (cond
@ -82,6 +77,17 @@
(string-append program-name (string-append program-name
" link: arguments to subcommand not yet implemented"))) " link: arguments to subcommand not yet implemented")))
;; If PATH has the form FOO/libBAR.a, return the substring
;; BAR, otherwise return #f.
(define (match-lib path)
(let* ((base (basename path))
(len (string-length base)))
(if (and (> len 5)
(string=? (make-shared-substring base 0 3) "lib")
(string=? (make-shared-substring base (- len 2)) ".a"))
(make-shared-substring base 3 (- len 2))
#f)))
(let* ((flags (let* ((flags
(let loop ((libs (let loop ((libs
;; Get the string of linker flags we used to build ;; Get the string of linker flags we used to build
@ -89,13 +95,14 @@
(separate-fields-discarding-char #\space (separate-fields-discarding-char #\space
(get-build-info 'LIBS) (get-build-info 'LIBS)
list))) list)))
(cond (cond
((null? libs) '()) ((null? libs) '())
;; Turn any "FOO/libBAR.a" elements into "-lBAR". ;; Turn any "FOO/libBAR.a" elements into "-lBAR".
((string-match "^.*/lib([^./]+).a$" (car libs)) ((match-lib (car libs))
=> (lambda (match) => (lambda (bar)
(cons (string-append "-l" (match:substring match 1)) (cons (string-append "-l" bar)
(loop (cdr libs))))) (loop (cdr libs)))))
;; Remove any empty strings that may have seeped in there. ;; Remove any empty strings that may have seeped in there.