diff options
| author | samueljohn | 2012-08-21 16:38:23 +0200 |
|---|---|---|
| committer | Jack Nagel | 2012-08-23 16:26:28 -0500 |
| commit | 17469d7ad648754462ee3348bae1e496c831a52f (patch) | |
| tree | 251b4e5dfd419bf83cbfbafe7333226d16ea977e | |
| parent | 0afd719bc9dd2045050ccf6c1abc78a3f2cd06f2 (diff) | |
| download | homebrew-17469d7ad648754462ee3348bae1e496c831a52f.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 #14351.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
| -rw-r--r-- | Library/Formula/pkg-config.rb | 15 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 32 |
2 files changed, 21 insertions, 26 deletions
diff --git a/Library/Formula/pkg-config.rb b/Library/Formula/pkg-config.rb index 5449007c0..8e47b2b00 100644 --- a/Library/Formula/pkg-config.rb +++ b/Library/Formula/pkg-config.rb @@ -21,10 +21,17 @@ class PkgConfig < Formula /usr/local/lib/pkgconfig /usr/lib/pkgconfig ].uniq - system "./configure", "--disable-debug", - "--prefix=#{prefix}", - "--with-pc-path=#{paths*':'}", - "--with-internal-glib" + + args = %W[ + --disable-debug + --prefix=#{prefix} + --with-pc-path=#{paths*':'} + --with-internal-glib + ] + args << "CC=#{ENV.cc} #{ENV.cflags}" unless MacOS::CLT.installed? + + system "./configure", *args + system "make" system "make check" system "make install" 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", ':' |
