Skip to content

Commit

Permalink
Respect CFLAGS env var and support MacPorts and BSD include directories
Browse files Browse the repository at this point in the history
Users should be able to pass custom compilation flags such as include
directories via CFLAGS env var.

It would be convenient for MacPorts users if libraries installed in /opt/local
worked by default. (/opt/local/lib is supported since cffi#139.)

/usr/local/include/ was added for OpenBSD because cffi finds it useful in
cc07246

Fixes orivej/pzmq#18
  • Loading branch information
orivej committed Jul 19, 2019
1 parent 8683656 commit 2af32a1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions toolchain/c-toolchain.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,8 @@
*cc-flags*
(append
arch-flags
;; For MacPorts
#+darwin (list "-I" "/opt/local/include/")
;; ECL internal flags
#+ecl (parse-command-flags c::*cc-flags*)
;; FreeBSD non-base header files
#+freebsd (list "-I" "/usr/local/include/")
(split-cflags (getenv "CFLAGS")))
#+ecl (parse-command-flags c::*cc-flags*))
*ld* *cc*
*ld-exe-flags* `(,@arch-flags #-darwin "-Wl,--export-dynamic")
*ld-dll-flags* (list* #+darwin "-dynamiclib" ;; -bundle ?
Expand All @@ -223,12 +218,23 @@
*linkkit-start* nil
*linkkit-end* nil)))

(defun common-toolchain-parameters ()
(setf *cc-flags*
(append
*cc-flags*
;; For MacPorts
#+darwin (list "-I" "/opt/local/include/")
(split-cflags (getenv "CFLAGS"))
;; FreeBSD non-base header files
#+(or freebsd openbsd) (list "-I" "/usr/local/include/"))))

(defun ensure-toolchain-parameters ()
#+clisp (unless *cc* (clisp-toolchain-parameters))
#+ecl (unless *cc* (ecl-toolchain-parameters))
#+mkcl (unless *cc* (mkcl-toolchain-parameters))
#+sbcl (unless *cc* (sbcl-toolchain-parameters))
(unless *cc* (default-toolchain-parameters)))
(unless *cc* (default-toolchain-parameters))
(common-toolchain-parameters))

;; Actually initialize toolchain parameters
(ignore-errors (ensure-toolchain-parameters))
Expand Down

0 comments on commit 2af32a1

Please sign in to comment.