Wednesday, July 12, 2006

Java-Readline on Mac OS X Update

EDIT 11-30-2006: The binary files linked below are now compiled as Universal Binaries. I have no access to an Intel machine, so I would appreciate it if someone could test it and post a comment on how it worked. In order to compile as universal binaries, you must have the latest version of XCode installed, and follow the instructions in red below

DarwinPorts is a great project, but I hate using when I don't have to. Mac OS X (at least Tiger does) comes with a readline compatibity already installed - so I have updated these instructions so that you can create a java-readline installation WITHOUT installing DarwinPorts.

The steps are a bit more involved...but here they are:

Download the libreadline-java source from the project site.

Unpackage.

In the source root, edit Makefile and make the following changes:
  • Add JAVA_HOME = /Library/Java/Home below the line # Operating system dependent
  • Make the JAVANATINC variable read $(JAVA_HOME)/include
  • Change LD_LIBRARY_PATH to be DYLD_LIBRARY_PATH

Now, edit src/native/Makefile and change the following:
  • Change the LIBPATH variable to be empty
  • Change the CFLAGS to -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -fno-common -DMAC_OS
  • Change $(CC) -shared (OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@ to $(CC) -bundle -flat_namespace -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@
  • change the JavaReadline_LIBS variable to be -lreadline -ltermcap

Now, you need to edit src/native/org_gnu_readline_Readline.c and make the following changes:
  • On lines 98, 114, 213, and 224, change #ifdef JavaReadline to #if defined JavaReadline && !defined MAC_OS
  • On lines 216, 235, and 475, change #ifdef JavaEditline to #if defined JavaEditline || defined MAC_OS

Now, you can run make, and you will end up with libJavaReadline.so and libreadline-java.jar.

Rename libJavaReadline.so to libJavaReadline.jnilib.

Move libJavaReadline.jnilib and libreadline-java.jar to /Library/Java/Extensions to install it and have it available to all java processes.

To test, run java test.ReadlineTest from the command line.

Have fun! Now, you can install HenPlus on Mac OS X easily!

If you are lazy, you can try out the pre-compiled binaries that I have available here - after unzipping, just move the two files (not the entire folder) into your /Library/Java/Extensions directory. NOTE: these *may* only work on OS X 10.4 and up - I have only tested them on that platform, and they are *not* universal binaries - PPC only.

Tuesday, July 11, 2006

Java-Readline on Mac OS X Howto

EDIT: I have updated these instructions so that you can build using the already-installed readline libs that come with OS X (at least Tiger). See the new instructions here.

I have been trying to get java-readline compiled on mac os, and there were references to a blog entry on it, but the entry is now gone.  I found it on archive.org, and here are the instructions I used to get it running:

Using darwinports, do: port install readline

In the source root, edit Makefile and make the following changes:
  • Add JAVA_HOME = /Library/Java/Home below the line # Operating system dependent
  • Make the JAVANATINC variable read $(JAVA_HOME)/include
  • Change LD_LIBRARY_PATH to be DYLD_LIBRARY_PATH

Now, edit src/native/Makefile and change the following:
  • Add -I/opt/local/include to the end of the INCLUDES variable.
  • Change the LIBPATH variable to be -L/opt/local/lib
  • Change the CFLAGS variable to -fno-common
  • Change $(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@ to $(CC) -bundle -flat_namespace $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@

You should now be able to run make and get libJavaReadline.so and libreadline-java.jar. You'll need to rename libJavaReadline.so to libJavaReadline.jnilib.

I put both of these in /Library/Java/Extensions, which makes the library available to all Java processes that are started as you. Make sure everything works by running java test.ReadlineTest from the command line.

Tuesday, July 04, 2006

Syncing iTunes library between Mac and PC

I searched around quite a bit on Google to try and find a way to sync my iTunes library between my laptop (Mac) and my desktop (PC).  After reading quite a bit about messing with the Library.xml file and stuff that I didn't want to deal with (I just wanted it to work quickly - something that I could script, and maybe use something like rsync), I decided to just play around a little bit...

What I found was really interesting - it's quite easy to sync your iTunes library, if you have things set up just right.

If you have both your Mac and your PC set to "Keep iTunes Music Folder Organized", then most of the work is done for you.

All you need to do is copy the "iTunes Music" folder from the Mac to the PC, and copy the "iTunes Library" file from the Mac to the PC, but rename it as "iTunes Library.itl"

To make things even easier, you can rename the "iTunes Library" file to "iTunes Library.itl" on your mac, and it will work just fine - then you can do a simple rsync and get everything you need synced across.

The rsync command I use is:
rsync -avz --force --delete --stats --size-only -e ssh --exclude="iTunes Music Library.xml" --exclude=".DS_Store" ~/Music/iTunes/* user@desktop:'~/My\ Music/iTunes/'

You can modify your rsync command yourself.  Of note, DO NOT copy the xml file (it's "--exclude"ed), because iTunes on Windows will just recreate it based off of the .itl file.  Also, I didn't want to mess up my Windows file structure with all the .DS_Store files (so they are "--exclude"ed as well)

Since I don't care about two-way synchronization (I just want my Windows machine to be a clone of my Mac), this works for me.  Hopefully, it's helpful for someone else as well.

CougarFan - Finally

Yesterday, I finally had some time to work on the CougarFan.com website.

I didn't get to do too much, but I was able to get the DB schema in place and  ready to go.  We'll see how much more time I can find in the next few days...