diff options
| author | Misty De Meo | 2013-03-10 19:38:36 -0500 |
|---|---|---|
| committer | Misty De Meo | 2013-06-08 19:10:42 -0500 |
| commit | 4494eb6f5b40be27bc276647e2fa8de3e49048ef (patch) | |
| tree | 3d010bb8d8492501ffc9d5f89f762965a531c526 /Library/Formula/ld64.rb | |
| parent | a0274864e29dad35461db352894e806865ab3235 (diff) | |
| download | homebrew-4494eb6f5b40be27bc276647e2fa8de3e49048ef.tar.bz2 | |
ld64 97.17
Diffstat (limited to 'Library/Formula/ld64.rb')
| -rw-r--r-- | Library/Formula/ld64.rb | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/Library/Formula/ld64.rb b/Library/Formula/ld64.rb new file mode 100644 index 000000000..0808df0da --- /dev/null +++ b/Library/Formula/ld64.rb @@ -0,0 +1,147 @@ +require 'formula' + +class Ld64 < Formula + homepage 'http://opensource.apple.com/' + # Latest is 134.9, but it no longer supports building for PPC. + # 127.2 won't build on Tiger, at least without some patching. + # Leopard users: if you like, add a 127.2 option or fix the build + # on Tiger. + # + url 'http://opensource.apple.com/tarballs/ld64/ld64-97.17.tar.gz' + sha1 '7c1d816c2fec02e558f4a528d16d8161f0e379b5' + + # Tiger either includes old versions of these headers, + # or doesn't ship them at all + depends_on 'cctools-headers' => :build + depends_on 'dyld-headers' => :build + depends_on 'libunwind-headers' => :build + + keg_only :provided_by_osx, + "ld64 is an updated version of the ld shipped by Apple." + + # NOTE: fails with gcc-4.0; add fails_with :gcc_4_0 when supported + + def patches + { + :p0 => [ + # Fixes logic on PPC branch islands + "https://trac.macports.org/export/103948/trunk/dports/devel/ld64/files/ld64-97-ppc-branch-island.patch", + # Remove LTO support + "https://trac.macports.org/export/103949/trunk/dports/devel/ld64/files/ld64-97-no-LTO.patch", + # Fix version number + "https://trac.macports.org/export/103951/trunk/dports/devel/ld64/files/ld64-version.patch" + ] + } + end + + def install + File.open('Makefile', 'w') {|f| f.write DATA.read} + inreplace 'src/ld/Options.cpp', '@@VERSION@@', version + + if MacOS.version < :leopard + # No CommonCrypto + inreplace 'src/ld/MachOWriterExecutable.hpp' do |s| + s.gsub! '<CommonCrypto/CommonDigest.h>', '<openssl/md5.h>' + s.gsub! 'CC_MD5', 'MD5' + end + + inreplace 'Makefile', "-Wl,-exported_symbol,__mh_execute_header", "" + end + + args = %W[ + CC=#{ENV.cc} + CXX=#{ENV.cxx} + OTHER_CPPFLAGS=#{ENV.cppflags} + OTHER_LDFLAGS=#{ENV.ldflags} + ] + + args << 'RC_SUPPORTED_ARCHS="armv6 armv7 i386 x86_64"' if MacOS.version >= :lion + args << "OTHER_LDFLAGS_LD64=-lcrypto" if MacOS.version < :leopard + + # Macports makefile hardcodes optimization + inreplace 'Makefile' do |s| + s.change_make_var! 'CFLAGS', ENV.cflags + s.change_make_var! 'CXXFLAGS', ENV.cxxflags + end + + system "make", *args + system "make", "install", "PREFIX=#{prefix}" + end +end + +# makefile courtesy Macports: +# https://trac.macports.org/browser/trunk/dports/devel/ld64/files/Makefile-97 +__END__ +ifdef LLVM_CONFIG +LLVM_CPPFLAGS := -I$(shell $(LLVM_CONFIG) --includedir) -DLTO_SUPPORT +LLVM_LDFLAGS := -L$(shell $(LLVM_CONFIG) --libdir) -lLTO +endif + +CPPFLAGS = $(LLVM_CPPFLAGS) -Isrc/abstraction -Isrc/ld $(OTHER_CPPFLAGS) +CFLAGS = -Os $(OTHER_CFLAGS) +CXXFLAGS = -Os $(OTHER_CXXFLAGS) +LDFLAGS = $(OTHER_LDFLAGS) + +ifndef RANLIB +RANLIB = ranlib +endif +ifndef AR +AR = ar +endif +ifndef PREFIX +PREFIX = /usr +endif + +all : src/ld/configure.h ObjectDump dyldinfo ld machocheck rebase unwinddump libprunetrie.a + +src/ld/configure.h : + touch $@ + +ObjectDump : src/ld/debugline.o +ObjectDump : src/other/ObjectDump.o + $(CXX) $(LLVM_LDFLAGS) $(LDFLAGS) $^ -o $@ + +dyldinfo : src/other/dyldinfo.o + $(CXX) $(LDFLAGS) -Wl,-exported_symbol,__mh_execute_header $^ -o $@ + +ld : src/ld/debugline.o +ld : src/ld/ld.o +ld : src/ld/Options.o + $(CXX) $(LLVM_LDFLAGS) $(LDFLAGS) $(OTHER_LDFLAGS_LD64) -Wl,-exported_symbol,__mh_execute_header $^ -o $@ + +machocheck : src/other/machochecker.o + $(CXX) $(LDFLAGS) $^ -o $@ + +rebase : src/other/rebase.o + $(CXX) $(LDFLAGS) -Wl,-exported_symbol,__mh_execute_header $^ -o $@ + +unwinddump : src/other/unwinddump.o + $(CXX) $(LDFLAGS) -Wl,-exported_symbol,__mh_execute_header $^ -o $@ + +libprunetrie.a : src/other/PruneTrie.o + $(AR) cru $@ $^ + $(RANLIB) $@ + +install : all + install -d -m 755 $(DESTDIR)$(PREFIX)/bin + install -d -m 755 $(DESTDIR)$(PREFIX)/lib + install -d -m 755 $(DESTDIR)$(PREFIX)/include/mach-o + install -d -m 755 $(DESTDIR)$(PREFIX)/share/man/man1 + + install -m 755 ObjectDump $(DESTDIR)$(PREFIX)/bin + install -m 755 dyldinfo $(DESTDIR)$(PREFIX)/bin + install -m 755 ld $(DESTDIR)$(PREFIX)/bin + install -m 755 machocheck $(DESTDIR)$(PREFIX)/bin + install -m 755 rebase $(DESTDIR)$(PREFIX)/bin + install -m 755 unwinddump $(DESTDIR)$(PREFIX)/bin + + install -m 644 src/other/prune_trie.h $(DESTDIR)$(PREFIX)/include/mach-o + install -m 644 libprunetrie.a $(DESTDIR)$(PREFIX)/lib + + install -m 644 doc/man/man1/dyldinfo.1 $(DESTDIR)$(PREFIX)/share/man/man1 + install -m 644 doc/man/man1/ld.1 $(DESTDIR)$(PREFIX)/share/man/man1 + install -m 644 doc/man/man1/ld64.1 $(DESTDIR)$(PREFIX)/share/man/man1 + install -m 644 doc/man/man1/rebase.1 $(DESTDIR)$(PREFIX)/share/man/man1 + install -m 644 doc/man/man1/unwinddump.1 $(DESTDIR)$(PREFIX)/share/man/man1 + + |
