diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index b1d7eab120..e8c0c0ad3a 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -14,12 +14,12 @@ module HomebrewEnvExtension # it encounters files with mixed character sets delete('LC_ALL') self['LC_CTYPE']="C" - - # Mountain Lion no longer ships a few .pcs; make sure we pick up our versions - prepend 'PKG_CONFIG_PATH', - HOMEBREW_REPOSITORY/'Library/Homebrew/pkgconfig', ':' end + # Set the default pkg-config search path, overriding the built-in paths + # Anything in PKG_CONFIG_PATH is searched before paths in this variable + self['PKG_CONFIG_LIBDIR'] = determine_pkg_config_libdir + # make any aclocal stuff installed in Homebrew available self['ACLOCAL_PATH'] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS::Xcode.provides_autotools? @@ -66,6 +66,15 @@ module HomebrewEnvExtension end end + def determine_pkg_config_libdir + paths = [] + paths << HOMEBREW_PREFIX/'lib/pkgconfig' + paths << HOMEBREW_PREFIX/'share/pkgconfig' + paths << HOMEBREW_REPOSITORY/'Library/Homebrew/pkgconfig' if MacOS.version >= :mountain_lion + paths << '/usr/lib/pkgconfig' + paths.select { |d| File.directory? d }.join(':') + end + def deparallelize remove 'MAKEFLAGS', /-j\d+/ end @@ -249,10 +258,13 @@ module HomebrewEnvExtension def x11 # There are some config scripts here that should go in the PATH - prepend 'PATH', MacOS::X11.bin, ':' + append 'PATH', MacOS::X11.bin, ':' - prepend 'PKG_CONFIG_PATH', MacOS::X11.lib/'pkgconfig', ':' - prepend 'PKG_CONFIG_PATH', MacOS::X11.share/'pkgconfig', ':' + # Append these to PKG_CONFIG_LIBDIR so they are searched + # *after* our own pkgconfig directories, as we dupe some of the + # libs in XQuartz. + append 'PKG_CONFIG_LIBDIR', MacOS::X11.lib/'pkgconfig', ':' + append 'PKG_CONFIG_LIBDIR', MacOS::X11.share/'pkgconfig', ':' append 'LDFLAGS', "-L#{MacOS::X11.lib}" append 'CMAKE_PREFIX_PATH', MacOS::X11.prefix, ':'