From 5b40937554f46857cb750b331ce5d57ed29c943b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Oliveira?= Date: Fri, 28 Nov 2014 22:39:20 +0000 Subject: [PATCH] grovel: rename pkg-config to pkg-config-cflags Also, by default failure to execute pkg-config is fatal and it takes a single pkg rather than a list. --- doc/cffi-manual.texinfo | 21 ++++++++++++--------- grovel/grovel.lisp | 17 +++++++++-------- libffi/libffi-unix.lisp | 3 +-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/doc/cffi-manual.texinfo b/doc/cffi-manual.texinfo index 6a7936c13288..a036940a8c6f 100644 --- a/doc/cffi-manual.texinfo +++ b/doc/cffi-manual.texinfo @@ -6489,15 +6489,18 @@ Adds @var{cc-flags} to the command line arguments used for the C compiler invocation. @end deffn -@deffn {Grovel Form} pkg-flags &rest pkgs - -Adds @var{pkgs} to the command line arguments for the external program -pkg-config and runs it to retrieve the relevant include flags used for the -C compiler invocation. This syntax can be used instead of hard-coding -paths using @code{cc-flags}, and ensures that include flags are added -correctly on the build system. Assumes pkg-config is installed and working. -@var{pkgs} are strings that identify installed pkg-config packages. See -the pkg-config manual for more information. +@deffn {Grovel Form} pkg-config-cflags pkg &key optional + +Adds @var{pkg} to the command line arguments for the external program +@code{pkg-config} and runs it to retrieve the relevant include flags +used for the C compiler invocation. This syntax can be used instead of +hard-coding paths using @code{cc-flags}, and ensures that include +flags are added correctly on the build system. Assumes +@code{pkg-config} is installed and working. @var{pkg} is a string +that identifies an installed @code{pkg-config} package. See the +pkg-config manual for more information. If @var{optional} is true, +failure to execute @code{pkg-config} does @emph{not} abort +compilation. @end deffn @deffn {Grovel Form} cstruct lisp-name c-name slots diff --git a/grovel/grovel.lisp b/grovel/grovel.lisp index 43d7b6744f8f..7cce6f3f42d5 100644 --- a/grovel/grovel.lisp +++ b/grovel/grovel.lisp @@ -334,15 +334,16 @@ int main(int argc, char**argv) { (define-grovel-syntax cc-flags (&rest flags) (appendf *cc-flags* (trim-whitespace flags))) -(define-grovel-syntax pkg-flags (&rest pkgs) - (handler-case +(define-grovel-syntax pkg-config-cflags (pkg &key optional) + (block nil + (handler-bind + ((error (lambda (e) + (when optional + (format *debug-io* "~&ERROR: ~a" e) + (format *debug-io* "~&Attempting to continue anyway.~%") + (return))))) (appendf *cc-flags* - (trim-whitespace (mapcar #'(lambda (p) - (invoke "pkg-config" p "--cflags")) - (trim-whitespace pkgs)))) - (error (e) - (format *debug-io* "~&ERROR: ~a" e) - (format *debug-io* "~&Attempting to continue anyway.~%")))) + (trim-whitespace (list (invoke "pkg-config" pkg "--cflags"))))))) ;;; This form also has some "read time" effects. See GENERATE-C-FILE. (define-grovel-syntax in-package (name) diff --git a/libffi/libffi-unix.lisp b/libffi/libffi-unix.lisp index 76e2767bd1d8..ad93e825e8c3 100644 --- a/libffi/libffi-unix.lisp +++ b/libffi/libffi-unix.lisp @@ -38,8 +38,7 @@ #+openbsd (cc-flags "-I/usr/local/include") -#+linux -(pkg-flags "libffi") +(pkg-config-cflags "libffi" :optional t) #+darwin (include "ffi/ffi.h")