#!/bin/bash

#	% cd 

# 1. Create a new directory to install ns-related software. Make sure that you are in
#    this directory. Save this install script there, set
#    the file permission to executable and run the script. Ex:

#	% chmod +x install-linux.sh
#	% ./install-linux.sh

# 2. It will create a directory tree:


# 3. You can now proceed with any changes to the source in your directory.
#    To make changes to an existing file (say tcp-reno.cc) you will have to
#    first delete the link from your ns-2 directory, copy the file
#    from the original source into your ns-2 directory
#    and then work on it.

# 4. After you are done with your changes, run "make" and a new ns will be
#    created in your ns-2 directory. Use this to run your test tcl
#    scripts

NSINSTALL="/home1/e/ec/ece/ece498nv/ns/ns-allinone-2.28"

mkdir ns2-linux
cd ns2-linux

echo "Expecting NS install at location - $NSINSTALL"


echo "Start - linking main folder tree"

ln -s $NSINSTALL/README README
ln -s $NSINSTALL/include include
ln -s $NSINSTALL/man man
ln -s $NSINSTALL/otcl-1.9 otcl-1.9
ln -s $NSINSTALL/xgraph-12.1 xgraph-12.1
ln -s $NSINSTALL/install install
ln -s $NSINSTALL/tcl8.4.5 tcl8.4.5
ln -s $NSINSTALL/zlib-1.1.4 zlib-1.1.4
ln -s $NSINSTALL/bin bin
ln -s $NSINSTALL/nam-1.11 nam-1.11
ln -s $NSINSTALL/tclcl-1.16 tclcl-1.16
ln -s $NSINSTALL/cweb cweb
ln -s $NSINSTALL/lib lib
ln -s $NSINSTALL/tk8.4.5 tk8.4.5         

echo "Done - linking main folder tree"

mkdir ns-2.28
cd ns-2.28

echo "Start - linking NS sub directories"

ln -s $NSINSTALL/ns-2.28/* .         

\rm -f	Makefile
cp $NSINSTALL/ns-2.28/Makefile .         

for i in adc allinone aodv apps asim baytcp bin bitmap classifier common conf diffserv diffusion diffusion3 doc dsdv dsr empweb emulate gaf gen imep indep-utils lib link linkstate mac mcast mobile mpls nix ns-tutorial pgm plm pushback qs queue rap realaudio routealgo routing rtproto satellite sctp sensor-nets src_rtg tcl tcp tools tora trace webcache wpan xcp

do    
   \rm -f $i
   mkdir $i
   cd $i
   echo "Linking - $NSINSTALL/ns-2.28/$i/*"
   ln -s $NSINSTALL/ns-2.28/$i/* .         
   cd ..
done

echo "Done - linking NS sub directories"

echo "********* DONE **********"
echo "NB: You must manually check the directory tree to make sure the links are fine. Symlinks do not throw errors, and it's upto us to make sure things are fine."
