OS X Lion Server: readline and rlwrap

Well, it's time to make some notes to myself again.

There are many wonderful tales to tell about upgrading babbage from Leopard server to Lion server this summer, but today's topic is just about getting sqlplus working. The sqlplus command works best, as does psql, php, and others, when run under rlwrap. It turned out that getting rlwrap to build under Lion was problematic enough to warrant a reminder here.

First, if you try to build and install rlwrap without first installing readline, it ain’t gonna work. I’m not sure why, but /usr/lib/libreadline is not a good match for rlwrap. Possibly because it’s a symlink to libedit instead of being GNU readline.

The first problem with building readline was a result of a bad configuration file, which was documented as a problem as far back as readline 5.2 under Leopard ( http://secretdiaryofhan.wordpress.com/2007/12/26/building-readline-52-on... ). Using that blog post as I guide, I edited support/shobj-conf so it included checks for darwin11. While I was at it, I updated the MACOSX_DEPLOYMENT_TARGET, although I don’t know how crucial that is, since the file already had the fix for testing for darwin10, but had the deployment target still stuck at 10.3. Anyway:
vickery@babbage [~/Downloads/readline-6.2/support]
$ diff shobj-conf.save shobj-conf
< darwin[89]*|darwin10*)
> darwin[89]*|darwin10*|darwin11*)
< darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
> darwin[789]*|darwin10*|darwin11*) SHOBJ_LDFLAGS=''
vickery@babbage [~/Downloads/readline-6.2/support]

Unfortunately, I’m a bit fuzzy on what I did that was superstitious. I thought I was having architecture problems because /usr/bin/arch returns i386 instead of x86_64, and I was seeing it being used in some of the build commands. So I was specifying CFLAGS="-arch x86_64", but perhaps unnecessarily. Anyway, once I had installed libreadline in /usr/local/lib, I then had to add LDFLAGS="-L /usr/local/lib" to the make command so that rlwrap would link to the GNU readline library instead of the Apple-supplied libedit library.

Of course, the sqlplus doesn’t work (segmentation fault), but at least rlwrap seems to be fine now.

Update August 9, 2013: Able to install rlwrap on OS X 10.8 after installing readline using the above instructions. Added darwin12* to the regexes. No need to set the architecture. Did have to append LDFLAGS="-L /usr/local/lib" to the make command: