chiark / gitweb /
A lot of binding changes
[clg] / tools / config.lisp
1 (defparameter *pkg-config* "/usr/bin/pkg-config")
2
3 (defun split-string (string &key (start 0) end)
4   (let ((position (position #\sp string :start start :end end)))
5     (if position
6         (cons
7          (subseq string start position)
8          (split-string string :start (1+ position) :end end))
9       (list (subseq string start end)))))
10
11 (defun run-pkg-config (package &rest options)
12   (let ((process
13          (run-program
14           *pkg-config* (cons package options) :wait t :output :stream)))
15     (unless process
16       (error "Unable to run ~A" *pkg-config*))
17     (unless (zerop (process-exit-code process))
18       (error "~A: ~A" *pkg-config* (read-line (process-output process))))
19     (prog1
20         (delete-if #'(lambda (str) (string= str "")) (split-string (read-line (process-output process))))
21       (process-close process))))
22
23
24 (defun pkg-cflags (package)
25   (run-pkg-config package "--cflags"))