2015-08-03 13:09:07 +01:00
|
|
|
require "extend/ENV/shared"
|
2016-07-06 11:07:24 +01:00
|
|
|
require "development_tools"
|
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
|
|
|
|
2015-08-29 10:56:24 +01: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
|
|
|
|
|
2015-08-29 10:56:24 +01:00
|
|
|
# @private
|
2018-05-16 11:34:12 -07:00
|
|
|
attr_accessor :keg_only_deps, :deps, :run_time_deps
|
2015-08-29 10:56:24 +01:00
|
|
|
attr_accessor :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 = []
|
2018-05-16 11:34:12 -07:00
|
|
|
base.run_time_deps = []
|
2013-08-19 12:32:56 -05:00
|
|
|
end
|
|
|
|
|
2015-08-29 10:56:24 +01:00
|
|
|
# @private
|
2017-10-07 00:31:28 +02:00
|
|
|
def self.bin; end
|
2013-08-19 12:32:56 -05: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 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-29 10:56:24 +01:00
|
|
|
# @private
|
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
|
|
|
|
2018-04-02 09:29:14 +01:00
|
|
|
self["HOMEBREW_ENV"] = "super"
|
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
|
2016-03-24 11:18:30 -07:00
|
|
|
self["HOMEBREW_OPT"] = "#{HOMEBREW_PREFIX}/opt"
|
2015-08-03 13:09:07 +01:00
|
|
|
self["HOMEBREW_TEMP"] = HOMEBREW_TEMP.to_s
|
|
|
|
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
|
2016-04-25 18:01:03 +01:00
|
|
|
self["M4"] = DevelopmentTools.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
|
2016-03-24 11:18:30 -07:00
|
|
|
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
|
2016-09-23 11:01:40 +02:00
|
|
|
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil?
|
2014-05-19 14:18:23 -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
|
2016-08-17 22:26:42 -07:00
|
|
|
# w - Pass -no_weak_imports to the linker
|
2013-08-01 11:36:44 -07:00
|
|
|
#
|
2019-01-26 17:13:14 +00:00
|
|
|
# These flags will also be present:
|
2013-08-01 11:36:44 -07:00
|
|
|
# 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
|
2016-09-23 18:13:48 +02:00
|
|
|
alias generic_setup_build_environment setup_build_environment
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_paths
|
|
|
|
[]
|
|
|
|
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
|
2017-04-27 09:56:16 +02:00
|
|
|
path = PATH.new(Superenv.bin)
|
2014-05-13 10:48:13 -05:00
|
|
|
|
2014-04-28 15:32:53 -07:00
|
|
|
# Formula dependencies can override standard tools.
|
2017-04-27 10:44:44 +02:00
|
|
|
path.append(deps.map(&:opt_bin))
|
2017-04-27 09:56:16 +02:00
|
|
|
path.append(homebrew_extra_paths)
|
|
|
|
path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin")
|
2013-09-10 23:08:17 -07:00
|
|
|
|
2017-03-06 09:51:15 -08:00
|
|
|
begin
|
2019-02-19 13:11:32 +00:00
|
|
|
path.append(gcc_version_formula($&).opt_bin) if homebrew_cc =~ GNU_GCC_REGEXP
|
2017-03-06 09:51:15 -08:00
|
|
|
rescue FormulaUnavailableError
|
|
|
|
# Don't fail and don't add these formulae to the path if they don't exist.
|
|
|
|
nil
|
2013-09-10 23:08:17 -07:00
|
|
|
end
|
|
|
|
|
2017-04-28 12:42:17 +02:00
|
|
|
path.existing
|
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
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_pkg_config_paths
|
|
|
|
[]
|
|
|
|
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_pkg_config_path
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
deps.map { |d| d.opt_lib/"pkgconfig" },
|
|
|
|
deps.map { |d| d.opt_share/"pkgconfig" },
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
2013-03-08 18:14:00 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def determine_pkg_config_libdir
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
homebrew_extra_pkg_config_paths,
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
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
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_aclocal_paths
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2014-05-13 10:48:13 -05:00
|
|
|
def determine_aclocal_path
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
keg_only_deps.map { |d| d.opt_share/"aclocal" },
|
|
|
|
HOMEBREW_PREFIX/"share/aclocal",
|
|
|
|
homebrew_extra_aclocal_paths,
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
2014-05-13 10:48:13 -05:00
|
|
|
end
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_isystem_paths
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_isystem_paths
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
HOMEBREW_PREFIX/"include",
|
|
|
|
homebrew_extra_isystem_paths,
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
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-19 14:18:23 -05:00
|
|
|
def determine_include_paths
|
2017-04-28 12:42:17 +02:00
|
|
|
PATH.new(keg_only_deps.map(&:opt_include)).existing
|
2014-05-19 14:18:23 -05:00
|
|
|
end
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_library_paths
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_library_paths
|
2018-03-06 08:44:47 +00:00
|
|
|
paths = [
|
|
|
|
keg_only_deps.map(&:opt_lib),
|
|
|
|
HOMEBREW_PREFIX/"lib",
|
|
|
|
]
|
2018-03-07 15:00:08 +00:00
|
|
|
paths += homebrew_extra_library_paths
|
2018-03-06 08:44:47 +00:00
|
|
|
PATH.new(paths).existing
|
2014-05-19 14:18:23 -05:00
|
|
|
end
|
|
|
|
|
2016-03-24 11:18:30 -07:00
|
|
|
def determine_dependencies
|
2016-09-11 17:53:00 +01:00
|
|
|
deps.map(&:name).join(",")
|
2016-03-24 11:18:30 -07:00
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_cmake_prefix_path
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
keg_only_deps.map(&:opt_prefix),
|
|
|
|
HOMEBREW_PREFIX.to_s,
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
2013-01-21 10:33:56 +01:00
|
|
|
end
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_cmake_include_paths
|
|
|
|
[]
|
|
|
|
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
|
2017-04-28 12:42:17 +02:00
|
|
|
PATH.new(homebrew_extra_cmake_include_paths).existing
|
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
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_cmake_library_paths
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2012-08-31 14:12:03 -04:00
|
|
|
def determine_cmake_library_path
|
2017-04-28 12:42:17 +02:00
|
|
|
PATH.new(homebrew_extra_cmake_library_paths).existing
|
2014-05-19 14:18:23 -05:00
|
|
|
end
|
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
def homebrew_extra_cmake_frameworks_paths
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2014-05-19 14:18:23 -05:00
|
|
|
def determine_cmake_frameworks_path
|
2017-04-27 09:56:16 +02:00
|
|
|
PATH.new(
|
|
|
|
deps.map(&:opt_frameworks),
|
|
|
|
homebrew_extra_cmake_frameworks_paths,
|
2017-04-28 12:42:17 +02:00
|
|
|
).existing
|
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
|
2019-01-06 21:27:15 +00:00
|
|
|
Hardware::CPU.optimization_flags.fetch(effective_arch)
|
2013-11-20 12:54:34 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def determine_cccfg
|
2016-07-12 12:01:20 +01:00
|
|
|
""
|
2012-08-27 08:48:02 -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
|
|
|
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
|
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
|
2016-03-11 03:34:47 -08:00
|
|
|
self["MAKEFLAGS"] =~ /-\w*j(\d+)/
|
2017-06-10 20:23:20 +03:00
|
|
|
[Regexp.last_match(1).to_i, 1].max
|
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-11-11 18:33:47 -06:00
|
|
|
|
|
|
|
def universal_binary
|
2015-12-09 10:37:49 -05:00
|
|
|
check_for_compiler_universal_support
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
2014-05-14 00:00:59 -05:00
|
|
|
def permit_arch_flags
|
2018-07-12 12:14:44 -05:00
|
|
|
append_to_cccfg "K"
|
2014-05-14 00:00:59 -05:00
|
|
|
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
|
2019-01-26 17:13:14 +00:00
|
|
|
append_to_cccfg "x"
|
|
|
|
append_to_cccfg "g" if homebrew_cc == "clang"
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def libcxx
|
2018-07-12 12:14:44 -05:00
|
|
|
append_to_cccfg "g" if compiler == :clang
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def libstdcxx
|
2018-07-12 12:14:44 -05:00
|
|
|
append_to_cccfg "h" if compiler == :clang
|
2013-11-11 18:33:47 -06:00
|
|
|
end
|
|
|
|
|
2015-08-29 10:56:24 +01:00
|
|
|
# @private
|
2014-03-20 15:20:27 -07:00
|
|
|
def refurbish_args
|
2018-07-12 12:14:44 -05:00
|
|
|
append_to_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
|
|
|
|
2017-10-07 00:31:28 +02:00
|
|
|
def set_x11_env_if_installed; end
|
2017-04-22 21:56:32 +01:00
|
|
|
|
2017-10-07 00:31:28 +02:00
|
|
|
def set_cpu_flags(_, _ = "", _ = {}); end
|
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
|
|
|
|
2016-07-12 12:01:20 +01:00
|
|
|
require "extend/os/extend/ENV/super"
|