#!/bin/sh

# Xcode 2.5+ installer is broken and will create an infinite symlink
# in /usr/local/lib.  We try to detect and fix this, becuase it
# caused just too many failed installations.

if [ -L /usr/local/lib -a -d /usr/local/lib\ 1 ]; then
    # excuse me for being paranoid, but I want to make sure it's
    # not some other (intentional) symlink that we are about to remove
    if ls -l /usr/local/lib|grep '/usr/local/lib -> /usr/local/lib$' >/dev/null; then
      	rm -f /usr/local/lib && mv /usr/local/lib\ 1 /usr/.local/lib
    fi
fi 
