aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorsamueljohn2012-08-21 16:38:23 +0200
committerJack Nagel2012-08-23 16:26:28 -0500
commitad0dd3d3de9df04cea41dc82626f510397a46a21 (patch)
tree0579511b101de3ba93cab73da936e84589857c3e /Library
parent6400f41a7728de76ba864123f7f46a0b5bcf7ff4 (diff)
downloadbrew-ad0dd3d3de9df04cea41dc82626f510397a46a21.tar.bz2
Xcode-only: Clean up compiler flags. Use CPATH.
- When using CPATH, we only need -isysroot and not the other -I spam. - LDFLAGS use -isysroot instead of -L Turns out that the linker also understands the -isysroot flag which behaves more natural (in the sense: "like the internal defaults `/usr/lib` etc.) than adding `-L$(SDKROOT). Especially for duplicates, the linker first searches through all `-L` dirs and then looks at the sysroot or internal defaults. This is what we want. - Pkg-config needs CC with CFLAGS passed to configure. Closes Homebrew/homebrew#14351. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ENV.rb32
1 files changed, 10 insertions, 22 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index c8952b186..4c6c5fd47 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -238,19 +238,14 @@ Please take one of the following actions:
v = v.to_s
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
self['MACOSX_DEPLOYMENT_TARGET'] = nil
- remove 'CPPFLAGS', "-isystem #{HOMEBREW_PREFIX}/include"
+ self['CPATH'] = nil
remove 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
sdk = MacOS.sdk_path(v)
unless sdk.nil? or MacOS::CLT.installed?
self['SDKROOT'] = nil
- remove 'CPPFLAGS', "-isysroot #{sdk}"
- remove 'CPPFLAGS', "-isystem #{sdk}/usr/include"
- remove 'CPPFLAGS', "-I#{sdk}/usr/include"
- remove_from_cflags "-isystem #{sdk}/usr/include"
remove_from_cflags "-isysroot #{sdk}"
- remove_from_cflags "-I#{sdk}/usr/include"
- remove 'LDFLAGS', "-L#{sdk}/usr/lib"
- remove 'LDFLAGS', "-I#{sdk}/usr/include"
+ remove 'CPPFLAGS', "-isysroot #{sdk}"
+ remove 'LDFLAGS', "-isysroot #{sdk}"
if HOMEBREW_PREFIX.to_s == '/usr/local'
self['CMAKE_PREFIX_PATH'] = nil
else
@@ -268,26 +263,19 @@ Please take one of the following actions:
v = v.to_s
append_to_cflags("-mmacosx-version-min=#{v}")
self['MACOSX_DEPLOYMENT_TARGET'] = v
- append 'CPPFLAGS', "-isystem #{HOMEBREW_PREFIX}/include"
+ self['CPATH'] = "#{HOMEBREW_PREFIX}/include"
prepend 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
sdk = MacOS.sdk_path(v)
unless sdk.nil? or MacOS::CLT.installed?
# Extra setup to support Xcode 4.3+ without CLT.
self['SDKROOT'] = sdk
- # Teach the preprocessor and compiler (some don't respect CPPFLAGS)
- # where system includes are:
- append 'CPPFLAGS', "-isysroot #{sdk}"
+ # Tell clang/gcc where system include's are:
+ append 'CPATH', "#{sdk}/usr/include", ":"
+ # The -isysroot is needed, too, because of the Frameworks
append_to_cflags "-isysroot #{sdk}"
- append 'CPPFLAGS', "-isystem #{sdk}/usr/include"
- # Suggested by mxcl (https://github.com/mxcl/homebrew/pull/10510#issuecomment-4187996):
- append_to_cflags "-isystem #{sdk}/usr/include"
- # Some software needs this (e.g. python shows error: /usr/include/zlib.h: No such file or directory)
- append 'CPPFLAGS', "-I#{sdk}/usr/include"
- # And finally the "normal" things one expects for the CFLAGS and LDFLAGS:
- append_to_cflags "-I#{sdk}/usr/include"
- append 'LDFLAGS', "-L#{sdk}/usr/lib"
- # Believe it or not, sometimes only the LDFLAGS are used :/
- append 'LDFLAGS', "-I#{sdk}/usr/include"
+ append 'CPPFLAGS', "-isysroot #{sdk}"
+ # And the linker needs to find sdk/usr/lib
+ append 'LDFLAGS', "-isysroot #{sdk}"
# Needed to build cmake itself and perhaps some cmake projects:
append 'CMAKE_PREFIX_PATH', "#{sdk}/usr", ':'
append 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks", ':'