Make flag lists into constants
This commit is contained in:
parent
7d6371cd19
commit
a458555ccb
@ -1,8 +1,10 @@
|
|||||||
require 'hardware'
|
require 'hardware'
|
||||||
|
|
||||||
module HomebrewEnvExtension
|
module HomebrewEnvExtension
|
||||||
# -w: keep signal to noise high
|
|
||||||
SAFE_CFLAGS_FLAGS = "-w -pipe"
|
SAFE_CFLAGS_FLAGS = "-w -pipe"
|
||||||
|
CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
|
||||||
|
FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
|
||||||
|
DEFAULT_FLAGS = '-march=core2 -msse4'
|
||||||
|
|
||||||
def setup_build_environment
|
def setup_build_environment
|
||||||
# Clear CDPATH to avoid make issues that depend on changing directories
|
# Clear CDPATH to avoid make issues that depend on changing directories
|
||||||
@ -303,21 +305,21 @@ module HomebrewEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def replace_in_cflags before, after
|
def replace_in_cflags before, after
|
||||||
cc_flag_vars.each do |key|
|
CC_FLAG_VARS.each do |key|
|
||||||
self[key] = self[key].sub before, after if self[key]
|
self[key] = self[key].sub before, after if self[key]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convenience method to set all C compiler flags in one shot.
|
# Convenience method to set all C compiler flags in one shot.
|
||||||
def set_cflags f
|
def set_cflags f
|
||||||
cc_flag_vars.each do |key|
|
CC_FLAG_VARS.each do |key|
|
||||||
self[key] = f
|
self[key] = f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets architecture-specific flags for every environment variable
|
# Sets architecture-specific flags for every environment variable
|
||||||
# given in the list `flags`.
|
# given in the list `flags`.
|
||||||
def set_cpu_flags flags, default='-march=core2 -msse4', map=Hardware::CPU.optimization_flags
|
def set_cpu_flags flags, default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
|
||||||
cflags =~ %r{(-Xarch_i386 )-march=}
|
cflags =~ %r{(-Xarch_i386 )-march=}
|
||||||
xarch = $1.to_s
|
xarch = $1.to_s
|
||||||
remove flags, %r{(-Xarch_i386 )?-march=\S*}
|
remove flags, %r{(-Xarch_i386 )?-march=\S*}
|
||||||
@ -337,8 +339,8 @@ module HomebrewEnvExtension
|
|||||||
remove flags, '-Qunused-arguments'
|
remove flags, '-Qunused-arguments'
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_cpu_cflags default='-march=core2 -msse4', map=Hardware::CPU.optimization_flags
|
def set_cpu_cflags default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
|
||||||
set_cpu_flags cc_flag_vars, default, map
|
set_cpu_flags CC_FLAG_VARS, default, map
|
||||||
end
|
end
|
||||||
|
|
||||||
# actually c-compiler, so cc would be a better name
|
# actually c-compiler, so cc would be a better name
|
||||||
@ -392,14 +394,11 @@ class << ENV
|
|||||||
end
|
end
|
||||||
removed
|
removed
|
||||||
end
|
end
|
||||||
def cc_flag_vars
|
|
||||||
%w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
|
|
||||||
end
|
|
||||||
def append_to_cflags newflags
|
def append_to_cflags newflags
|
||||||
append(cc_flag_vars, newflags)
|
append(CC_FLAG_VARS, newflags)
|
||||||
end
|
end
|
||||||
def remove_from_cflags f
|
def remove_from_cflags f
|
||||||
remove cc_flag_vars, f
|
remove CC_FLAG_VARS, f
|
||||||
end
|
end
|
||||||
def append keys, value, separator = ' '
|
def append keys, value, separator = ' '
|
||||||
value = value.to_s
|
value = value.to_s
|
||||||
@ -459,8 +458,6 @@ class << ENV
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
fc_flag_vars = %w{FCFLAGS FFLAGS}
|
|
||||||
|
|
||||||
# superenv removes these PATHs, but this option needs them
|
# superenv removes these PATHs, but this option needs them
|
||||||
# TODO fix better, probably by making a super-fc
|
# TODO fix better, probably by making a super-fc
|
||||||
ENV['PATH'] += ":#{HOMEBREW_PREFIX}/bin:/usr/local/bin"
|
ENV['PATH'] += ":#{HOMEBREW_PREFIX}/bin:/usr/local/bin"
|
||||||
@ -493,8 +490,8 @@ class << ENV
|
|||||||
self['FC'] = which 'gfortran'
|
self['FC'] = which 'gfortran'
|
||||||
self['F77'] = self['FC']
|
self['F77'] = self['FC']
|
||||||
|
|
||||||
fc_flag_vars.each {|key| self[key] = cflags}
|
FC_FLAG_VARS.each {|key| self[key] = cflags}
|
||||||
set_cpu_flags(fc_flag_vars)
|
set_cpu_flags(FC_FLAG_VARS)
|
||||||
else
|
else
|
||||||
onoe <<-EOS
|
onoe <<-EOS
|
||||||
This formula requires a fortran compiler, but we could not find one by
|
This formula requires a fortran compiler, but we could not find one by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user