Extend ENV to make tweaking the build environment easier
eg. ENV.libpng or ENV.deparallelize
This commit is contained in:
parent
4355182529
commit
5a396fd8b4
@ -14,7 +14,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
|
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
require 'osx/cocoa' # to get number of cores
|
require 'osx/cocoa' # to get number of cores
|
||||||
require 'formula'
|
require 'formula'
|
||||||
require 'hw.model'
|
require 'hw.model'
|
||||||
@ -57,12 +57,42 @@ ENV['CXX']='g++-4.2'
|
|||||||
ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
|
ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
|
||||||
|
|
||||||
|
|
||||||
unless HOMEBREW_PREFIX == '/usr/local'
|
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
||||||
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
||||||
ENV['LDFLAGS']="-L#{HOMEBREW_PREFIX}/lib"
|
ENV['LDFLAGS']="-L#{HOMEBREW_PREFIX}/lib"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# you can use these functions for packages that have build issues
|
||||||
|
module HomebrewEnvExtension
|
||||||
|
def deparallelize
|
||||||
|
remove 'MAKEFLAGS', /-j\d+/
|
||||||
|
end
|
||||||
|
def gcc_4_0_1
|
||||||
|
self['CC']=nil
|
||||||
|
self['CXX']=nil
|
||||||
|
end
|
||||||
|
def osx_10_4
|
||||||
|
self['MACOSX_DEPLOYMENT_TARGET']=nil
|
||||||
|
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
|
||||||
|
end
|
||||||
|
def generic_i386
|
||||||
|
%w[-mfpmath=sse -msse3 -mmmx -march=\w+].each {|s| remove_from_cflags s}
|
||||||
|
end
|
||||||
|
private
|
||||||
|
def remove key, rx
|
||||||
|
# sub! doesn't work as "the string is frozen"
|
||||||
|
self[key]=self[key].sub rx, ''
|
||||||
|
self[key]=nil if self[key].empty? # keep things clean
|
||||||
|
end
|
||||||
|
def remove_from_cflags rx
|
||||||
|
%w[CFLAGS CXXFLAGS].each {|key| remove key, rx}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ENV.extend HomebrewEnvExtension
|
||||||
|
|
||||||
|
|
||||||
def inreplace(path, before, after)
|
def inreplace(path, before, after)
|
||||||
before=Regexp.escape before.to_s
|
before=Regexp.escape before.to_s
|
||||||
after=Regexp.escape after.to_s
|
after=Regexp.escape after.to_s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user