brew/Library/Homebrew/brewkit.rb

54 lines
2.1 KiB
Ruby
Raw Normal View History

# Copyright 2009 Max Howell <max@methylblue.com>
#
# This file is part of Homebrew.
#
# Homebrew is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Homebrew is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
require 'osx/cocoa' # to get number of cores
require 'formula'
2009-05-22 00:14:57 +01:00
# optimise all the way to eleven, references:
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
# http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
# http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/i386-and-x86_002d64-Options.html
2009-05-21 01:28:11 +01:00
ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w -pipe -fomit-frame-pointer -march=prescott -mmacosx-version-min=10.5'
2009-05-22 00:14:57 +01:00
# lets use gcc 4.2, it is newer and "better", at least I believe so, mail me
# if I'm wrong
ENV['CC']='gcc-4.2'
ENV['CXX']='g++-4.2'
ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
2009-05-22 00:14:57 +01:00
unless $root.to_s == '/usr/local'
ENV['CPPFLAGS']='-I'+$root+'include'
ENV['LDFLAGS']='-L'+$root+'lib'
end
2009-05-21 01:28:11 +01:00
######################################################################## utils
2009-05-21 00:04:43 +01:00
def inreplace(path, before, after)
2009-05-22 14:02:11 +01:00
before=before.to_s.gsub('"', '\"').gsub('/', '\/')
after=after.to_s.gsub('"', '\"').gsub('/', '\/')
2009-05-22 00:15:28 +01:00
2009-05-21 00:04:43 +01:00
# we're not using Ruby because the perl script is more concise
2009-05-22 00:15:28 +01:00
#TODO the above escapes are worse, use a proper ruby script :P
#TODO optimise it by taking before and after as arrays
#Bah, just make the script writers do it themselves with a standard collect block
2009-05-22 14:02:11 +01:00
#TODO use ed -- less to escape
#TODO the above doesn't escape all regexp symbols!
2009-05-22 14:02:11 +01:00
`perl -pi -e "s/#{before}/#{after}/g" "#{path}"`
2009-05-21 00:04:43 +01:00
end