Re: Macirssi build problem - ugly source

John Labovitz <[email protected]> Sun, 13 Aug 2006 12:21:42 -0700
Newsgroups gmane.os.opendarwin.darwinports
Message-ID <[email protected]>
On Aug 13, 2006, at 12:01pm, Mark Duling wrote:

> Just to see how hard it would be I grabbed the latest source and  
> tried to
> update the portfile to use it.  The developers have hardcoded Fink
> dependencies in it.  So I reinplaced all the /sw's with ${prefix} and
> things went great until then it hit hardcoded /sw paths in the .dylib
> files!  What a piece of work that is.  Just out of curiosity, is  
> there a
> Unix utility that can replace in a binary file without damaging it?

Actually, it might be easier.  There's a tool called  
"install_name_tool" that might do what you're trying to do.  From its  
man page:

        Install_name_tool  changes  the  dynamic  shared  library  
install names
        recorded in a Mach-O binary.  For this tool to work  when   
the  install
        names  are  larger  the  binary should be built with the ld 
(1) -header-
        pad_max_install_names option.

I used this recently in a project to embed libraries built with  
DarwinPorts into the Frameworks directory of an application bundle.   
It worked great.  I think you should be able to do something like:

	install_name_tool -change /sw/lib/libfoo.1.dylib /opt/local/lib/ 
libfoo.1.dylib  appfile

...where appfile is the executable file in the bundle at Contents/ 
MacOS/<appname>, and "libfoo" is the library for which you need to  
change the reference.

--John