2012-08-30 09:55:33 -04:00
|
|
|
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
|
2012-09-03 11:56:29 -04:00
|
|
|
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
#TODO make it work with homebrew/dupes/gcc
|
|
|
|
#TODO? If we find -mmacosx-version-min=10.8, change sdkroot? warn visibly if no such SDK?
|
|
|
|
#TODO fix pkg-config files, should point to /usr/local or /usr/local/opt
|
|
|
|
#TODO create mechanism to specify build effects like %w{-O0 -O4 vanilla-arg-parsing sdk=10.6} etc.
|
|
|
|
|
|
|
|
require "#{File.dirname __FILE__}/../libsuperenv"
|
|
|
|
require 'set'
|
|
|
|
|
|
|
|
def cccfg? flags
|
|
|
|
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
|
|
|
end
|
|
|
|
def nclt?
|
|
|
|
$sdkroot != nil
|
|
|
|
end
|
2012-09-03 14:34:42 -04:00
|
|
|
def syspath
|
|
|
|
if nclt?
|
|
|
|
%W{#$sdkroot/usr #$sdkroot/usr/local}
|
|
|
|
else
|
|
|
|
%W{/usr /usr/local}
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
end
|
2012-09-29 09:57:37 -04:00
|
|
|
|
2013-03-03 22:28:12 -06:00
|
|
|
module ExecLogExtension
|
|
|
|
def exec *args
|
|
|
|
path = File.expand_path('~/Library/Logs/Homebrew/cc.log')
|
|
|
|
open(path, 'a') do |f|
|
|
|
|
f.print '[', $0
|
|
|
|
f.print " -%s" % ENV['HOMEBREW_CCCFG'] if ENV['HOMEBREW_CCCFG']
|
|
|
|
f.print '] '
|
|
|
|
f.puts args.join(' ')
|
|
|
|
f.puts
|
|
|
|
end
|
|
|
|
Kernel.exec *args
|
|
|
|
end
|
|
|
|
end
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
|
|
|
|
class Cmd
|
|
|
|
def initialize path, args
|
2012-08-31 09:18:05 -04:00
|
|
|
@arg0 = path.basename.freeze
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
@args = args.freeze
|
|
|
|
end
|
|
|
|
def mode
|
2012-08-31 09:18:05 -04:00
|
|
|
if @arg0 == 'cpp' or @arg0 == 'ld'
|
|
|
|
@arg0.to_sym
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
elsif @args.include? '-c'
|
2013-10-07 00:40:32 -07:00
|
|
|
if @arg0 =~ /(?:c|g|clang)\+\+/
|
|
|
|
:cxx
|
|
|
|
else
|
|
|
|
:cc
|
|
|
|
end
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
elsif @args.include? '-E'
|
2013-08-31 10:43:23 -05:00
|
|
|
:ccE
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
else
|
2013-10-07 00:40:32 -07:00
|
|
|
if @arg0 =~ /(?:c|g|clang)\+\+/
|
|
|
|
:cxxld
|
|
|
|
else
|
|
|
|
:ccld
|
|
|
|
end
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def tool
|
2012-09-03 11:56:29 -04:00
|
|
|
@tool ||= case @arg0
|
|
|
|
when 'ld' then 'ld'
|
2013-08-27 18:31:57 -07:00
|
|
|
when 'cpp' then 'cpp'
|
2013-10-16 17:53:01 -07:00
|
|
|
when /\w\+\+$/
|
2013-05-27 12:54:07 -05:00
|
|
|
case ENV['HOMEBREW_CC']
|
|
|
|
when /clang/
|
|
|
|
'clang++'
|
|
|
|
when /llvm-gcc/
|
2013-06-27 14:56:47 -05:00
|
|
|
'llvm-g++-4.2'
|
2013-06-04 10:18:14 -05:00
|
|
|
when /gcc(-\d\.\d)?$/
|
|
|
|
'g++' + $1.to_s
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
else
|
2013-10-16 17:53:01 -07:00
|
|
|
# Note that this is a universal fallback, so that we'll always invoke
|
|
|
|
# HOMEBREW_CC regardless of what name under which the tool was invoked.
|
|
|
|
ENV['HOMEBREW_CC']
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def args
|
2012-09-03 11:56:29 -04:00
|
|
|
args = if not cccfg? 'O' or tool == 'ld'
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
@args.dup
|
2012-08-31 09:18:05 -04:00
|
|
|
else
|
|
|
|
refurbished_args
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
2012-08-31 09:18:05 -04:00
|
|
|
if tool != 'ld'
|
2012-09-14 11:55:21 -04:00
|
|
|
args << "--sysroot=#$sdkroot"
|
2012-08-30 10:03:26 -04:00
|
|
|
else
|
2012-09-14 11:55:21 -04:00
|
|
|
args << "-syslibroot" << $sdkroot
|
2012-08-30 10:03:26 -04:00
|
|
|
end if nclt?
|
2013-10-12 05:23:06 -07:00
|
|
|
allflags = case mode
|
2013-10-07 00:40:32 -07:00
|
|
|
when :ccld, :cxxld
|
2013-08-31 10:38:18 -05:00
|
|
|
cflags + args + cppflags + ldflags
|
2013-10-07 00:40:32 -07:00
|
|
|
when :cc, :cxx
|
2013-08-31 10:38:18 -05:00
|
|
|
cflags + args + cppflags
|
2013-08-31 10:43:23 -05:00
|
|
|
when :ccE
|
2013-08-31 11:14:38 -05:00
|
|
|
args + cppflags
|
2013-08-31 10:43:23 -05:00
|
|
|
when :cpp
|
|
|
|
args + cppflags
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when :ld
|
|
|
|
ldflags + args
|
|
|
|
end.compact
|
2013-11-02 00:42:51 -05:00
|
|
|
make_fuss(allflags) if verbose? and cccfg? 'O'
|
2013-10-12 05:23:06 -07:00
|
|
|
allflags
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
def refurbished_args
|
2012-09-14 11:55:21 -04:00
|
|
|
lset = Set.new(libpath + syslibpath)
|
|
|
|
iset = Set.new(cpath.flatten)
|
2012-09-03 14:34:42 -04:00
|
|
|
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
args = []
|
|
|
|
whittler = @args.each
|
|
|
|
loop do
|
|
|
|
case arg = whittler.next
|
|
|
|
when '-arch', /^-Xarch_/
|
|
|
|
whittler.next
|
2012-12-01 19:42:22 +01:00
|
|
|
when '-m32'
|
|
|
|
# If ENV.m32 was set, we allow the "-m32" flag, but we don't add anything
|
|
|
|
args << '-m32' if cccfg? '3'
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when /^-g\d?/, /^-gstabs\d+/, '-gstabs+', /^-ggdb\d?/, '-gdwarf-2',
|
2013-08-28 20:01:58 -07:00
|
|
|
/^-march=.+/, /^-mtune=.+/, /^-mcpu=.+/, '-m64',
|
2012-10-31 06:50:50 -07:00
|
|
|
/^-O[0-9zs]?$/, '-fast',
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
'-pedantic', '-pedantic-errors'
|
2012-09-02 11:44:23 -04:00
|
|
|
when '-fopenmp', '-lgomp'
|
|
|
|
# clang doesn't support OpenMP
|
|
|
|
args << arg if not tool =~ /^clang/
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when /^-W.*/
|
2013-01-22 23:52:20 -06:00
|
|
|
args << arg if arg =~ /^-W[alp],/
|
2012-08-29 22:37:57 -04:00
|
|
|
when '-macosx_version_min', '-dylib_install_name'
|
|
|
|
args << "-Wl,#{arg},#{whittler.next}"
|
2012-12-14 19:03:12 +01:00
|
|
|
when /^-isysroot/
|
|
|
|
# We set the sysroot
|
|
|
|
whittler.next
|
2012-08-29 22:37:57 -04:00
|
|
|
when '-dylib'
|
|
|
|
args << "-Wl,#{arg}"
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when /^-I(.+)/
|
|
|
|
# it is okay to add a space after the -I; so let's support it
|
|
|
|
path = $1.chuzzle || whittler.next
|
|
|
|
args << "-I#{path}" if iset.add?(path.cleanpath)
|
2012-09-03 14:34:42 -04:00
|
|
|
when /^-L(.+)/
|
|
|
|
path = $1.chuzzle || whittler.next
|
2012-10-31 02:44:18 -07:00
|
|
|
doit = case path.cleanpath
|
|
|
|
when %r{^#$brewfix}
|
|
|
|
# maybe homebrew is installed to /sw or /opt/brew
|
|
|
|
true
|
2012-09-03 14:34:42 -04:00
|
|
|
when %r{^/opt}, %r{^/sw}, %r{/usr/X11}
|
2012-10-31 02:44:18 -07:00
|
|
|
false
|
2012-09-03 14:34:42 -04:00
|
|
|
else
|
2012-10-31 02:44:18 -07:00
|
|
|
true
|
2012-09-03 14:34:42 -04:00
|
|
|
end
|
2012-10-31 02:44:18 -07:00
|
|
|
args << "-L#{path}" if doit and lset.add?(path.cleanpath)
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
else
|
|
|
|
args << arg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
args
|
|
|
|
end
|
|
|
|
def cflags
|
2013-10-07 00:40:32 -07:00
|
|
|
args = []
|
|
|
|
if mode == :cxx
|
|
|
|
args << '-std=c++11' if cccfg? 'x'
|
|
|
|
args << '-stdlib=libc++' if cccfg? 'g'
|
2013-10-24 00:26:09 -07:00
|
|
|
args << '-stdlib=libstdc++' if cccfg? 'h'
|
2013-10-07 00:40:32 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
return args unless cccfg? 'O'
|
2013-05-11 12:18:25 +01:00
|
|
|
|
2013-10-07 00:40:32 -07:00
|
|
|
args << '-pipe' << '-w' << '-Os'
|
2013-05-11 12:18:25 +01:00
|
|
|
|
|
|
|
# When bottling use the oldest supported CPU type.
|
2013-08-25 14:14:53 -07:00
|
|
|
if cccfg? 'bc'
|
|
|
|
# Custom bottle specified during the build
|
|
|
|
args << ENV['HOMEBREW_ARCHFLAGS']
|
|
|
|
elsif cccfg? 'bi6'
|
2013-05-11 12:18:25 +01:00
|
|
|
args << '-march=core2'
|
|
|
|
elsif cccfg? 'bi'
|
|
|
|
args << '-march=prescott'
|
2013-08-25 14:29:55 -07:00
|
|
|
elsif cccfg? 'bpA'
|
|
|
|
args << '-mcpu=7400'
|
|
|
|
elsif cccfg? 'bp'
|
|
|
|
args << '-mcpu=750'
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
else
|
2013-05-11 12:18:25 +01:00
|
|
|
args << '-march=native' if tool =~ /clang/
|
2012-09-13 11:28:06 -04:00
|
|
|
end
|
2013-05-11 12:18:25 +01:00
|
|
|
|
2013-08-16 20:46:02 -05:00
|
|
|
ENV['HOMEBREW_ARCHS'].split(',').each { |a| args << "-arch" << a } if cccfg? 'u'
|
2013-05-11 12:18:25 +01:00
|
|
|
args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/
|
|
|
|
args
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
2012-09-03 14:34:42 -04:00
|
|
|
def syslibpath
|
|
|
|
# We reject brew's lib as we explicitly add this as a -L flag, thus it
|
|
|
|
# is given higher priority by cc, so it surpasses the system libpath.
|
|
|
|
# NOTE this only counts if Homebrew is installed at /usr/local
|
2013-08-29 19:03:35 -05:00
|
|
|
syspath.map{|d| "#{d}/lib" }.reject{|d| d == "#$brewfix/lib" }
|
2012-09-03 14:34:42 -04:00
|
|
|
end
|
|
|
|
def syscpath
|
|
|
|
isystem, _ = cpath
|
|
|
|
isystem + syspath.map{|d| "#{d}/include" }
|
|
|
|
end
|
|
|
|
def cpath
|
|
|
|
cpath = ENV['CMAKE_PREFIX_PATH'].split(':').map{|d| "#{d}/include" } + ENV['CMAKE_INCLUDE_PATH'].split(':')
|
|
|
|
opt = cpath.select{|prefix| prefix =~ %r{^#$brewfix/opt} }
|
|
|
|
sys = cpath - opt
|
|
|
|
[sys, opt]
|
|
|
|
end
|
|
|
|
def libpath
|
|
|
|
ENV['CMAKE_PREFIX_PATH'].split(':').map{|d| "#{d}/lib" } +
|
|
|
|
ENV['CMAKE_LIBRARY_PATH'].split(':') -
|
|
|
|
syslibpath
|
|
|
|
end
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
def ldflags
|
2013-08-23 11:36:03 -05:00
|
|
|
args = libpath.to_flags('-L')
|
|
|
|
case mode
|
|
|
|
when :ld then args << '-headerpad_max_install_names'
|
|
|
|
when :ccld then args << '-Wl,-headerpad_max_install_names'
|
2013-10-07 00:40:32 -07:00
|
|
|
when :cxxld
|
|
|
|
args << '-Wl,-headerpad_max_install_names'
|
|
|
|
args << '-stdlib=libc++' if cccfg? 'g'
|
2013-10-24 00:26:09 -07:00
|
|
|
args << '-stdlib=libstdc++' if cccfg? 'h'
|
2013-08-23 11:36:03 -05:00
|
|
|
end
|
|
|
|
args
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
def cppflags
|
2012-09-03 14:34:42 -04:00
|
|
|
sys, opt = cpath
|
|
|
|
# we want our keg-only includes to be found before system includes *and*
|
|
|
|
# before any other includes the build-system adds
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
sys.to_flags('-isystem') + opt.to_flags('-I')
|
|
|
|
end
|
2012-08-30 10:03:26 -04:00
|
|
|
def make_fuss args
|
|
|
|
dels = @args - args
|
2012-08-31 12:06:20 -04:00
|
|
|
adds = args - @args
|
2012-09-13 11:28:06 -04:00
|
|
|
dups = dels & args
|
2012-09-11 20:59:59 -04:00
|
|
|
|
Move superenv make_fuss output back to stderr
In 6e3a585607116d06f47aac2ff5a649f2898216f0 ("Improve superenv
add/remove message."), more debugging information was added to the
"make_fuss" output generated by the superenv compiler
wrapper.
This resulted in some breakage in configure scripts that inspect stderr,
so in e1bd9b9e980c433878e60833f09964b8ca996657 ("Don't use stderr for
make_fuss output."), the output was moved to stdout. This only appeared
to solve the problem, since stdout is buffered but stderr is not.
Later, in fb749e47509b77b5bd89e7b14f0a1097d4af7f40, Homebrew started
generating logs even in verbose mode. This had the side effect of moving
stdout/stderr from a TTY to a pipe, and thus stdout was no longer
line-buffered.
Since it was not line-buffered, and Ruby's internal buffers were not
flushed, the debug output was being lost. This was addressed in
2d5724af8613c820b8c14f4171fe1de6a17f10c3 ("cc: ensure wrapper output is
always flushed").
This caused stdout to be flushed during configure, which resurfaced the
original bug that prompted e1bd9b9e980c433878e60833f09964b8ca996657.
This was fixed by disabling the debug output during configure, in
f1779837a46a58520560fba3850a0e2992284d0a.
Since the original bug has been addressed in a more robust way, we can
move the debug output back to stderr.
Fixes Homebrew/homebrew#23923.
2013-11-03 19:58:29 -06:00
|
|
|
STDERR.puts "brew: superenv removed: #{dels*' '}" unless dels.empty?
|
|
|
|
STDERR.puts "brew: superenv deduped: #{dups}" unless dups.empty?
|
|
|
|
STDERR.puts "brew: superenv added: #{adds*' '}" unless adds.empty?
|
2012-08-30 10:03:26 -04:00
|
|
|
end
|
2013-10-12 05:23:06 -07:00
|
|
|
def verbose?
|
|
|
|
!ENV['VERBOSE'].nil? || !ENV['HOMEBREW_VERBOSE'].nil?
|
|
|
|
end
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
|
2013-03-03 22:11:26 -06:00
|
|
|
if __FILE__ == $PROGRAM_NAME
|
2013-11-01 23:14:59 -05:00
|
|
|
STDOUT.sync = STDERR.sync = true
|
|
|
|
|
2013-03-03 22:11:26 -06:00
|
|
|
##################################################################### sanity
|
|
|
|
abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
|
2013-03-03 22:11:26 -06:00
|
|
|
case ENV['HOMEBREW_CC'].chuzzle when 'cc', nil
|
|
|
|
# those values are not allowed
|
|
|
|
ENV['HOMEBREW_CC'] = 'clang'
|
|
|
|
end
|
2012-09-03 11:56:29 -04:00
|
|
|
|
2013-03-03 22:11:26 -06:00
|
|
|
####################################################################### main
|
2013-03-03 22:28:12 -06:00
|
|
|
extend(ExecLogExtension) if ENV['HOMEBREW_LOG']
|
2013-03-03 22:11:26 -06:00
|
|
|
cmd = Cmd.new($0, ARGV)
|
|
|
|
exec "xcrun", cmd.tool, *cmd.args
|
|
|
|
end
|