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 '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
|
|
|
|
|
2013-08-19 12:32:55 -05:00
|
|
|
module Superenv
|
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
|
|
|
|
@bin ||= (HOMEBREW_REPOSITORY/"Library/ENV").children.reject{|d| d.basename.to_s > MacOS::Xcode.version }.max
|
|
|
|
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
|
2013-01-21 10:33:56 +01:00
|
|
|
%w{CC CXX OBJC OBJCXX CPP MAKE LD LDSHARED
|
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
|
2013-03-16 13:50:44 -05:00
|
|
|
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH
|
|
|
|
CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_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-09-21 23:10:46 -04:00
|
|
|
ENV['CC'] = 'cc'
|
2012-09-03 11:56:29 -04:00
|
|
|
ENV['CXX'] = 'c++'
|
2012-11-13 14:38:57 -08:00
|
|
|
ENV['OBJC'] = 'cc'
|
|
|
|
ENV['OBJCXX'] = 'c++'
|
2013-05-31 12:30:25 +02:00
|
|
|
ENV['DEVELOPER_DIR'] = determine_developer_dir
|
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
|
2013-03-08 18:14:00 -06:00
|
|
|
ENV['PKG_CONFIG_LIBDIR'] = determine_pkg_config_libdir
|
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_CC'] = determine_cc
|
2012-08-27 08:48:02 -04:00
|
|
|
ENV['HOMEBREW_CCCFG'] = determine_cccfg
|
2013-01-02 11:08:44 -08:00
|
|
|
ENV['HOMEBREW_BREW_FILE'] = HOMEBREW_BREW_FILE
|
2013-08-09 20:47:28 -05:00
|
|
|
ENV['HOMEBREW_SDKROOT'] = "#{MacOS.sdk_path}" if MacOS::Xcode.without_clt?
|
2013-05-31 12:30:25 +02:00
|
|
|
ENV['HOMEBREW_DEVELOPER_DIR'] = determine_developer_dir # used by our xcrun shim
|
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['CMAKE_PREFIX_PATH'] = determine_cmake_prefix_path
|
2013-01-21 10:33:56 +01:00
|
|
|
ENV['CMAKE_FRAMEWORK_PATH'] = determine_cmake_frameworks_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['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
|
2013-05-27 15:17:49 -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.
|
|
|
|
#
|
|
|
|
# u - A universal build was requested
|
|
|
|
# 3 - A 32-bit build was requested
|
|
|
|
# b - Installing from a bottle
|
|
|
|
# i - Installing from a bottle on Intel
|
|
|
|
# 6 - Installing from a bottle on 64-bit Intel
|
2013-08-04 22:37:52 -07:00
|
|
|
# O - Enables argument refurbishing. Only active under the
|
|
|
|
# make/bsdmake wrappers currently.
|
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
|
|
|
|
|
2013-05-27 15:17:49 -05:00
|
|
|
# Homebrew's apple-gcc42 will be outside the PATH in superenv,
|
|
|
|
# so xcrun may not be able to find it
|
2013-07-29 18:44:34 -07:00
|
|
|
if ENV['HOMEBREW_CC'] == 'gcc-4.2'
|
2013-05-27 15:17:49 -05:00
|
|
|
apple_gcc42 = Formula.factory('apple-gcc42') rescue nil
|
|
|
|
ENV.append('PATH', apple_gcc42.opt_prefix/'bin', ':') if apple_gcc42
|
|
|
|
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
|
|
|
|
|
|
|
|
def universal_binary
|
2013-08-02 22:28:55 -07:00
|
|
|
ENV['HOMEBREW_ARCHS'] = Hardware::CPU.universal_archs.join(',')
|
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
|
|
|
append 'HOMEBREW_CCCFG', "u", ''
|
|
|
|
end
|
|
|
|
|
2013-08-01 11:36:44 -07:00
|
|
|
# m32 on superenv does not add any CC flags. It prevents "-m32" from being erased.
|
2012-12-01 19:42:22 +01:00
|
|
|
def m32
|
|
|
|
append 'HOMEBREW_CCCFG', "3", ''
|
|
|
|
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
|
|
|
private
|
|
|
|
|
|
|
|
def determine_cc
|
|
|
|
if ARGV.include? '--use-gcc'
|
2013-05-27 15:17:49 -05:00
|
|
|
gcc_installed = Formula.factory('apple-gcc42').installed? rescue false
|
2013-01-22 18:28:13 -06:00
|
|
|
# fall back to something else on systems without Apple gcc
|
2013-05-27 15:17:49 -05:00
|
|
|
if MacOS.locate('gcc-4.2') || gcc_installed
|
|
|
|
"gcc-4.2"
|
|
|
|
else
|
2013-08-06 19:24:17 -05:00
|
|
|
raise "gcc-4.2 not found!"
|
2013-05-27 15:17:49 -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
|
|
|
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']
|
2013-05-27 15:17:49 -05:00
|
|
|
when 'clang', 'gcc-4.0' then ENV['HOMEBREW_CC']
|
|
|
|
# depending on Xcode version plain 'gcc' could actually be
|
|
|
|
# gcc-4.0 or llvm-gcc
|
2013-06-02 19:40:23 -05:00
|
|
|
when 'gcc', 'gcc-4.2' then 'gcc-4.2'
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when 'llvm', 'llvm-gcc' then 'llvm-gcc'
|
|
|
|
else
|
2013-08-06 19:24:17 -05:00
|
|
|
opoo "Invalid value for HOMEBREW_CC: #{ENV['HOMEBREW_CC'].inspect}"
|
2013-08-06 19:24:18 -05:00
|
|
|
default_cc
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
else
|
2013-08-06 19:24:18 -05:00
|
|
|
default_cc
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
2013-08-06 19:24:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def default_cc
|
2013-05-27 12:54:07 -05:00
|
|
|
case MacOS.default_compiler
|
|
|
|
when :clang then 'clang'
|
|
|
|
when :llvm then 'llvm-gcc'
|
2013-05-27 15:17:49 -05:00
|
|
|
when :gcc then 'gcc-4.2'
|
2013-05-27 12:54:07 -05:00
|
|
|
when :gcc_4_0 then 'gcc-4.0'
|
|
|
|
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
|
|
|
|
|
|
|
|
def determine_path
|
2013-08-19 12:32:56 -05:00
|
|
|
paths = [Superenv.bin]
|
2013-08-09 20:47:28 -05:00
|
|
|
if MacOS::Xcode.without_clt?
|
2013-03-20 18:20:18 +01:00
|
|
|
paths << "#{MacOS::Xcode.prefix}/usr/bin"
|
|
|
|
paths << "#{MacOS::Xcode.prefix}/Toolchains/XcodeDefault.xctoolchain/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
|
2013-03-09 16:56:32 -06:00
|
|
|
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" }
|
2013-08-06 19:24:19 -05:00
|
|
|
paths << MacOS::X11.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
|
2013-03-09 16:56:32 -06:00
|
|
|
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/lib/pkgconfig" }
|
|
|
|
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/pkgconfig" }
|
2013-03-08 18:14:00 -06:00
|
|
|
paths.to_path_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_pkg_config_libdir
|
|
|
|
paths = %W{/usr/lib/pkgconfig #{HOMEBREW_REPOSITORY}/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
|
|
|
|
|
|
|
|
def determine_cmake_prefix_path
|
2013-03-09 16:56:32 -06:00
|
|
|
paths = keg_only_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
|
2013-08-09 20:47:28 -05:00
|
|
|
paths << "#{MacOS.sdk_path}/usr" if MacOS::Xcode.without_clt?
|
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
|
|
|
|
|
2013-01-21 10:33:56 +01:00
|
|
|
def determine_cmake_frameworks_path
|
|
|
|
# XXX: keg_only_deps perhaps? but Qt does not link its Frameworks because of Ruby's Find.find ignoring symlinks!!
|
|
|
|
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" }
|
2013-08-09 20:47:28 -05:00
|
|
|
paths << "#{MacOS.sdk_path}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
|
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
|
2013-08-09 20:47:28 -05:00
|
|
|
sdk = MacOS.sdk_path if MacOS::Xcode.without_clt?
|
2012-08-29 11:19:39 -04:00
|
|
|
paths = []
|
2013-08-06 19:24:19 -05:00
|
|
|
paths << "#{MacOS::X11.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'
|
2013-08-09 20:47:28 -05:00
|
|
|
paths << "#{sdk}/usr/include/apache2" if MacOS::Xcode.without_clt?
|
2012-09-13 12:10:01 -04:00
|
|
|
paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/" unless x11?
|
2013-08-06 19:24:19 -05:00
|
|
|
paths << MacOS::X11.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
|
2013-08-09 20:47:28 -05:00
|
|
|
sdk = MacOS.sdk_path if MacOS::Xcode.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?
|
2013-08-06 19:24:19 -05:00
|
|
|
paths << MacOS::X11.lib if x11?
|
2012-09-03 14:17:40 -04:00
|
|
|
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
|
2013-03-09 16:56:32 -06:00
|
|
|
paths = keg_only_deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/aclocal" }
|
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 << "#{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
|
2013-06-13 12:04:58 -05:00
|
|
|
Hardware::CPU.cores
|
2012-08-23 16:15:26 -04:00
|
|
|
else
|
|
|
|
j
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-27 08:48:02 -04:00
|
|
|
def determine_cccfg
|
|
|
|
s = ""
|
2013-05-11 12:18:25 +01:00
|
|
|
if ARGV.build_bottle?
|
|
|
|
s << if Hardware::CPU.type == :intel
|
|
|
|
if Hardware::CPU.is_64_bit?
|
|
|
|
'bi6'
|
|
|
|
else
|
|
|
|
'bi'
|
|
|
|
end
|
|
|
|
else
|
|
|
|
'b'
|
|
|
|
end
|
|
|
|
end
|
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
|
2013-06-13 17:19:27 +02:00
|
|
|
# Fix issue with >= 10.8 apr-1-config having broken paths
|
|
|
|
s << 'a' if MacOS.version >= :mountain_lion
|
2012-08-27 08:48:02 -04:00
|
|
|
s
|
|
|
|
end
|
|
|
|
|
2012-09-23 20:57:41 -04:00
|
|
|
def determine_developer_dir
|
|
|
|
# If Xcode path is fucked then this is basically a fix. In the case where
|
|
|
|
# nothing is valid, it still fixes most usage to supply a valid path that
|
|
|
|
# is not "/".
|
2013-03-20 18:20:18 +01:00
|
|
|
MacOS::Xcode.prefix || ENV['DEVELOPER_DIR']
|
2012-09-23 20:57:41 -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
|
|
|
|
|
|
|
|
### NO LONGER NECESSARY OR NO LONGER SUPPORTED
|
|
|
|
def noop(*args); end
|
2012-12-01 19:42:22 +01:00
|
|
|
%w[m64 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
|
2013-01-22 18:28:13 -06:00
|
|
|
when "gcc-4.2" then :gcc
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
when "gcc", "clang" then ENV['HOMEBREW_CC'].to_sym
|
|
|
|
else
|
2013-08-06 19:24:17 -05:00
|
|
|
raise "Invalid value for HOMEBREW_CC: #{ENV['HOMEBREW_CC'].inspect}"
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def deparallelize
|
|
|
|
delete('MAKEFLAGS')
|
|
|
|
end
|
|
|
|
alias_method :j1, :deparallelize
|
|
|
|
def gcc
|
2012-11-13 14:38:57 -08:00
|
|
|
ENV['CC'] = ENV['OBJC'] = ENV['HOMEBREW_CC'] = "gcc"
|
2013-06-27 15:13:02 -05:00
|
|
|
ENV['CXX'] = ENV['OBJCXX'] = "g++-4.2"
|
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-11-13 14:38:57 -08:00
|
|
|
ENV['CC'] = ENV['OBJC'] = ENV['HOMEBREW_CC'] = "llvm-gcc"
|
2013-06-27 15:13:02 -05:00
|
|
|
ENV['CXX'] = ENV['OBJCXX'] = "llvm-g++-4.2"
|
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-11-13 14:38:57 -08:00
|
|
|
ENV['CC'] = ENV['OBJC'] = ENV['HOMEBREW_CC'] = "clang"
|
|
|
|
ENV['CXX'] = ENV['OBJCXX'] = "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 = "")
|
2013-03-09 17:13:01 -06:00
|
|
|
attr_accessor :key
|
2012-08-31 23:44:36 -04:00
|
|
|
def + value
|
|
|
|
ENV[key] = value
|
|
|
|
end
|
|
|
|
alias_method '<<', '+'
|
|
|
|
end
|
|
|
|
a.key = key
|
|
|
|
a
|
|
|
|
end
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|