Install ns2-2.31 on OS X 10.5.5

The following are software versions I used.
  • MacOS X 10.5.5
  • Xcode 3.1.1
  • NS2.31 (all in one version) Also works on NS2.29
SETPS:

1. Install Xcode (read this). 
Note: don't just install gcc because you will need X11 as well. In my case, I download Xcode (3.1.1) from Apple.com and installed the whole packages.

2. modify "ns-allinone-2.31\install" file (insert red sentence)

Modification 1

echo "============================================================"
echo "* Build Tk$TKVER"
echo "============================================================"

cd ./tk$TKVER/unix
if [ -f Makefile ] ; then
make distclean
fi

blame='Tk is not part of the ns project.  Please see www.Scriptics.com
to see if they have a fix for your platform.'
./configure --enable-gcc --disable-shared --prefix=$CUR_PATH --x-libraries=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/lib --x-includes=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include || die "tk8.3.2 configuration failed! Exiting ..."
if make 
then
echo "tk$TKVER build succeeded."
make install || die "tk$TKVER installation failed."
echo "tk$TKVER installation succeeded."
else
echo "tk$TKVER make failed! Exiting ..."
echo "For problems with Tcl/Tk see http://www.scriptics.com"
exit
fi

cd ../../

Modification 2

echo "============================================================"
echo "* Build OTcl-$OTCLVER"
echo "============================================================"

cd ./otcl-$OTCLVER

blame='Please check http://www.isi.edu/nsnam/ns/ns-problems.html
for common problems and bug fixes.'
if  [ "${test_cygwin}" = "true" ]; then
        ./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include || die "otcl-$OTCLVER configuration failed! Exiting ...";
else
        ./configure --x-libraries=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/lib --x-includes=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include || die "otcl-$OTCLVER configuration failed! Exiting ...";
fi

if make 
then
echo "otcl-$OTCLVER has been installed successfully."
else
echo "otcl-$OTCLVER make failed! Exiting ..."
echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
exit
fi

cd ..

Modification 3

echo "============================================================"
echo "* Build Tclcl-$TCLCLVER"
echo "============================================================"

cd ./tclcl-$TCLCLVER

if  [ "${test_cygwin}" = "true" ]; then
        ./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include || die "tclcl-$TCLCLVER configuration failed! Exiting ...";
else
        ./configure --x-libraries=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/lib --x-includes=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include --with-otcl=../otcl-$OTCLVER || die "tclcl-$TCLCLVER configuration failed! Exiting ..."
fi

if make
then
echo "tclcl-$TCLCLVER has been installed successfully."
else
echo "tclcl-$TCLCLVER make failed! Exiting ..."
echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
exit
fi

cd ../

Modification 4

echo "============================================================"
echo "* Build nam-$NAMVER"
echo "============================================================"

ln -s otcl-$OTCLVER otcl
ln -s tclcl-$TCLCLVER tclcl

cd ./nam-$NAMVER

# XXX temporary OS X hack
if  [ "${test_darwin}" = "true" ]; then
ln -s /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation libcorefoundation.dylib
fi

if  [ "${test_cygwin}" = "true" ]; then
        ./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --with-tclcl=$CUR_PATH/tclcl-$TCLCLVER  || die "Nam configuration failed! Exiting ...";
else
        ./configure --with-otcl=../otcl-$OTCLVER --with-tclcl=../tclcl-$TCLCLVER --x-libraries=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/lib --x-includes=/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include || die "Nam configuration failed! Exiting ...";
fi

3. Install NS2

./install

4. PATH
echo "PATH=/Users/username/ns2/ns-allinone-2.31/bin:$PATH" > .bashrc