anchor.diff:  (defpackage #:pkg-config
  -  (:use #:common-lisp #+cmu #:ext #+sbcl #:sb-ext)
  -  (:export #:pkg-cflags #:pkg-libs #:pkg-exists-p #:pkg-version 
  -	   #:pkg-variable))
  +  (:use #:common-lisp #:clg-utils #+(or cmu clisp) #:ext #+sbcl #:sb-ext)
  +  #+sbcl
  +  (:import-from #:sb-int #:featurep)
  +  (:export #:pkg-cflags #:pkg-libs #:pkg-exists-p #:pkg-version #:pkg-variable)
  +  (:export #:featurep #:sbcl>=))
   
   (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)))
  -    (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)))))
  -
   
   #+(or sbcl cmu)
  -(defun run-pkg-config (package error &rest options)
  +(defun run-pkg-config (package error-p &rest options)
     (let ((process
   	 (run-program
   	  *pkg-config* (cons package options) :wait t :output :stream)))
       (unless process
         (error "Unable to run ~A" *pkg-config*))
       (let ((exit-code (process-exit-code process)))
  -      (unless (or (not error) (zerop exit-code))
  +      (unless (or (not error-p) (zerop exit-code))
   	(error
   	 (or
  -	  (read-string (process-error process) nil)
  +	  (format nil "~A: ~{~A~%~}" *pkg-config* (read-lines (process-error process)))
   	  (format nil "~A terminated with exit code ~A"
   		  *pkg-config* exit-code))))
         (let ((output (read-lines (process-output process))))	  
  
positive.code: 	(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"))))
  
negative.code: 
  (defun pkg-variable (package variable)
    (first (run-pkg-config package t "--variable" variable)))
  
  
  (defun |#?-reader| (stream subchar arg)
    (declare (ignore subchar arg))
    (let ((not-p (when (char= (peek-char nil stream) #\-)
  		 (read-char stream)))
  	(conditional (read stream t nil t)))
      (cond
       (*read-suppress* (read stream t nil t))
       ((not *read-eval*)
        (error 'reader-error 
         :format-control "Attempt to read #? while *READ-EVAL* is bound to NIL."
         :format-arguments nil :stream stream))
       ((if not-p
  	  (eval conditional)
  	(not (eval conditional)))
        (let ((*read-suppress* t))
  	(read stream t nil t)))))
    (values))
  
  (set-dispatch-macro-character #\# #\? #'|#?-reader|)
  
  
  #+sbcl
  (progn
    (defun sbcl-version ()
      (let ((dot1 (position #\. (lisp-implementation-version)))
  	  (dot2 (position #\. (lisp-implementation-version) :from-end t)))
        (values 
         (parse-integer (lisp-implementation-version) :end dot1)
         (parse-integer (lisp-implementation-version) :start (1+ dot1) :end dot2)
         (parse-integer (lisp-implementation-version) :start (1+ dot2)))))
    (defun sbcl>= (req-major req-minor req-micro)
      (multiple-value-bind (major minor micro) (sbcl-version)      
        (or 
         (> major req-major)
         (and (= major req-major) (> minor req-minor))
         (and (= major req-major) (= minor req-minor) (>= micro req-micro))))))
  
  #-sbcl
  (defun sbcl>= (req-major req-minor req-micro)
    (declare (ignore req-major req-minor req-micro))
    nil)
  