aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-08-10 16:48:21 +0100
committerMax Howell2009-08-10 16:48:21 +0100
commit6442e457412d1ea263bc6db49dc6dadb2bda5778 (patch)
tree6636c60408e9565401aee42c74b62e86119b83bd
parent6c344eef72b23429566ad8c506b1167fe9ff36bf (diff)
downloadhomebrew-6442e457412d1ea263bc6db49dc6dadb2bda5778.tar.bz2
Extend ENV to make tweaking the build environment easier
eg. ENV.libpng or ENV.deparallelize
-rw-r--r--Library/Homebrew/brewkit.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index efd55913e..bddc2cca6 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -14,7 +14,7 @@
#
# 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'
require 'hw.model'
@@ -57,12 +57,42 @@ ENV['CXX']='g++-4.2'
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['LDFLAGS']="-L#{HOMEBREW_PREFIX}/lib"
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)
before=Regexp.escape before.to_s
after=Regexp.escape after.to_s