From 300d704ed5a29a886cd9155f17c8b7e08c8dff9c Mon Sep 17 00:00:00 2001 Message-Id: <300d704ed5a29a886cd9155f17c8b7e08c8dff9c.1715066378.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 29 Apr 2001 20:12:56 +0000 Subject: [PATCH] Added support for pkg-config Organization: Straylight/Edgeware From: espen --- tools/config.lisp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/config.lisp b/tools/config.lisp index fa335fa..0b776e0 100644 --- a/tools/config.lisp +++ b/tools/config.lisp @@ -1,16 +1,25 @@ -(defun configure-cflags (config-program) +(defparameter *pkg-config* "/usr/bin/pkg-config") + +(defun split-string (string &key (start 0) end) + (let ((position (position #\sp string :start start :end end))) + (if position + (cons + (subseq string start position) + (split-string string :start (1+ position) :end end)) + (list (subseq string start end))))) + +(defun run-pkg-config (package &rest options) (let ((process (run-program - config-program '("--cflags") :wait t :output :stream))) + *pkg-config* (cons package options) :wait t :output :stream))) (unless process - (error "Unable to run %A" config-program)) - (labels ((split (string) - (let ((position (position #\sp string))) - (if position - (cons - (subseq string 0 position) - (split (subseq string (1+ position)))) - (list string))))) + (error "Unable to run ~A" *pkg-config*)) + (unless (zerop (process-exit-code process)) + (error "~A: ~A" *pkg-config* (read-line (process-output process)))) (prog1 - (split (read-line (process-output process))) - (process-close process))))) + (delete-if #'(lambda (str) (string= str "")) (split-string (read-line (process-output process)))) + (process-close process)))) + + +(defun pkg-cflags (package) + (run-pkg-config package "--cflags")) -- [mdw]