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
|
|
|
require 'extend/ENV'
|
|
|
|
require 'macos'
|
|
|
|
|
|
|
|
### Why `superenv`?
|
|
|
|
# 1) Only specify the environment we need (NO LDFLAGS for cmake)
|
|
|
|
# 2) Only apply compiler specific options when we are calling that compiler
|
|
|
|
# 3) Force all incpaths and libpaths into the cc instantiation (less bugs)
|
|
|
|
# 4) Cater toolchain usage to specific Xcode versions
|
|
|
|
# 5) Remove flags that we don't want or that will break builds
|
|
|
|
# 6) Simpler code
|
|
|
|
# 7) Simpler formula that *just work*
|
|
|
|
# 8) Build-system agnostic configuration of the tool-chain
|
|
|
|
|
2012-08-31 11:42:01 -04:00
|
|
|
def superbin
|
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
|
|
|
@bin ||= (HOMEBREW_REPOSITORY/"Library/ENV").children.reject{|d| d.basename.to_s > MacOS::Xcode.version }.max
|
|
|
|
end
|
|
|
|
|
|
|
|
def superenv?
|
|
|
|
not MacOS::Xcode.bad_xcode_select_path? and # because xcrun won't work
|
|
|
|
not MacOS::Xcode.folder.nil? and # because xcrun won't work
|
2012-08-31 11:42:01 -04:00
|
|
|
superbin and superbin.directory? and
|
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
|
|
|
not ARGV.include? "--env=std"
|
|
|
|
end
|
|
|
|
|
|
|
|
class << ENV
|
|
|
|
attr :deps, true
|
2012-08-29 11:19:39 -04:00
|
|
|
attr :x11, true
|
|
|
|
alias_method :x11?, :x11
|
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 reset
|
2012-08-30 10:03:26 -04:00
|
|
|
%w{CC CXX CPP OBJC MAKE
|
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
|
|
|
CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS
|
|
|
|
MACOS_DEPLOYMENT_TARGET SDKROOT
|
2012-08-23 16:15:26 -04:00
|
|
|
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH}.
|
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
|
|
|
each{ |x| delete(x) }
|
|
|
|
delete('CDPATH') # avoid make issues that depend on changing directories
|
|
|
|
delete('GREP_OPTIONS') # can break CMake
|
|
|
|
delete('CLICOLOR_FORCE') # autotools doesn't like this
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup_build_environment
|
|
|
|
reset
|
2012-08-31 10:26:22 -04:00
|
|
|
check
|
2012-09-21 23:10:46 -04:00
|
|
|
ENV['CC'] = 'cc'
|
2012-09-03 11:56:29 -04:00
|
|
|
ENV['CXX'] = 'c++'
|
2012-08-23 16:15:26 -04:00
|
|
|
ENV['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"
|
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
|
|
|
ENV['PATH'] = determine_path
|
|
|
|
ENV['PKG_CONFIG_PATH'] = determine_pkg_config_path
|
|
|
|
ENV['HOMEBREW_CC'] = determine_cc
|
2012-08-27 08:48:02 -04:00
|
|
|
ENV['HOMEBREW_CCCFG'] = determine_cccfg
|
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
|
|
|
ENV['HOMEBREW_SDKROOT'] = "#{MacOS.sdk_path}" if MacSystem.xcode43_without_clt?
|
|
|
|
ENV['CMAKE_PREFIX_PATH'] = determine_cmake_prefix_path
|
|
|
|
ENV['CMAKE_FRAMEWORK_PATH'] = "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt?
|
|
|
|
ENV['CMAKE_INCLUDE_PATH'] = determine_cmake_include_path
|
2012-08-31 14:12:03 -04:00
|
|
|
ENV['CMAKE_LIBRARY_PATH'] = determine_cmake_library_path
|
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
|
|
|
ENV['ACLOCAL_PATH'] = determine_aclocal_path
|
2012-08-31 10:21:44 -04:00
|
|
|
ENV['VERBOSE'] = '1' if ARGV.verbose?
|
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 10:26:22 -04:00
|
|
|
def check
|
|
|
|
raise if MacSystem.xcode43_without_clt? and MacOS.sdk_path.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
|
|
|
def universal_binary
|
|
|
|
append 'HOMEBREW_CCCFG', "u", ''
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def determine_cc
|
|
|
|
if ARGV.include? '--use-gcc'
|
|
|
|
"gcc"
|
|
|
|
elsif ARGV.include? '--use-llvm'
|
|
|
|
"llvm-gcc"
|
|
|
|
elsif ARGV.include? '--use-clang'
|
|
|
|
"clang"
|
|
|
|
elsif ENV['HOMEBREW_USE_CLANG']
|
|
|
|
opoo %{HOMEBREW_USE_CLANG is deprecated, use HOMEBREW_CC="clang" instead}
|
|
|
|
"clang"
|
|
|
|
elsif ENV['HOMEBREW_USE_LLVM']
|
|
|
|
opoo %{HOMEBREW_USE_LLVM is deprecated, use HOMEBREW_CC="llvm" instead}
|
|
|
|
"llvm-gcc"
|
|
|
|
elsif ENV['HOMEBREW_USE_GCC']
|
|
|
|
opoo %{HOMEBREW_USE_GCC is deprecated, use HOMEBREW_CC="gcc" instead}
|
|
|
|
"gcc"
|
|
|
|
elsif ENV['HOMEBREW_CC']
|
|
|
|
case ENV['HOMEBREW_CC']
|
|
|
|
when 'clang', 'gcc' then ENV['HOMEBREW_CC']
|
|
|
|
when 'llvm', 'llvm-gcc' then 'llvm-gcc'
|
|
|
|
else
|
|
|
|
opoo "Invalid value for HOMEBREW_CC: #{ENV['HOMEBREW_CC']}"
|
|
|
|
raise # use default
|
|
|
|
end
|
|
|
|
else
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
"clang"
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_path
|
2012-08-31 11:42:01 -04:00
|
|
|
paths = [superbin]
|
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
|
|
|
if MacSystem.xcode43_without_clt?
|
|
|
|
paths << "#{MacSystem.xcode43_developer_dir}/usr/bin"
|
|
|
|
paths << "#{MacSystem.xcode43_developer_dir}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
|
|
|
|
end
|
|
|
|
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" }
|
|
|
|
paths << HOMEBREW_PREFIX/:bin
|
2012-08-29 11:19:39 -04:00
|
|
|
paths << "#{MacSystem.x11_prefix}/bin" if x11?
|
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
|
|
|
paths += %w{/usr/bin /bin /usr/sbin /sbin}
|
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_pkg_config_path
|
|
|
|
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/lib/pkgconfig" }
|
|
|
|
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/pkgconfig" }
|
2012-08-30 16:08:24 -05:00
|
|
|
paths << "#{HOMEBREW_PREFIX}/lib/pkgconfig"
|
|
|
|
paths << "#{HOMEBREW_PREFIX}/share/pkgconfig"
|
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
|
|
|
# we put our paths before X because we dupe some of the X libraries
|
2012-08-29 11:19:39 -04:00
|
|
|
paths << "#{MacSystem.x11_prefix}/lib/pkgconfig" << "#{MacSystem.x11_prefix}/share/pkgconfig" if x11?
|
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
|
|
|
# Mountain Lion no longer ships some .pcs; ensure we pick up our versions
|
2012-09-04 23:04:01 -05:00
|
|
|
paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.version >= :mountain_lion
|
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
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cmake_prefix_path
|
|
|
|
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" }
|
2012-09-03 14:17:40 -04:00
|
|
|
paths << HOMEBREW_PREFIX.to_s # put ourselves ahead of everything else
|
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
|
|
|
paths << "#{MacOS.sdk_path}/usr" if MacSystem.xcode43_without_clt?
|
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cmake_include_path
|
|
|
|
sdk = MacOS.sdk_path if MacSystem.xcode43_without_clt?
|
2012-08-29 11:19:39 -04:00
|
|
|
paths = []
|
|
|
|
paths << "#{MacSystem.x11_prefix}/include/freetype2" if x11?
|
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
|
|
|
paths << "#{sdk}/usr/include/libxml2" unless deps.include? 'libxml2'
|
2012-09-03 12:30:21 -04:00
|
|
|
if MacSystem.xcode43_without_clt?
|
|
|
|
paths << "#{sdk}/usr/include/apache2"
|
|
|
|
# TODO prolly shouldn't always do this?
|
|
|
|
paths << "#{sdk}/System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7"
|
|
|
|
end
|
2012-09-13 12:10:01 -04:00
|
|
|
paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/" unless x11?
|
2012-09-03 14:17:40 -04:00
|
|
|
paths << "#{MacSystem.x11_prefix}/include" if x11?
|
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
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
2012-08-31 14:12:03 -04:00
|
|
|
def determine_cmake_library_path
|
|
|
|
sdk = MacOS.sdk_path if MacSystem.xcode43_without_clt?
|
2012-09-03 14:17:40 -04:00
|
|
|
paths = []
|
2012-08-31 14:12:03 -04:00
|
|
|
# things expect to find GL headers since X11 used to be a default, so we add them
|
2012-09-13 12:10:01 -04:00
|
|
|
paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" unless x11?
|
2012-09-03 14:17:40 -04:00
|
|
|
paths << "#{MacSystem.x11_prefix}/lib" if x11?
|
|
|
|
paths.to_path_s
|
2012-08-31 14:12:03 -04:00
|
|
|
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 determine_aclocal_path
|
|
|
|
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/aclocal" }
|
|
|
|
paths << "#{HOMEBREW_PREFIX}/share/aclocal"
|
2012-08-29 11:19:39 -04:00
|
|
|
paths << "/opt/X11/share/aclocal" if x11?
|
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
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
2012-08-23 16:15:26 -04:00
|
|
|
def determine_make_jobs
|
|
|
|
if (j = ENV['HOMEBREW_MAKE_JOBS'].to_i) < 1
|
|
|
|
Hardware.processor_count
|
|
|
|
else
|
|
|
|
j
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-27 08:48:02 -04:00
|
|
|
def determine_cccfg
|
|
|
|
s = ""
|
2012-08-31 11:42:01 -04:00
|
|
|
s << 'b' if ARGV.build_bottle?
|
2012-08-27 08:48:02 -04:00
|
|
|
# Fix issue with sed barfing on unicode characters on Mountain Lion
|
2012-09-04 23:04:01 -05:00
|
|
|
s << 's' if MacOS.version >= :mountain_lion
|
2012-08-31 11:42:01 -04:00
|
|
|
# Fix issue with 10.8 apr-1-config having broken paths
|
2012-09-04 23:04:01 -05:00
|
|
|
s << 'a' if MacOS.version == :mountain_lion
|
2012-08-27 08:48:02 -04:00
|
|
|
s
|
|
|
|
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
|
|
|
public
|
|
|
|
|
|
|
|
### NO LONGER NECESSARY OR NO LONGER SUPPORTED
|
|
|
|
def noop(*args); end
|
|
|
|
%w[m64 m32 gcc_4_0_1 fast O4 O3 O2 Os Og O1 libxml2 minimal_optimization
|
2012-08-29 14:36:30 -04:00
|
|
|
no_optimization enable_warnings x11
|
|
|
|
set_cpu_flags
|
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
|
|
|
macosxsdk remove_macosxsdk].each{|s| alias_method s, :noop }
|
|
|
|
|
|
|
|
### DEPRECATE THESE
|
|
|
|
def compiler
|
|
|
|
case ENV['HOMEBREW_CC']
|
|
|
|
when "llvm-gcc" then :llvm
|
|
|
|
when "gcc", "clang" then ENV['HOMEBREW_CC'].to_sym
|
|
|
|
else
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def deparallelize
|
|
|
|
delete('MAKEFLAGS')
|
|
|
|
end
|
|
|
|
alias_method :j1, :deparallelize
|
|
|
|
def gcc
|
2012-09-03 11:56:29 -04:00
|
|
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "gcc"
|
|
|
|
ENV['CXX'] = "g++"
|
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 llvm
|
2012-09-03 11:56:29 -04:00
|
|
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "llvm-gcc"
|
|
|
|
ENV['CXX'] = "g++"
|
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 clang
|
2012-09-03 11:56:29 -04:00
|
|
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "clang"
|
|
|
|
ENV['CXX'] = "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
|
|
|
end
|
|
|
|
def make_jobs
|
|
|
|
ENV['MAKEFLAGS'] =~ /-\w*j(\d)+/
|
|
|
|
[$1.to_i, 1].max
|
|
|
|
end
|
|
|
|
|
2012-08-31 23:44:36 -04:00
|
|
|
# Many formula assume that CFLAGS etc. will not be nil.
|
|
|
|
# This should be a safe hack to prevent that exception cropping up.
|
|
|
|
# Main consqeuence of this is that ENV['CFLAGS'] is never nil even when it
|
|
|
|
# is which can break if checks, but we don't do such a check in our code.
|
|
|
|
def [] key
|
|
|
|
if has_key? key
|
|
|
|
fetch(key)
|
|
|
|
elsif %w{CPPFLAGS CFLAGS LDFLAGS}.include? key
|
|
|
|
class << (a = "")
|
|
|
|
attr :key, true
|
|
|
|
def + value
|
|
|
|
ENV[key] = value
|
|
|
|
end
|
|
|
|
alias_method '<<', '+'
|
|
|
|
end
|
|
|
|
a.key = key
|
|
|
|
a
|
|
|
|
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
|
|
|
end if superenv?
|
|
|
|
|
|
|
|
|
|
|
|
if not superenv?
|
|
|
|
ENV.extend(HomebrewEnvExtension)
|
|
|
|
# we must do this or tools like pkg-config won't get found by configure scripts etc.
|
|
|
|
ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin'
|
|
|
|
else
|
|
|
|
ENV.deps = []
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class Array
|
|
|
|
def to_path_s
|
2012-08-30 09:45:07 -04:00
|
|
|
map(&:to_s).uniq.select{|s| File.directory? s }.join(':').chuzzle
|
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
|
|
|
|
|
|
|
|
# new code because I don't really trust the Xcode code now having researched it more
|
|
|
|
module MacSystem extend self
|
|
|
|
def xcode_clt_installed?
|
|
|
|
File.executable? "/usr/bin/clang" and File.executable? "/usr/bin/lldb"
|
|
|
|
end
|
|
|
|
|
|
|
|
def xcode43_without_clt?
|
|
|
|
MacOS::Xcode.version >= "4.3" and not MacSystem.xcode_clt_installed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def x11_prefix
|
|
|
|
@x11_prefix ||= %W[/usr/X11 /opt/X11
|
|
|
|
#{MacOS.sdk_path}/usr/X11].find{|path| File.directory? "#{path}/include" }
|
|
|
|
end
|
|
|
|
|
|
|
|
def xcode43_developer_dir
|
|
|
|
@xcode43_developer_dir ||=
|
|
|
|
tst(ENV['DEVELOPER_DIR']) ||
|
|
|
|
tst(`xcode-select -print-path 2>/dev/null`) ||
|
|
|
|
tst("/Applications/Xcode.app/Contents/Developer") ||
|
|
|
|
MacOS.mdfind("com.apple.dt.Xcode").find{|path| tst(path) }
|
|
|
|
raise unless @xcode43_developer_dir
|
|
|
|
@xcode43_developer_dir
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tst prefix
|
|
|
|
prefix = prefix.to_s.chomp
|
|
|
|
xcrun = "#{prefix}/usr/bin/xcrun"
|
|
|
|
prefix if xcrun != "/usr/bin/xcrun" and File.executable? xcrun
|
|
|
|
end
|
|
|
|
end
|