2009-10-15 12:36:09 +01:00
|
|
|
module HomebrewEnvExtension
|
|
|
|
# -w: keep signal to noise high
|
2009-12-02 12:17:14 +00:00
|
|
|
SAFE_CFLAGS_FLAGS = "-w -pipe"
|
2009-10-15 12:36:09 +01:00
|
|
|
|
|
|
|
def setup_build_environment
|
|
|
|
# Clear CDPATH to avoid make issues that depend on changing directories
|
2010-08-10 07:58:08 -07:00
|
|
|
delete('CDPATH')
|
2012-02-16 17:12:53 +00:00
|
|
|
delete('GREP_OPTIONS') # can break CMake (lol)
|
2012-02-16 16:55:28 -06:00
|
|
|
delete('CLICOLOR_FORCE') # autotools doesn't like this
|
2012-02-16 23:39:57 +00:00
|
|
|
remove_cc_etc
|
2009-10-15 12:36:09 +01:00
|
|
|
|
2012-07-28 20:02:33 -03:00
|
|
|
if MacOS.mountain_lion?
|
2012-08-02 16:52:33 +01:00
|
|
|
# Fix issue with sed barfing on unicode characters on Mountain Lion.
|
|
|
|
delete('LC_ALL')
|
|
|
|
self['LANG']="C"
|
|
|
|
|
|
|
|
# Mountain Lion no longer ships a few .pcs; make sure we pick up our versions
|
2012-07-28 20:02:33 -03:00
|
|
|
prepend 'PKG_CONFIG_PATH',
|
|
|
|
HOMEBREW_REPOSITORY/'Library/Homebrew/pkgconfig', ':'
|
|
|
|
end
|
|
|
|
|
2012-02-27 04:06:13 +00:00
|
|
|
# make any aclocal stuff installed in Homebrew available
|
2012-07-10 20:25:16 -05:00
|
|
|
self['ACLOCAL_PATH'] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS::Xcode.provides_autotools?
|
2012-02-27 04:06:13 +00:00
|
|
|
|
2011-07-26 00:01:22 -05:00
|
|
|
self['MAKEFLAGS'] = "-j#{self.make_jobs}"
|
2009-10-15 12:36:09 +01:00
|
|
|
|
|
|
|
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
2009-12-01 11:27:44 +00:00
|
|
|
# /usr/local is already an -isystem and -L directory so we skip it
|
2010-08-10 07:58:08 -07:00
|
|
|
self['CPPFLAGS'] = "-isystem #{HOMEBREW_PREFIX}/include"
|
|
|
|
self['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
|
2009-12-09 04:49:19 +01:00
|
|
|
# CMake ignores the variables above
|
2010-08-10 07:58:08 -07:00
|
|
|
self['CMAKE_PREFIX_PATH'] = "#{HOMEBREW_PREFIX}"
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
|
|
|
|
2012-02-16 17:23:11 +00:00
|
|
|
# Os is the default Apple uses for all its stuff so let's trust them
|
2012-02-20 13:16:58 -08:00
|
|
|
set_cflags "-Os #{SAFE_CFLAGS_FLAGS}"
|
2010-02-12 13:35:29 +00:00
|
|
|
|
2012-02-16 18:00:04 +00:00
|
|
|
# set us up for the user's compiler choice
|
2011-11-23 19:52:00 +00:00
|
|
|
self.send self.compiler
|
2012-02-16 18:00:04 +00:00
|
|
|
|
2011-08-31 17:50:39 +01:00
|
|
|
# we must have a working compiler!
|
2012-03-21 11:58:32 -05:00
|
|
|
unless self['CC']
|
2011-11-23 19:52:00 +00:00
|
|
|
@compiler = MacOS.default_compiler
|
|
|
|
self.send @compiler
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CC'] = MacOS.locate("cc")
|
|
|
|
self['CXX'] = MacOS.locate("c++")
|
2012-03-21 11:58:32 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2011-09-06 11:20:09 +01:00
|
|
|
end
|
2011-08-31 17:50:39 +01:00
|
|
|
|
2010-08-09 21:03:29 -07:00
|
|
|
# In rare cases this may break your builds, as the tool for some reason wants
|
|
|
|
# to use a specific linker. However doing this in general causes formula to
|
2009-10-15 12:36:09 +01:00
|
|
|
# build more successfully because we are changing CC and many build systems
|
2010-08-09 21:03:29 -07:00
|
|
|
# don't react properly to that.
|
2010-08-10 07:58:08 -07:00
|
|
|
self['LD'] = self['CC']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
|
|
|
|
# Add lib and include etc. from the current macosxsdk to compiler flags:
|
|
|
|
macosxsdk MacOS.version
|
|
|
|
|
|
|
|
# For Xcode 4.3 (*without* the "Command Line Tools for Xcode") compiler and tools inside of Xcode:
|
2012-07-09 14:58:34 -05:00
|
|
|
if not MacOS::CLT.installed? and MacOS::Xcode.installed? and MacOS::Xcode.version >= "4.3"
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
# Some tools (clang, etc.) are in the xctoolchain dir of Xcode
|
|
|
|
append 'PATH', "#{MacOS.xctoolchain_path}/usr/bin", ":" if MacOS.xctoolchain_path
|
|
|
|
# Others are now at /Applications/Xcode.app/Contents/Developer/usr/bin
|
|
|
|
append 'PATH', "#{MacOS.dev_tools_path}", ":"
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2010-08-09 21:03:29 -07:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def deparallelize
|
|
|
|
remove 'MAKEFLAGS', /-j\d+/
|
|
|
|
end
|
|
|
|
alias_method :j1, :deparallelize
|
2009-10-23 14:51:40 +01:00
|
|
|
|
2010-02-12 13:35:29 +00:00
|
|
|
# recommended by Apple, but, eg. wget won't compile with this flag, so…
|
|
|
|
def fast
|
2010-10-25 21:12:41 -07:00
|
|
|
remove_from_cflags(/-O./)
|
2010-02-12 13:35:29 +00:00
|
|
|
append_to_cflags '-fast'
|
|
|
|
end
|
2010-06-18 14:32:25 -07:00
|
|
|
def O4
|
|
|
|
# LLVM link-time optimization
|
2010-10-25 21:12:41 -07:00
|
|
|
remove_from_cflags(/-O./)
|
2010-06-18 14:32:25 -07:00
|
|
|
append_to_cflags '-O4'
|
|
|
|
end
|
2009-10-23 14:51:40 +01:00
|
|
|
def O3
|
|
|
|
# Sometimes O4 just takes fucking forever
|
2010-10-25 21:12:41 -07:00
|
|
|
remove_from_cflags(/-O./)
|
2009-10-23 14:51:40 +01:00
|
|
|
append_to_cflags '-O3'
|
|
|
|
end
|
|
|
|
def O2
|
|
|
|
# Sometimes O3 doesn't work or produces bad binaries
|
2010-10-25 21:12:41 -07:00
|
|
|
remove_from_cflags(/-O./)
|
2009-10-23 14:51:40 +01:00
|
|
|
append_to_cflags '-O2'
|
|
|
|
end
|
2009-12-02 12:17:14 +00:00
|
|
|
def Os
|
|
|
|
# Sometimes you just want a small one
|
2010-10-25 21:12:41 -07:00
|
|
|
remove_from_cflags(/-O./)
|
2009-12-02 12:17:14 +00:00
|
|
|
append_to_cflags '-Os'
|
|
|
|
end
|
2011-05-24 18:15:05 -07:00
|
|
|
def Og
|
|
|
|
# Sometimes you want a debug build
|
|
|
|
remove_from_cflags(/-O./)
|
|
|
|
append_to_cflags '-g -O0'
|
|
|
|
end
|
2012-02-06 21:54:02 -06:00
|
|
|
def O1
|
|
|
|
# Sometimes even O2 doesn't work :(
|
|
|
|
remove_from_cflags(/-O./)
|
|
|
|
append_to_cflags '-O1'
|
|
|
|
end
|
2009-10-23 14:51:40 +01:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def gcc_4_0_1
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
# we don't use locate because gcc 4.0 has not been provided since Xcode 4
|
2012-03-21 12:01:19 -05:00
|
|
|
self['CC'] = "#{MacOS.dev_tools_path}/gcc-4.0"
|
|
|
|
self['LD'] = self['CC']
|
2012-02-16 18:00:04 +00:00
|
|
|
self['CXX'] = "#{MacOS.dev_tools_path}/g++-4.0"
|
2012-03-16 16:27:35 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2011-11-23 19:52:00 +00:00
|
|
|
replace_in_cflags '-O4', '-O3'
|
2011-12-31 19:10:05 +00:00
|
|
|
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
2011-09-06 11:20:09 +01:00
|
|
|
@compiler = :gcc
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2009-12-02 10:39:06 +00:00
|
|
|
alias_method :gcc_4_0, :gcc_4_0_1
|
|
|
|
|
2012-02-16 23:39:57 +00:00
|
|
|
# if your formula doesn't like CC having spaces use this
|
|
|
|
def expand_xcrun
|
2012-03-21 11:58:32 -05:00
|
|
|
self['CC'] =~ %r{/usr/bin/xcrun (.*)}
|
|
|
|
self['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
|
|
|
|
self['CXX'] =~ %r{/usr/bin/xcrun (.*)}
|
|
|
|
self['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
|
2012-03-21 12:01:19 -05:00
|
|
|
self['LD'] = self['CC']
|
2012-03-21 11:58:32 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2012-02-16 23:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-02-21 00:17:19 -06:00
|
|
|
def gcc
|
2012-02-16 18:00:04 +00:00
|
|
|
# Apple stopped shipping gcc-4.2 with Xcode 4.2
|
|
|
|
# However they still provide a gcc symlink to llvm
|
|
|
|
# But we don't want LLVM of course.
|
|
|
|
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CC'] = MacOS.locate "gcc-4.2"
|
2012-03-21 12:01:19 -05:00
|
|
|
self['LD'] = self['CC']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CXX'] = MacOS.locate "g++-4.2"
|
2012-03-21 11:58:32 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2012-02-16 23:39:57 +00:00
|
|
|
|
2012-03-21 11:58:32 -05:00
|
|
|
unless self['CC']
|
|
|
|
self['CC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.2"
|
2012-03-21 12:01:19 -05:00
|
|
|
self['LD'] = self['CC']
|
2012-03-21 11:58:32 -05:00
|
|
|
self['CXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.2"
|
|
|
|
self['OBJC'] = self['CC']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
raise "GCC could not be found" unless File.exist? self['CC']
|
2012-02-16 23:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-03-21 11:58:32 -05:00
|
|
|
if not self['CC'] =~ %r{^/usr/bin/xcrun }
|
|
|
|
raise "GCC could not be found" if Pathname.new(self['CC']).realpath.to_s =~ /llvm/
|
2012-02-16 23:39:57 +00:00
|
|
|
end
|
|
|
|
|
2011-11-23 19:52:00 +00:00
|
|
|
replace_in_cflags '-O4', '-O3'
|
2011-12-31 19:10:05 +00:00
|
|
|
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic'
|
2011-09-06 11:20:09 +01:00
|
|
|
@compiler = :gcc
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2011-08-26 13:53:36 +01:00
|
|
|
alias_method :gcc_4_2, :gcc
|
2009-10-23 14:51:40 +01:00
|
|
|
|
2010-06-17 10:57:41 -05:00
|
|
|
def llvm
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CC'] = MacOS.locate "llvm-gcc"
|
2012-03-21 12:01:19 -05:00
|
|
|
self['LD'] = self['CC']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CXX'] = MacOS.locate "llvm-g++"
|
2012-03-16 16:27:35 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2011-11-23 19:52:00 +00:00
|
|
|
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
2011-09-06 11:20:09 +01:00
|
|
|
@compiler = :llvm
|
2011-08-26 13:53:36 +01:00
|
|
|
end
|
|
|
|
|
2012-02-21 00:17:19 -06:00
|
|
|
def clang
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CC'] = MacOS.locate "clang"
|
2012-03-21 12:01:19 -05:00
|
|
|
self['LD'] = self['CC']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['CXX'] = MacOS.locate "clang++"
|
2012-03-16 16:27:35 -05:00
|
|
|
self['OBJC'] = self['CC']
|
2011-11-23 19:52:00 +00:00
|
|
|
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
|
|
|
# Clang mistakenly enables AES-NI on plain Nehalem
|
|
|
|
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
2012-02-18 12:25:23 -06:00
|
|
|
append_to_cflags '-Qunused-arguments'
|
2011-09-06 11:20:09 +01:00
|
|
|
@compiler = :clang
|
2010-06-17 10:57:41 -05:00
|
|
|
end
|
|
|
|
|
2011-03-10 11:23:42 -08:00
|
|
|
def fortran
|
|
|
|
if self['FC']
|
|
|
|
ohai "Building with an alternative Fortran compiler. This is unsupported."
|
|
|
|
self['F77'] = self['FC'] unless self['F77']
|
|
|
|
|
|
|
|
if ARGV.include? '--default-fortran-flags'
|
2012-03-07 18:38:04 -08:00
|
|
|
flags_to_set = []
|
|
|
|
flags_to_set << 'FCFLAGS' unless self['FCFLAGS']
|
|
|
|
flags_to_set << 'FFLAGS' unless self['FFLAGS']
|
|
|
|
|
|
|
|
flags_to_set.each {|key| self[key] = cflags}
|
|
|
|
|
|
|
|
# Ensure we use architecture optimizations for GCC 4.2.x
|
|
|
|
set_cpu_flags flags_to_set, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic'
|
2011-03-10 11:23:42 -08:00
|
|
|
elsif not self['FCFLAGS'] or self['FFLAGS']
|
2012-02-16 17:23:25 +00:00
|
|
|
opoo <<-EOS.undent
|
|
|
|
No Fortran optimization information was provided. You may want to consider
|
|
|
|
setting FCFLAGS and FFLAGS or pass the `--default-fortran-flags` option to
|
|
|
|
`brew install` if your compiler is compatible with GCC.
|
2011-03-10 11:23:42 -08:00
|
|
|
|
2012-02-16 17:23:25 +00:00
|
|
|
If you like the default optimization level of your compiler, ignore this
|
|
|
|
warning.
|
2011-03-10 11:23:42 -08:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
elsif `/usr/bin/which gfortran`.chomp.size > 0
|
2012-02-16 17:23:25 +00:00
|
|
|
ohai <<-EOS.undent
|
|
|
|
Using Homebrew-provided fortran compiler.
|
|
|
|
This may be changed by setting the FC environment variable.
|
|
|
|
EOS
|
2011-03-10 11:23:42 -08:00
|
|
|
self['FC'] = `/usr/bin/which gfortran`.chomp
|
|
|
|
self['F77'] = self['FC']
|
|
|
|
|
2012-03-07 18:38:04 -08:00
|
|
|
fc_flag_vars.each {|key| self[key] = cflags}
|
|
|
|
# Ensure we use architecture optimizations for GCC 4.2.x
|
|
|
|
set_cpu_flags fc_flag_vars, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic'
|
2011-03-10 11:23:42 -08:00
|
|
|
|
|
|
|
else
|
|
|
|
onoe <<-EOS
|
|
|
|
This formula requires a fortran compiler, but we could not find one by
|
|
|
|
looking at the FC environment variable or searching your PATH for `gfortran`.
|
|
|
|
Please take one of the following actions:
|
|
|
|
|
|
|
|
- Decide to use the build of gfortran 4.2.x provided by Homebrew using
|
|
|
|
`brew install gfortran`
|
|
|
|
|
|
|
|
- Choose another Fortran compiler by setting the FC environment variable:
|
|
|
|
export FC=/path/to/some/fortran/compiler
|
|
|
|
Using an alternative compiler may produce more efficient code, but we will
|
|
|
|
not be able to provide support for build errors.
|
|
|
|
EOS
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
def remove_macosxsdk v=MacOS.version
|
|
|
|
# Clear all lib and include dirs from CFLAGS, CPPFLAGS, LDFLAGS that were
|
|
|
|
# previously added by macosxsdk
|
|
|
|
v = v.to_s
|
2009-10-15 12:36:09 +01:00
|
|
|
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['MACOSX_DEPLOYMENT_TARGET'] = nil
|
|
|
|
remove 'CPPFLAGS', "-isystem #{HOMEBREW_PREFIX}/include"
|
|
|
|
remove 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
|
|
|
|
sdk = MacOS.sdk_path(v)
|
2012-07-09 14:58:34 -05:00
|
|
|
unless sdk.nil? or MacOS::CLT.installed?
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
self['SDKROOT'] = nil
|
|
|
|
remove 'CPPFLAGS', "-isysroot #{sdk}"
|
|
|
|
remove 'CPPFLAGS', "-isystem #{sdk}/usr/include"
|
|
|
|
remove 'CPPFLAGS', "-I#{sdk}/usr/include"
|
|
|
|
remove_from_cflags "-isystem #{sdk}/usr/include"
|
|
|
|
remove_from_cflags "-isysroot #{sdk}"
|
|
|
|
remove_from_cflags "-I#{sdk}/usr/include"
|
|
|
|
remove 'LDFLAGS', "-L#{sdk}/usr/lib"
|
|
|
|
remove 'LDFLAGS', "-I#{sdk}/usr/include"
|
|
|
|
if HOMEBREW_PREFIX.to_s == '/usr/local'
|
|
|
|
self['CMAKE_PREFIX_PATH'] = nil
|
|
|
|
else
|
|
|
|
# It was set in setup_build_environment, so we have to restore it here.
|
|
|
|
self['CMAKE_PREFIX_PATH'] = "#{HOMEBREW_PREFIX}"
|
|
|
|
end
|
|
|
|
remove 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks"
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
|
|
|
|
def macosxsdk v=MacOS.version
|
|
|
|
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
|
|
|
|
remove_macosxsdk
|
|
|
|
# Allow cool style of ENV.macosxsdk 10.8 here (no "" :)
|
|
|
|
v = v.to_s
|
|
|
|
append_to_cflags("-mmacosx-version-min=#{v}")
|
|
|
|
self['MACOSX_DEPLOYMENT_TARGET'] = v
|
|
|
|
append 'CPPFLAGS', "-isystem #{HOMEBREW_PREFIX}/include"
|
|
|
|
prepend 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
|
|
|
|
sdk = MacOS.sdk_path(v)
|
2012-07-09 14:58:34 -05:00
|
|
|
unless sdk.nil? or MacOS::CLT.installed?
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
# Extra setup to support Xcode 4.3+ without CLT.
|
|
|
|
self['SDKROOT'] = sdk
|
|
|
|
# Teach the preprocessor and compiler (some don't respect CPPFLAGS)
|
|
|
|
# where system includes are:
|
|
|
|
append 'CPPFLAGS', "-isysroot #{sdk}"
|
|
|
|
append_to_cflags "-isysroot #{sdk}"
|
|
|
|
append 'CPPFLAGS', "-isystem #{sdk}/usr/include"
|
|
|
|
# Suggested by mxcl (https://github.com/mxcl/homebrew/pull/10510#issuecomment-4187996):
|
|
|
|
append_to_cflags "-isystem #{sdk}/usr/include"
|
|
|
|
# Some software needs this (e.g. python shows error: /usr/include/zlib.h: No such file or directory)
|
|
|
|
append 'CPPFLAGS', "-I#{sdk}/usr/include"
|
|
|
|
# And finally the "normal" things one expects for the CFLAGS and LDFLAGS:
|
|
|
|
append_to_cflags "-I#{sdk}/usr/include"
|
2012-07-07 15:10:01 +02:00
|
|
|
append 'LDFLAGS', "-L#{sdk}/usr/lib"
|
|
|
|
# Believe it or not, sometimes only the LDFLAGS are used :/
|
|
|
|
append 'LDFLAGS', "-I#{sdk}/usr/include"
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
# Needed to build cmake itself and perhaps some cmake projects:
|
|
|
|
append 'CMAKE_PREFIX_PATH', "#{sdk}/usr", ':'
|
|
|
|
append 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks", ':'
|
|
|
|
end
|
2009-10-23 14:51:40 +01:00
|
|
|
end
|
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def minimal_optimization
|
2010-08-10 07:58:08 -07:00
|
|
|
self['CFLAGS'] = self['CXXFLAGS'] = "-Os #{SAFE_CFLAGS_FLAGS}"
|
2012-07-09 14:58:34 -05:00
|
|
|
macosxsdk unless MacOS::CLT.installed?
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
|
|
|
def no_optimization
|
2010-08-10 07:58:08 -07:00
|
|
|
self['CFLAGS'] = self['CXXFLAGS'] = SAFE_CFLAGS_FLAGS
|
2012-07-09 14:58:34 -05:00
|
|
|
macosxsdk unless MacOS::CLT.installed?
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2009-12-02 12:17:14 +00:00
|
|
|
|
2011-03-14 13:58:30 -07:00
|
|
|
# Some configure scripts won't find libxml2 without help
|
2009-10-15 12:36:09 +01:00
|
|
|
def libxml2
|
2012-07-09 14:58:34 -05:00
|
|
|
if MacOS::CLT.installed?
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
append 'CPPFLAGS', '-I/usr/include/libxml2'
|
|
|
|
else
|
|
|
|
# Use the includes form the sdk
|
|
|
|
append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/include/libxml2"
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2010-08-07 16:50:45 -07:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def x11
|
2012-07-25 15:04:46 -05:00
|
|
|
unless MacOS::XQuartz.installed?
|
|
|
|
opoo "You do not have X11 installed, this formula may not build."
|
|
|
|
end
|
2012-06-05 22:21:15 +02:00
|
|
|
|
2012-07-25 15:04:46 -05:00
|
|
|
# There are some config scripts here that should go in the PATH
|
|
|
|
prepend 'PATH', MacOS::XQuartz.bin, ':'
|
2012-06-05 22:21:15 +02:00
|
|
|
|
2012-07-25 15:04:46 -05:00
|
|
|
prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.lib/'pkgconfig', ':'
|
|
|
|
prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.share/'pkgconfig', ':'
|
2012-06-05 22:21:15 +02:00
|
|
|
|
2012-07-25 15:04:46 -05:00
|
|
|
append 'LDFLAGS', "-L#{MacOS::XQuartz.lib}"
|
|
|
|
append 'CMAKE_PREFIX_PATH', MacOS::XQuartz.prefix, ':'
|
|
|
|
append 'CMAKE_INCLUDE_PATH', MacOS::XQuartz.include, ':'
|
2012-06-05 22:21:15 +02:00
|
|
|
|
2012-07-25 15:04:46 -05:00
|
|
|
append 'CPPFLAGS', "-I#{MacOS::XQuartz.include}"
|
2012-06-05 22:21:15 +02:00
|
|
|
|
2012-07-09 14:58:34 -05:00
|
|
|
unless MacOS::CLT.installed?
|
2012-07-25 15:04:46 -05:00
|
|
|
append 'CMAKE_PREFIX_PATH', MacOS.sdk_path/'usr/X11', ':'
|
|
|
|
append 'CPPFLAGS', "-I#{MacOS::XQuartz.include}/freetype2"
|
|
|
|
append 'CFLAGS', "-I#{MacOS::XQuartz.include}"
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
|
|
|
alias_method :libpng, :x11
|
2010-08-07 16:50:45 -07:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
# we've seen some packages fail to build when warnings are disabled!
|
|
|
|
def enable_warnings
|
|
|
|
remove_from_cflags '-w'
|
2012-02-21 00:38:57 -06:00
|
|
|
remove_from_cflags '-Qunused-arguments'
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2010-08-10 08:01:06 -07:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
# Snow Leopard defines an NCURSES value the opposite of most distros
|
|
|
|
# See: http://bugs.python.org/issue6848
|
|
|
|
def ncurses_define
|
|
|
|
append 'CPPFLAGS', "-DNCURSES_OPAQUE=0"
|
|
|
|
end
|
2010-08-10 08:01:06 -07:00
|
|
|
|
2010-09-07 10:09:22 -07:00
|
|
|
# Shortcuts for reading common flags
|
|
|
|
def cc; self['CC'] or "gcc"; end
|
|
|
|
def cxx; self['CXX'] or "g++"; end
|
|
|
|
def cflags; self['CFLAGS']; end
|
2012-02-12 17:29:02 -06:00
|
|
|
def cxxflags;self['CXXFLAGS']; end
|
2012-02-16 17:23:25 +00:00
|
|
|
def cppflags;self['CPPFLAGS']; end
|
2010-09-07 10:09:22 -07:00
|
|
|
def ldflags; self['LDFLAGS']; end
|
2009-10-23 14:51:50 +01:00
|
|
|
|
2012-03-07 17:56:56 -08:00
|
|
|
# Shortcuts for lists of common flags
|
|
|
|
def cc_flag_vars
|
|
|
|
%w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
|
|
|
|
end
|
2012-03-07 18:38:04 -08:00
|
|
|
def fc_flag_vars
|
|
|
|
%w{FCFLAGS FFLAGS}
|
|
|
|
end
|
2012-03-07 17:56:56 -08:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def m64
|
|
|
|
append_to_cflags '-m64'
|
2010-08-10 07:58:08 -07:00
|
|
|
append 'LDFLAGS', '-arch x86_64'
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2009-10-23 14:51:50 +01:00
|
|
|
def m32
|
|
|
|
append_to_cflags '-m32'
|
2010-08-10 07:58:08 -07:00
|
|
|
append 'LDFLAGS', '-arch i386'
|
2009-10-23 14:51:50 +01:00
|
|
|
end
|
|
|
|
|
2011-06-04 09:05:52 -07:00
|
|
|
# i386 and x86_64 (no PPC)
|
2009-10-19 12:44:30 +01:00
|
|
|
def universal_binary
|
|
|
|
append_to_cflags '-arch i386 -arch x86_64'
|
2011-11-23 19:52:00 +00:00
|
|
|
replace_in_cflags '-O4', '-O3' # O4 seems to cause the build to fail
|
2010-08-10 07:58:08 -07:00
|
|
|
append 'LDFLAGS', '-arch i386 -arch x86_64'
|
2010-04-22 11:15:03 -07:00
|
|
|
|
2011-11-23 19:52:00 +00:00
|
|
|
unless compiler == :clang
|
|
|
|
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
|
|
|
|
replace_in_cflags(/-march=\S*/, '-Xarch_i386 \0') if Hardware.is_32_bit?
|
|
|
|
end
|
2009-10-19 12:44:30 +01:00
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
|
|
|
|
def prepend key, value, separator = ' '
|
2010-09-30 10:17:41 -07:00
|
|
|
# Value should be a string, but if it is a pathname then coerce it.
|
|
|
|
value = value.to_s
|
2012-03-07 17:56:56 -08:00
|
|
|
|
|
|
|
[*key].each do |key|
|
|
|
|
unless self[key].to_s.empty?
|
|
|
|
self[key] = value + separator + self[key]
|
|
|
|
else
|
|
|
|
self[key] = value
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
|
|
|
end
|
2010-09-30 10:17:41 -07:00
|
|
|
|
2009-10-21 11:50:37 -07:00
|
|
|
def append key, value, separator = ' '
|
2010-09-30 10:17:41 -07:00
|
|
|
# Value should be a string, but if it is a pathname then coerce it.
|
|
|
|
value = value.to_s
|
2012-03-07 17:56:56 -08:00
|
|
|
|
|
|
|
[*key].each do |key|
|
|
|
|
unless self[key].to_s.empty?
|
|
|
|
self[key] = self[key] + separator + value
|
|
|
|
else
|
|
|
|
self[key] = value
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
|
|
|
end
|
2010-08-10 07:58:08 -07:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def append_to_cflags f
|
2012-03-07 17:56:56 -08:00
|
|
|
append cc_flag_vars, f
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2011-11-23 19:52:00 +00:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def remove key, value
|
2012-03-07 17:56:56 -08:00
|
|
|
[*key].each do |key|
|
|
|
|
next if self[key].nil?
|
|
|
|
self[key] = self[key].sub value, '' # can't use sub! on ENV
|
|
|
|
self[key] = nil if self[key].empty? # keep things clean
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2011-11-23 19:52:00 +00:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
def remove_from_cflags f
|
2012-03-07 17:56:56 -08:00
|
|
|
remove cc_flag_vars, f
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|
2011-06-16 20:55:59 -07:00
|
|
|
|
2011-11-23 19:52:00 +00:00
|
|
|
def replace_in_cflags before, after
|
2012-03-07 17:56:56 -08:00
|
|
|
cc_flag_vars.each do |key|
|
2011-11-23 19:52:00 +00:00
|
|
|
self[key] = self[key].sub before, after if self[key]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-02-20 13:16:58 -08:00
|
|
|
# Convenience method to set all C compiler flags in one shot.
|
|
|
|
def set_cflags f
|
2012-03-07 17:56:56 -08:00
|
|
|
cc_flag_vars.each do |key|
|
2012-02-20 13:16:58 -08:00
|
|
|
self[key] = f
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-07 18:33:32 -08:00
|
|
|
# Sets architecture-specific flags for every environment variable
|
|
|
|
# given in the list `flags`.
|
|
|
|
def set_cpu_flags flags, default, map = {}
|
2011-11-23 19:52:00 +00:00
|
|
|
cflags =~ %r{(-Xarch_i386 )-march=}
|
|
|
|
xarch = $1.to_s
|
2012-03-07 18:33:32 -08:00
|
|
|
remove flags, %r{(-Xarch_i386 )?-march=\S*}
|
|
|
|
remove flags, %r{( -Xclang \S+)+}
|
|
|
|
remove flags, %r{-mssse3}
|
|
|
|
remove flags, %r{-msse4(\.\d)?}
|
|
|
|
append flags, xarch unless xarch.empty?
|
2012-02-21 00:13:07 -06:00
|
|
|
|
2011-12-31 19:10:05 +00:00
|
|
|
if ARGV.build_bottle?
|
2012-03-07 18:33:32 -08:00
|
|
|
append flags, '-mtune=' + map.fetch(:bottle) if map.has_key? :bottle
|
2011-12-31 19:10:05 +00:00
|
|
|
else
|
2012-02-21 00:13:07 -06:00
|
|
|
# Don't set -msse3 and older flags because -march does that for us
|
2012-03-07 18:33:32 -08:00
|
|
|
append flags, '-march=' + map.fetch(Hardware.intel_family, default)
|
2011-12-31 19:10:05 +00:00
|
|
|
end
|
2012-02-18 12:25:23 -06:00
|
|
|
|
|
|
|
# not really a 'CPU' cflag, but is only used with clang
|
2012-03-07 18:33:32 -08:00
|
|
|
remove flags, '-Qunused-arguments'
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_cpu_cflags default, map = {}
|
|
|
|
set_cpu_flags cc_flag_vars, default, map
|
2011-11-23 19:52:00 +00:00
|
|
|
end
|
|
|
|
|
2011-09-06 11:20:09 +01:00
|
|
|
# actually c-compiler, so cc would be a better name
|
2011-08-26 14:21:37 +01:00
|
|
|
def compiler
|
|
|
|
# TODO seems that ENV.clang in a Formula.install should warn when called
|
|
|
|
# if the user has set something that is tested here
|
|
|
|
|
|
|
|
# test for --flags first so that installs can be overridden on a per
|
2011-09-01 14:17:29 +01:00
|
|
|
# install basis. Then test for ENVs in inverse order to flags, this is
|
|
|
|
# sensible, trust me
|
2011-09-06 11:20:09 +01:00
|
|
|
@compiler ||= if ARGV.include? '--use-gcc'
|
2011-08-26 14:21:37 +01:00
|
|
|
:gcc
|
|
|
|
elsif ARGV.include? '--use-llvm'
|
|
|
|
:llvm
|
|
|
|
elsif ARGV.include? '--use-clang'
|
|
|
|
:clang
|
2011-09-01 14:17:29 +01:00
|
|
|
elsif self['HOMEBREW_USE_CLANG']
|
2011-08-26 14:21:37 +01:00
|
|
|
:clang
|
|
|
|
elsif self['HOMEBREW_USE_LLVM']
|
|
|
|
:llvm
|
|
|
|
elsif self['HOMEBREW_USE_GCC']
|
|
|
|
:gcc
|
|
|
|
else
|
2011-08-31 16:59:04 +01:00
|
|
|
MacOS.default_compiler
|
2011-08-26 14:21:37 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-26 00:01:22 -05:00
|
|
|
def make_jobs
|
|
|
|
# '-j' requires a positive integral argument
|
|
|
|
if self['HOMEBREW_MAKE_JOBS'].to_i > 0
|
2012-05-03 15:49:27 -07:00
|
|
|
self['HOMEBREW_MAKE_JOBS'].to_i
|
2011-07-26 00:01:22 -05:00
|
|
|
else
|
|
|
|
Hardware.processor_count
|
|
|
|
end
|
|
|
|
end
|
2011-09-10 11:24:29 +01:00
|
|
|
|
|
|
|
def remove_cc_etc
|
2012-02-20 13:16:58 -08:00
|
|
|
keys = %w{CC CXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
|
2012-03-21 11:58:32 -05:00
|
|
|
removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
|
2011-09-10 11:24:29 +01:00
|
|
|
keys.each do |key|
|
2012-03-21 11:58:32 -05:00
|
|
|
self[key] = nil
|
2011-09-10 11:24:29 +01:00
|
|
|
end
|
|
|
|
removed
|
|
|
|
end
|
2009-10-15 12:36:09 +01:00
|
|
|
end
|