While trying to build pugs with readline support, I've had to battle a neutered readline library, a readline that doesn't come with certain functions which pugs (and ghc) expect. I had previously installed readline 5.1 in /usr/local, but apparently ghc still linked to the libreadline in /usr, even after my having set $LDFLAGS to -L/usr/local/include. Therefore, I decided to do something a little more drastic: overwrite the libreadline.dylib in /usr/lib.
Now I've heard over and over again that you don't want to mess with /usr and that you should always use /usr/local. However, it didn't seem like other workarounds were working. So I decided to cream my /usr/lib version of libreadline and install the same version and minor version of of readline from GNU (after making a backup of my original libreadline.dylib and include/readline.h, of course). Fortunately, it wasn't too hard. I did curl -f http://ftp.gnu.org/gnu/readline/readline-5.0.tar.gz | tar xvz, cd readline-5.0; make; sudo make install
. However, there was one small hitch. The make process gave this error message:
gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061) powerpc-apple-darwin8-gcc-4.0.0: -compatibility_version only allowed with -dynamiclibThe reason for the error is that GNU readline's default flags for building shared libraries is wrong for my version of OS X. Fortunately, some quick google'ing turned up this, telling me that I had to edit shlib/Makefile to have SHOBJ_LDFLAGS=-dynamiclib. After that was changed,
make
ing was successful.
But I decided to dig around more as the the reason why GNU readline was passing the wrong flag. It was easier than expected. I looked at configure
and noticed that it called ${srcdir}/support/shobj-conf to configure the shared libraries. Searching for -dynamic
brought me to this chunk of script:
case "${host_os}" in darwin7*) SHOBJ_LDFLAGS='' SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' ;; *) SHOBJ_LDFLAGS='-dynamic' SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' ;; esacThe lone
darwin7
looked suspicious to me, so I checked out the same file for readline-5.1 and noticed darwin7
had changed to darwin[78]
. Also, the error message above said it was building for darwin8
, so it seemed reasonable to suspect this was the crucial change. After I made that change and did make clean; ./configure; make
, libreadline-5.0 compiled properly. Now ghc and pugs both compile with readline support, and I haven't had any problems (readline related) otherwise. Woo-hoo! :-)