+(defpackage #:pkg-config
+ (:use #:common-lisp)
+ (:export #:pkg-cflags #:pkg-libs #:pkg-exists-p #:pkg-version
+ #:pkg-variable))
+
+(in-package #:pkg-config)
+
+(defparameter *pkg-config* "pkg-config")
+
+(defun split-string (string &key (start 0) (end (length string)))
+ (let ((position (position #\sp string :start start :end end)))
+ (cond
+ ((zerop (- end start)) nil)
+ ((not position) (list (subseq string start end)))
+ ((= position start) (split-string string :start (1+ start) :end end))
+ (t (cons
+ (subseq string start position)
+ (split-string string :start (1+ position) :end end))))))
+
+
+(defun read-lines (&optional (stream *standard-input*))
+ (let ((line (read-line stream nil)))
+ (when line
+ (cons line (read-lines stream)))))
+
+
+(defun read-string (&optional (stream *standard-input*)
+ (delimiter #\newline) (eof-error-p t) eof-value)
+ (let ((string (make-array 0 :element-type 'character
+ :fill-pointer t :adjustable t)))
+ ;; I really need to learn how to use the loop facility
+ (labels ((read-chars ()
+ (let ((char (read-char stream (and eof-error-p delimiter))))
+ (when char
+ (vector-push-extend char string)
+ (unless (eq char delimiter)
+ (read-chars))))))
+ (read-chars))
+ (cond
+ ((not (zerop (length string))) string)
+ ((not eof-error-p) eof-value)
+ ((error 'end-of-file :stream stream)))))
+
+
+(defun run-pkg-config (package error &rest options)