X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/d3768217596409b897466cb21697cc087147d4a0..9a25addd456ffad4b4354302c715a1207d9e3238:/tools/config.lisp diff --git a/tools/config.lisp b/tools/config.lisp index 0ec9a70..acf9943 100644 --- a/tools/config.lisp +++ b/tools/config.lisp @@ -1,11 +1,11 @@ (defpackage #:pkg-config - (:use #:common-lisp) + (:use #:common-lisp #+cmu #:ext #+sbcl #:sb-ext) (:export #:pkg-cflags #:pkg-libs #:pkg-exists-p #:pkg-version #:pkg-variable)) (in-package #:pkg-config) -(defparameter *pkg-config* "pkg-config") +(defparameter *pkg-config* "/usr/bin/pkg-config") (defun split-string (string &key (start 0) (end (length string))) (let ((position (position #\sp string :start start :end end))) @@ -42,23 +42,30 @@ (defun read-string (&optional (stream *standard-input*) ((error 'end-of-file :stream stream))))) +#+(or sbcl cmu) (defun run-pkg-config (package error &rest options) (let ((process - (ext:run-program + (run-program *pkg-config* (cons package options) :wait t :output :stream))) (unless process (error "Unable to run ~A" *pkg-config*)) - (let ((exit-code (ext:process-exit-code process))) + (let ((exit-code (process-exit-code process))) (unless (or (not error) (zerop exit-code)) (error (or - (read-string (ext:process-error process) nil) + (read-string (process-error process) nil) (format nil "~A terminated with exit code ~A" *pkg-config* exit-code)))) - (let ((output (read-lines (ext:process-output process)))) - (ext:process-close process) + (let ((output (read-lines (process-output process)))) + (process-close process) (values output exit-code))))) +#+clisp +;; I haven't figured out how to do error checking with CLISP's run-program +(defun run-pkg-config (package error &rest options) + (declare (ignore error)) + (let ((stream (ext:run-program *pkg-config* :arguments (cons package options) :output :stream))) + (read-lines stream))) (defun pkg-cflags (package) (split-string (first (run-pkg-config package t "--cflags"))))