mxcl/homebrew — Issue #9535: Compiler location
Author: jacknagel
Created: 2012-01-11 04:27:23+00:00
State: open

Related: #6852, #9179, #9524

I think this is a separate issue from "compiler selection" (i.e. `fails_with`), and probably deserves priority at this point.

We're getting close to the XCode 4.3 release, and it removes the option to install the UNIX tools to /usr/bin. Here is a list of where things are located: https://gist.github.com/1591451 We'll need to deal with this without having to tell users to "add such and such directories to your PATH", so...

There are wrappers installed to /usr/bin (see https://gist.github.com/1592925) for `xcodebuild` and `xcrun`. So far MacPorts has done [this](https://svn.macports.org/changeset/88541/) to aid in locating things. We could certainly do this, maybe something along the lines of

```ruby
def find_developer_tool name
case name
when "gcc-4.0", "gcc-4.2"
# look in /usr/bin (and /usr/local/bin for gcc-4.2) first,
# then shell out to `xcrun` if necessary
else Pathname.new(`xcrun -find #{name}`.chomp)
end
end
```

possibly special casing some other tools if we want to look in other places first. We would need to utilize this to find these tools/symlinks to tools:

```
cc
clang
llvm-gcc
install_name_tool
otool
strip
make
# others?
```

An alternative approach might be to add something like HOMEBREW_PATH which gets set up at runtime, and then implement `find_developer_tool` as a wrapper around which, e.g.

```ruby
def find_developer_tool name
path = `PATH=#{HOMEBREW_PATH} which #{name}`.chomp
Pathname.new(path)
end
```

or something like that (and is probably faster than the `xcrun` wrapper). This would also be gentler to users of the osx-gcc-installer.

Further, XCode 4.3 no longer contains autotools. We might have to bite the bullet here and allow in keg-only builds of these things, declaring them as build-time deps of the formulae that require them (on systems with XCode 4.3, of course).

Thoughts?