X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/4539aedf46acf09af752d7c7a36a0de0ae5ca4be..9a25addd456ffad4b4354302c715a1207d9e3238:/tools/config.lisp diff --git a/tools/config.lisp b/tools/config.lisp index 1623a57..acf9943 100644 --- a/tools/config.lisp +++ b/tools/config.lisp @@ -1,4 +1,11 @@ -(defparameter *pkg-config* "pkg-config") +(defpackage #:pkg-config + (: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* "/usr/bin/pkg-config") (defun split-string (string &key (start 0) (end (length string))) (let ((position (position #\sp string :start start :end end))) @@ -35,6 +42,7 @@ (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 (run-program @@ -52,10 +60,19 @@ (defun run-pkg-config (package error &rest options) (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")))) +(defun pkg-libs (package) + (split-string (first (run-pkg-config package t "--libs")))) + (defun pkg-exists-p (package &key version atleast-version max-version ( error t))