2015-08-03 13:09:07 +01:00
|
|
|
require "os/mac"
|
|
|
|
require "extend/ENV/shared"
|
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
|
|
|
|
|
|
|
### 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
|
|
|
|
|
2013-08-19 12:32:55 -05:00
|
|
|
module Superenv
|
2013-08-19 12:32:59 -05:00
|
|
|
include SharedEnvExtension
|
|
|
|
|
2013-03-09 16:56:32 -06:00
|
|
|
attr_accessor :keg_only_deps, :deps, :x11
|
2012-08-29 11:19:39 -04:00
|
|
|
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
|
|
|
|
2013-08-19 12:32:56 -05:00
|
|
|
def self.extended(base)
|
|
|
|
base.keg_only_deps = []
|
|
|
|
base.deps = []
|
|
|
|
end
|
|
|
|
|
2013-08-19 12:32:56 -05:00
|
|
|
def self.bin
|
2015-05-25 00:05:32 -04:00
|
|
|
bin = (HOMEBREW_REPOSITORY/"Library/ENV").subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
|
|
|
|
bin.realpath unless bin.nil?
|
2013-08-19 12:32:56 -05: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 reset
|
2014-05-26 14:10:24 -05:00
|
|
|
super
|
2013-11-15 00:15:50 -06:00
|
|
|
# Configure scripts generated by autoconf 2.61 or later export as_nl, which
|
|
|
|
# we use as a heuristic for running under configure
|
2014-05-26 14:10:24 -05:00
|
|
|
delete("as_nl")
|
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
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def setup_build_environment(formula = nil)
|
2014-09-18 15:50:54 -05:00
|
|
|
super
|
|
|
|
send(compiler)
|
2013-09-10 23:08:17 -07:00
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}"
|
|
|
|
self["PATH"] = determine_path
|
|
|
|
self["PKG_CONFIG_PATH"] = determine_pkg_config_path
|
|
|
|
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
|
|
|
|
self["HOMEBREW_CCCFG"] = determine_cccfg
|
|
|
|
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "Os"
|
|
|
|
self["HOMEBREW_BREW_FILE"] = HOMEBREW_BREW_FILE.to_s
|
|
|
|
self["HOMEBREW_PREFIX"] = HOMEBREW_PREFIX.to_s
|
|
|
|
self["HOMEBREW_CELLAR"] = HOMEBREW_CELLAR.to_s
|
|
|
|
self["HOMEBREW_TEMP"] = HOMEBREW_TEMP.to_s
|
|
|
|
self["HOMEBREW_SDKROOT"] = effective_sysroot
|
|
|
|
self["HOMEBREW_OPTFLAGS"] = determine_optflags
|
|
|
|
self["HOMEBREW_ARCHFLAGS"] = ""
|
|
|
|
self["CMAKE_PREFIX_PATH"] = determine_cmake_prefix_path
|
|
|
|
self["CMAKE_FRAMEWORK_PATH"] = determine_cmake_frameworks_path
|
|
|
|
self["CMAKE_INCLUDE_PATH"] = determine_cmake_include_path
|
|
|
|
self["CMAKE_LIBRARY_PATH"] = determine_cmake_library_path
|
|
|
|
self["ACLOCAL_PATH"] = determine_aclocal_path
|
|
|
|
self["M4"] = MacOS.locate("m4") if deps.any? { |d| d.name == "autoconf" }
|
2014-05-19 14:18:23 -05:00
|
|
|
self["HOMEBREW_ISYSTEM_PATHS"] = determine_isystem_paths
|
|
|
|
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
|
|
|
|
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
|
|
|
|
|
2014-05-08 17:10:08 -05:00
|
|
|
# On 10.9, the tools in /usr/bin proxy to the active developer directory.
|
|
|
|
# This means we can use them for any combination of CLT and Xcode.
|
2014-05-13 11:22:30 -05:00
|
|
|
self["HOMEBREW_PREFER_CLT_PROXIES"] = "1" if MacOS.version >= "10.9"
|
2014-05-08 17:10:08 -05:00
|
|
|
|
2013-08-01 11:36:44 -07:00
|
|
|
# The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control
|
|
|
|
# compiler flag stripping. It consists of a string of characters which act
|
|
|
|
# as flags. Some of these flags are mutually exclusive.
|
|
|
|
#
|
2013-08-04 22:37:52 -07:00
|
|
|
# O - Enables argument refurbishing. Only active under the
|
|
|
|
# make/bsdmake wrappers currently.
|
2013-10-07 00:40:32 -07:00
|
|
|
# x - Enable C++11 mode.
|
|
|
|
# g - Enable "-stdlib=libc++" for clang.
|
2013-10-24 00:26:09 -07:00
|
|
|
# h - Enable "-stdlib=libstdc++" for clang.
|
2014-05-14 00:00:59 -05:00
|
|
|
# K - Don't strip -arch <arch>, -m32, or -m64
|
2013-08-01 11:36:44 -07:00
|
|
|
#
|
|
|
|
# On 10.8 and newer, these flags will also be present:
|
|
|
|
# s - apply fix for sed's Unicode support
|
|
|
|
# a - apply fix for apr-1-config 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
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def cc=(val)
|
2014-05-13 16:09:19 -05:00
|
|
|
self["HOMEBREW_CC"] = super
|
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def cxx=(val)
|
2014-05-13 16:09:19 -05:00
|
|
|
self["HOMEBREW_CXX"] = super
|
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def effective_sysroot
|
2014-10-27 23:59:47 -05:00
|
|
|
MacOS::Xcode.without_clt? ? MacOS.sdk_path.to_s : nil
|
2014-05-19 14:18:23 -05:00
|
|
|
end
|
|
|
|
|
2013-10-30 13:00:39 -07:00
|
|
|
def determine_cxx
|
2015-08-03 13:09:07 +01:00
|
|
|
determine_cc.to_s.gsub("gcc", "g++").gsub("clang", "clang++")
|
2013-10-30 13:00:39 -07: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_path
|
2013-08-19 12:32:56 -05:00
|
|
|
paths = [Superenv.bin]
|
2014-05-13 10:48:13 -05:00
|
|
|
|
2014-04-28 15:32:53 -07:00
|
|
|
# Formula dependencies can override standard tools.
|
2015-06-17 22:03:50 -04:00
|
|
|
paths += deps.map { |d| d.opt_bin.to_s }
|
2014-04-28 15:32:53 -07:00
|
|
|
|
2014-05-13 10:48:13 -05:00
|
|
|
# On 10.9, there are shims for all tools in /usr/bin.
|
|
|
|
# On 10.7 and 10.8 we need to add these directories ourselves.
|
|
|
|
if MacOS::Xcode.without_clt? && MacOS.version <= "10.8"
|
2013-03-20 18:20:18 +01:00
|
|
|
paths << "#{MacOS::Xcode.prefix}/usr/bin"
|
2014-05-01 18:36:46 -05:00
|
|
|
paths << "#{MacOS::Xcode.toolchain_path}/usr/bin"
|
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
|
2014-05-13 10:48:13 -05:00
|
|
|
|
2014-05-13 12:13:05 -05:00
|
|
|
paths << MacOS::X11.bin.to_s if x11?
|
2015-08-03 13:09:07 +01:00
|
|
|
paths += %w[/usr/bin /bin /usr/sbin /sbin]
|
2013-09-10 23:08:17 -07:00
|
|
|
|
|
|
|
# Homebrew's apple-gcc42 will be outside the PATH in superenv,
|
|
|
|
# so xcrun may not be able to find it
|
2014-05-18 14:34:31 -05:00
|
|
|
case homebrew_cc
|
2014-05-13 12:13:05 -05:00
|
|
|
when "gcc-4.2"
|
|
|
|
begin
|
2015-08-03 13:09:07 +01:00
|
|
|
apple_gcc42 = Formulary.factory("apple-gcc42")
|
2015-08-06 15:45:52 +08:00
|
|
|
rescue FormulaUnavailableError
|
2013-09-10 23:08:17 -07:00
|
|
|
end
|
2014-05-13 12:13:05 -05:00
|
|
|
paths << apple_gcc42.opt_bin.to_s if apple_gcc42
|
2014-05-13 12:13:05 -05:00
|
|
|
when GNU_GCC_REGEXP
|
2015-06-21 21:18:23 -04:00
|
|
|
gcc_formula = gcc_version_formula($&)
|
2014-05-13 12:13:05 -05:00
|
|
|
paths << gcc_formula.opt_bin.to_s
|
2013-09-10 23:08:17 -07: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
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_pkg_config_path
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = deps.map { |d| "#{d.opt_lib}/pkgconfig" }
|
|
|
|
paths += deps.map { |d| "#{d.opt_share}/pkgconfig" }
|
2013-03-08 18:14:00 -06:00
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_pkg_config_libdir
|
2015-08-03 13:09:07 +01:00
|
|
|
paths = %W[/usr/lib/pkgconfig #{HOMEBREW_LIBRARY}/ENV/pkgconfig/#{MacOS.version}]
|
2013-08-06 19:24:19 -05:00
|
|
|
paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.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
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
2014-05-13 10:48:13 -05:00
|
|
|
def determine_aclocal_path
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = keg_only_deps.map { |d| "#{d.opt_share}/aclocal" }
|
2014-05-13 10:48:13 -05:00
|
|
|
paths << "#{HOMEBREW_PREFIX}/share/aclocal"
|
|
|
|
paths << "#{MacOS::X11.share}/aclocal" if x11?
|
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_isystem_paths
|
|
|
|
paths = []
|
|
|
|
paths << "#{HOMEBREW_PREFIX}/include"
|
2015-06-17 22:03:50 -04:00
|
|
|
paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" }
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
|
|
|
|
paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
|
2014-05-28 09:20:44 -05:00
|
|
|
paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
|
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
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_include_paths
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = keg_only_deps.map { |d| d.opt_include.to_s }
|
2015-04-15 14:24:02 -07:00
|
|
|
|
|
|
|
# https://github.com/Homebrew/homebrew/issues/38514
|
2015-04-20 20:49:42 -04:00
|
|
|
if MacOS::CLT.installed? && MacOS.active_developer_dir.include?("CommandLineTools") &&
|
2015-04-15 14:24:02 -07:00
|
|
|
MacOS::CLT.version == "6.3.0.0.1.1428348375"
|
|
|
|
paths << "#{HOMEBREW_LIBRARY}/ENV/include/6.3"
|
|
|
|
end
|
|
|
|
|
|
|
|
paths.to_path_s
|
2014-05-19 14:18:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def determine_library_paths
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = keg_only_deps.map { |d| d.opt_lib.to_s }
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << "#{HOMEBREW_PREFIX}/lib"
|
|
|
|
paths << MacOS::X11.lib.to_s if x11?
|
2014-05-28 09:20:44 -05:00
|
|
|
paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
|
2014-05-19 14:18:23 -05:00
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cmake_prefix_path
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = keg_only_deps.map { |d| d.opt_prefix.to_s }
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << HOMEBREW_PREFIX.to_s
|
2013-01-21 10:33:56 +01:00
|
|
|
paths.to_path_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
|
|
|
def determine_cmake_include_path
|
2012-08-29 11:19:39 -04:00
|
|
|
paths = []
|
2015-06-17 22:03:50 -04:00
|
|
|
paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" }
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
|
|
|
|
paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
|
2014-05-28 09:20:44 -05:00
|
|
|
paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
|
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
|
2012-09-03 14:17:40 -04:00
|
|
|
paths = []
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << MacOS::X11.lib.to_s if x11?
|
2014-05-28 09:20:44 -05:00
|
|
|
paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
|
2014-05-19 14:18:23 -05:00
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cmake_frameworks_path
|
2015-06-17 22:03:50 -04:00
|
|
|
paths = deps.map { |d| d.opt_frameworks.to_s }
|
2014-05-19 14:18:23 -05:00
|
|
|
paths << "#{effective_sysroot}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
|
2012-09-03 14:17:40 -04:00
|
|
|
paths.to_path_s
|
2012-08-31 14:12:03 -04:00
|
|
|
end
|
|
|
|
|
2012-08-23 16:15:26 -04:00
|
|
|
def determine_make_jobs
|
2015-08-03 13:09:07 +01:00
|
|
|
if (j = self["HOMEBREW_MAKE_JOBS"].to_i) < 1
|
2013-06-13 12:04:58 -05:00
|
|
|
Hardware::CPU.cores
|
2012-08-23 16:15:26 -04:00
|
|
|
else
|
|
|
|
j
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-20 12:54:34 -06:00
|
|
|
def determine_optflags
|
2013-05-11 12:18:25 +01:00
|
|
|
if ARGV.build_bottle?
|
2013-11-20 12:54:34 -06:00
|
|
|
arch = ARGV.bottle_arch || Hardware.oldest_cpu
|
|
|
|
Hardware::CPU.optimization_flags.fetch(arch)
|
2013-11-27 17:25:17 -06:00
|
|
|
elsif Hardware::CPU.intel? && !Hardware::CPU.sse4?
|
|
|
|
Hardware::CPU.optimization_flags.fetch(Hardware.oldest_cpu)
|
2014-04-29 19:11:34 -07:00
|
|
|
elsif compiler == :clang
|
|
|
|
"-march=native"
|
|
|
|
# This is mutated elsewhere, so return an empty string in this case
|
2013-11-27 17:25:17 -06:00
|
|
|
else
|
2014-04-29 19:11:34 -07:00
|
|
|
""
|
2013-05-11 12:18:25 +01:00
|
|
|
end
|
2013-11-20 12:54:34 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cccfg
|
|
|
|
s = ""
|
2012-08-27 08:48:02 -04:00
|
|
|
# Fix issue with sed barfing on unicode characters on Mountain Lion
|
2015-08-03 13:09:07 +01:00
|
|
|
s << "s" if MacOS.version >= :mountain_lion
|
2013-06-13 17:19:27 +02:00
|
|
|
# Fix issue with >= 10.8 apr-1-config having broken paths
|
2015-08-03 13:09:07 +01: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
|
|
|
|
|
2015-04-25 02:03:00 -07:00
|
|
|
# Removes the MAKEFLAGS environment variable, causing make to use a single job.
|
|
|
|
# This is useful for makefiles with race conditions.
|
|
|
|
# When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
|
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 deparallelize
|
2015-08-03 13:09:07 +01:00
|
|
|
old = delete("MAKEFLAGS")
|
2015-04-25 02:03:00 -07:00
|
|
|
if block_given?
|
|
|
|
begin
|
|
|
|
yield
|
|
|
|
ensure
|
2015-08-03 13:09:07 +01:00
|
|
|
self["MAKEFLAGS"] = old
|
2015-04-25 02:03:00 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
old
|
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
|
|
|
|
alias_method :j1, :deparallelize
|
2013-11-11 18:33:47 -06: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
|
|
|
def make_jobs
|
2015-08-03 13:09:07 +01:00
|
|
|
self["MAKEFLAGS"] =~ /-\w*j(\d)+/
|
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
|
|
|
[$1.to_i, 1].max
|
|
|
|
end
|
2013-11-11 18:33:47 -06:00
|
|
|
|
|
|
|
def universal_binary
|
2015-08-03 13:09:07 +01:00
|
|
|
self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
|
2014-01-08 00:08:52 -05:00
|
|
|
|
|
|
|
# GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
|
|
|
|
if compiler != :clang && Hardware.is_32_bit?
|
2015-08-03 13:09:07 +01:00
|
|
|
self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
|
2014-01-08 00:08:52 -05:00
|
|
|
/-march=\S*/,
|
|
|
|
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
|
|
|
|
)
|
|
|
|
end
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
2014-05-14 00:00:59 -05:00
|
|
|
def permit_arch_flags
|
|
|
|
append "HOMEBREW_CCCFG", "K"
|
|
|
|
end
|
|
|
|
|
2014-05-22 09:18:34 -05:00
|
|
|
def m32
|
|
|
|
append "HOMEBREW_ARCHFLAGS", "-m32"
|
|
|
|
end
|
|
|
|
|
2014-05-22 09:18:34 -05:00
|
|
|
def m64
|
|
|
|
append "HOMEBREW_ARCHFLAGS", "-m64"
|
|
|
|
end
|
|
|
|
|
2013-11-11 18:33:47 -06:00
|
|
|
def cxx11
|
2014-05-18 14:34:31 -05:00
|
|
|
case homebrew_cc
|
2014-05-13 16:23:12 -05:00
|
|
|
when "clang"
|
2015-08-03 13:09:07 +01:00
|
|
|
append "HOMEBREW_CCCFG", "x", ""
|
|
|
|
append "HOMEBREW_CCCFG", "g", ""
|
2015-05-14 10:36:56 -07:00
|
|
|
when /gcc-(4\.(8|9)|5)/
|
2015-08-03 13:09:07 +01:00
|
|
|
append "HOMEBREW_CCCFG", "x", ""
|
2013-11-11 18:33:47 -06:00
|
|
|
else
|
2014-05-18 14:34:31 -05:00
|
|
|
raise "The selected compiler doesn't support C++11: #{homebrew_cc}"
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def libcxx
|
2014-05-13 16:22:57 -05:00
|
|
|
append "HOMEBREW_CCCFG", "g", "" if compiler == :clang
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def libstdcxx
|
2014-05-13 16:22:57 -05:00
|
|
|
append "HOMEBREW_CCCFG", "h", "" if compiler == :clang
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
2014-03-20 15:20:27 -07:00
|
|
|
def refurbish_args
|
2015-08-03 13:09:07 +01:00
|
|
|
append "HOMEBREW_CCCFG", "O", ""
|
2014-03-20 15:20:27 -07:00
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
%w[O3 O2 O1 O0 Os].each do |opt|
|
2013-11-12 12:00:18 -06:00
|
|
|
define_method opt do
|
2015-08-03 13:09:07 +01:00
|
|
|
self["HOMEBREW_OPTIMIZATION_LEVEL"] = opt
|
2013-11-12 12:00:18 -06:00
|
|
|
end
|
|
|
|
end
|
2013-11-12 12:00:18 -06:00
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def noop(*_args); end
|
2013-11-12 12:00:18 -06:00
|
|
|
noops = []
|
|
|
|
|
|
|
|
# These methods are no longer necessary under superenv, but are needed to
|
|
|
|
# maintain an interface compatible with stdenv.
|
2015-08-03 13:09:07 +01:00
|
|
|
noops.concat %w[fast O4 Og libxml2 set_cpu_flags macosxsdk remove_macosxsdk]
|
2013-11-12 12:00:18 -06:00
|
|
|
|
|
|
|
# These methods provide functionality that has not yet been ported to
|
|
|
|
# superenv.
|
2015-08-03 13:09:07 +01:00
|
|
|
noops.concat %w[gcc_4_0_1 minimal_optimization no_optimization enable_warnings]
|
2013-11-12 12:00:18 -06:00
|
|
|
|
|
|
|
noops.each { |m| alias_method m, :noop }
|
2013-08-19 12:32:55 -05: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
|
|
|
|
|
|
|
class Array
|
|
|
|
def to_path_s
|
2015-08-03 13:09:07 +01:00
|
|
|
map(&:to_s).uniq.select { |s| File.directory? s }.join(File::PATH_SEPARATOR).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
|