在Mac os 10.9(Mavericks)中安装NS-2.35附自己制作的patch[修正一个错误]

前言

在Mac OS 10.9这个最新的系统下安装NS-2.35存在一些小困难,相信困扰到一些同学了。网上有针对10.6/7的patch,但是在OS 10.9上,并且更新了新的Xcode后,会因为编译器的原因导致一些错误。本人看了很多老外也在stack overflow上求助。

方法和步骤

我一番折腾之后,修复了所有安装过程出现的问题,为了下次安装可以省事,就干脆直接制作了一个patch,方便自己也方便他人。同时对install脚本进行改进,自动增加环境变量(MacOs)。

安装步骤:

安装之前请先安装xQuartz和patch。(patch通过brew或者ports安装,不懂的自己先搜一下,相当于yum和apt-get)
1.解压ns-allinone-2.35.tar.gz。
2.复制patch文件到ns-allinone-2.35目录下。
3.执行patch -p1 -i macos10.9.patch。
4.执行./install进行安装。
不出意外的话,应该直接安装成功,并且自动添加环境变量。

修正:

之前的补丁在重新执行configure脚本后会报Undefined symbols for architecture x86_64这个错误,分析了原因发现是LDFLAGS的原因。需要加载CoreFoundation框架。
即LDFLAGS =  -framework CoreFoundation,这个本来在configure里面是存在的,但是configure脚本的判断逻辑不对,它判断mac的内核如果是Darwin 8、9才加载这个框架。由于我不做Mac开发,不太清楚框架的用途。总之,修正后的补丁解决了这个问题。还有,没事不要乱对ns进行configure。

补丁:

下载:

https://code.csdn.net/snippets/153117/master/download

感谢CSDN的代码片功能。

直接贴代码:保存为macos10.9.patch

macos10.9.patch
diff -aur s-allinone-2.35.orig/ns-2.35/configure ns-allinone-2.35/ns-2.35/configure
--- ns-allinone-2.35.orig/ns-2.35/configure	2011-11-05 01:29:46.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/configure	2014-01-12 14:30:52.000000000 +0800
@@ -9301,7 +9301,7 @@
 fi
 
 case $system in
-    Darwin-7.*|Darwin-8.*)
+    Darwin-7.*|Darwin-8.*|Darwin-12.*|Darwin-13.*)
 	V_LIB="$V_LIB -framework CoreFoundation"
 esac

diff -aur s-allinone-2.35.orig/install ns-allinone-2.35/install
--- ns-allinone-2.35.orig/install	2011-11-05 01:18:22.000000000 +0800
+++ ns-allinone-2.35/install	2014-01-14 15:34:34.000000000 +0800
@@ -200,6 +200,7 @@
     echo "Darwin detected";
     DYLD_LIBRARY_PATH=$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix:$DYLD_LIBRARY_PATH
     export DYLD_LIBRARY_PATH
+    export LDFLAGS="-framework CoreFoundation"
     test_darwin=true
 fi
 
@@ -565,11 +566,6 @@
 
 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  --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "Nam configuration failed! Exiting ...";
 else
@@ -671,14 +667,19 @@
 
 echo ""
 echo "----------------------------------------------------------------------------------"
-echo ""
+echo "The install script will automatically add environment variable to your system,if you run \"ns\" and then system says \"command not found\", you should check your environment varible (~/.bash_profile or ~/.bash_rc)"
 echo "Please put $CUR_PATH/bin:$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix" 
 echo "into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph."
+#Add env var
+echo "export PATH=$PATH:$CUR_PATH/bin:$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix" >>~/.bash_profile
 echo ""
 echo "IMPORTANT NOTICES:"
 echo ""
 echo "(1) You MUST put $CUR_PATH/otcl-$OTCLVER, $CUR_PATH/lib, "
 echo "    into your LD_LIBRARY_PATH environment variable."
+#Add env var
+echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUR_PATH/otcl-$OTCLVER:$CUR_PATH/lib" >>~/.bash_profile
+
 echo "    If it complains about X libraries, add path to your X libraries "
 echo "    into LD_LIBRARY_PATH."
 echo "    If you are using csh, you can set it like:"
@@ -687,6 +688,9 @@
 echo "		export LD_LIBRARY_PATH=
    
    
     
     "
 echo ""
 echo "(2) You MUST put $CUR_PATH/tcl$TCLVER/library into your TCL_LIBRARY environmental"
+#Add env var
+echo "export TCL_LIBRARY=$TCL_LIBRARY:$CUR_PATH/tcl$TCLVER/library " >>~/.bash_profile
+
 echo "    variable. Otherwise ns/nam will complain during startup."
 echo ""
 echo ""

diff -aur ns-allinone-2.35.orig/nam-1.15/Makefile.in ns-allinone-2.35/nam-1.15/Makefile.in
--- ns-allinone-2.35.orig/nam-1.15/Makefile.in	2012-09-07 14:36:27.000000000 -0700
+++ ns-allinone-2.35/nam-1.15/Makefile.in	2012-09-07 14:45:22.000000000 -0700
@@ -72,7 +72,7 @@
 BLANK	= # make a blank space.  DO NOT add anything to this line
 AR	= ar rc $(BLANK)
 LINK	= $(CPP)
-LDFLAGS	=
+LDFLAGS	= @LDFLAGS@
 LDOUT	= -o $(BLANK)
 PERL	= perl
 RM	= rm -f
diff -aur ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/dec/Makefile.in ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/dec/Makefile.in
--- ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/dec/Makefile.in	2012-09-07 14:36:41.000000000 -0700
+++ ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/dec/Makefile.in	2012-09-07 14:40:36.000000000 -0700
@@ -54,7 +54,7 @@
 CC = @CXX@
 INCLUDE = -I. @V_INCLUDES@
 CFLAGS = @V_CCOPT@ -DCPP_NAMESPACE=@CPP_NAMESPACE@
-LDFLAGS = @V_STATIC@
+LDFLAGS = @LDFLAGS@
 LIBS = @V_LIB_TCL@ @V_LIB@ @LIBS@
 INSTALL = @INSTALL@
 
diff -aur ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/epa/Makefile.in ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/epa/Makefile.in
--- ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/epa/Makefile.in	2012-09-07 14:36:42.000000000 -0700
+++ ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/epa/Makefile.in	2012-09-07 14:40:22.000000000 -0700
@@ -51,7 +51,7 @@
 
 INCLUDE = -I. @V_INCLUDES@
 CFLAGS = @V_CCOPT@ -DCPP_NAMESPACE=@CPP_NAMESPACE@
-LDFLAGS = @V_STATIC@
+LDFLAGS = @LDFLAGS@
 LIBS = @V_LIB_TCL@ @V_LIB@ @LIBS@
 INSTALL = @INSTALL@
 
diff -aur ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/nlanr/Makefile.in ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/nlanr/Makefile.in
--- ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/nlanr/Makefile.in	2012-09-07 14:36:42.000000000 -0700
+++ ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/nlanr/Makefile.in	2012-09-07 14:40:02.000000000 -0700
@@ -51,7 +51,7 @@
 CC = @CXX@
 INCLUDE = -I. -I../../.. @V_INCLUDES@
 CFLAGS = @V_CCOPT@ -DCPP_NAMESPACE=@CPP_NAMESPACE@
-LDFLAGS = @V_STATIC@
+LDFLAGS = @LDFLAGS@
 LIBS = @V_LIB_TCL@ @V_LIB@ @LIBS@
 INSTALL = @INSTALL@
 
diff -aur ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/ucb/Makefile.in ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb/Makefile.in
--- ns-allinone-2.35.orig/ns-2.35/indep-utils/webtrace-conv/ucb/Makefile.in	2012-09-07 14:36:42.000000000 -0700
+++ ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb/Makefile.in	2012-09-07 14:39:41.000000000 -0700
@@ -29,7 +29,7 @@
 
 INCLUDE = -I. @V_INCLUDES@
 CFLAGS = @V_CCOPT@ -DCPP_NAMESPACE=@CPP_NAMESPACE@
-LDFLAGS = @V_STATIC@
+LDFLAGS = @LDFLAGS@
 LIBS = @V_LIB_TCL@ @V_LIB@ @LIBS@
 INSTALL = @INSTALL@
 
--- ns-allinone-2.35.orig/otcl-1.14/Makefile.in	2012-09-07 14:37:37.000000000 -0700
+++ ns-allinone-2.35/otcl-1.14/Makefile.in	2012-09-07 21:20:06.000000000 -0700
@@ -8,6 +8,7 @@
 CFLAGS=		@CFLAGS@
 RANLIB= 	@RANLIB@
 INSTALL=	@INSTALL@
+LDFLAGS=	@LDFLAGS@
 
 #
 # how to compile, link, and name shared libraries
@@ -16,7 +17,7 @@
 SHLIB_LD=	@SHLIB_LD@
 SHLIB_CFLAGS=	@SHLIB_CFLAGS@
 SHLIB_SUFFIX=	@SHLIB_SUFFIX@
-SHLD_FLAGS=	@DL_LD_FLAGS@
+SHLD_FLAGS=	@LDFLAGS@
 DL_LIBS=	@DL_LIBS@
 
 SHLIB_LD_LIBS  = @SHLIB_LD_LIBS@

diff -aur ns-allinone-2.35.orig/ns-2.35/common/agent.cc ns-allinone-2.35/ns-2.35/common/agent.cc
--- ns-allinone-2.35.orig/ns-2.35/common/agent.cc	2010-03-08 13:54:49.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/common/agent.cc	2014-01-12 02:21:17.000000000 +0800
@@ -51,7 +51,7 @@
 #include "nix/nixnode.h"
 #endif //HAVE_STL
 
-
+using namespace NIX;
 
 #ifndef min
 #define min(a, b) (((a) < (b)) ? (a) : (b))
diff -aur ns-allinone-2.35.orig/ns-2.35/common/node.cc ns-allinone-2.35/ns-2.35/common/node.cc
--- ns-allinone-2.35.orig/ns-2.35/common/node.cc	2002-05-31 01:44:03.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/common/node.cc	2014-01-12 02:58:36.000000000 +0800
@@ -42,11 +42,8 @@
 
 #include "address.h"
 #include "config.h"
-#ifdef HAVE_STL
-#include "nix/nixnode.h"
-#endif //HAVE_STL
 #include "node.h"
-
+using namespace NIX;
 static class LinkHeadClass : public TclClass {
 public:
 	LinkHeadClass() : TclClass("Connector/LinkHead") {}
diff -aur ns-allinone-2.35.orig/ns-2.35/common/node.h ns-allinone-2.35/ns-2.35/common/node.h
--- ns-allinone-2.35.orig/ns-2.35/common/node.h	2002-05-31 01:44:03.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/common/node.h	2014-01-12 03:04:44.000000000 +0800
@@ -59,8 +59,11 @@
 #include "energy-model.h"
 #include "location.h"
 #include "rtmodule.h"
-
-class NixNode;
+#ifdef HAVE_STL
+#include "nix/nixnode.h"
+#endif //HAVE_STL
+//class NixNode;
+using namespace NIX;
 class LinkHead;
 
 LIST_HEAD(linklist_head, LinkHead); // declare list head structure 
diff -aur ns-allinone-2.35.orig/ns-2.35/common/tclAppInit.cc ns-allinone-2.35/ns-2.35/common/tclAppInit.cc
--- ns-allinone-2.35.orig/ns-2.35/common/tclAppInit.cc	2008-02-18 11:39:02.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/common/tclAppInit.cc	2014-01-12 04:10:35.000000000 +0800
@@ -237,7 +237,7 @@
 Tcl_AppInit(Tcl_Interp *interp)
 {
 #ifdef MEMDEBUG_SIMULATIONS
-        extern MemTrace *globalMemTrace;
+        //extern MemTrace *globalMemTrace;
         globalMemTrace = new MemTrace;
 #endif
 
diff -aur ns-allinone-2.35.orig/ns-2.35/common/tkAppInit.cc ns-allinone-2.35/ns-2.35/common/tkAppInit.cc
--- ns-allinone-2.35.orig/ns-2.35/common/tkAppInit.cc	2007-08-15 13:49:13.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/common/tkAppInit.cc	2014-01-12 04:14:22.000000000 +0800
@@ -293,7 +293,7 @@
 Tcl_AppInit(Tcl_Interp *interp)
 {
 #ifdef MEMDEBUG_SIMULATIONS
-        extern MemTrace *globalMemTrace;
+        //extern MemTrace *globalMemTrace;
         globalMemTrace = new MemTrace;
 #endif
 
diff -aur ns-allinone-2.35.orig/ns-2.35/linkstate/ls.h ns-allinone-2.35/ns-2.35/linkstate/ls.h
--- ns-allinone-2.35.orig/ns-2.35/linkstate/ls.h	2010-03-08 13:54:51.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/linkstate/ls.h	2014-01-12 03:56:02.000000000 +0800
@@ -134,7 +134,7 @@
 		return ib.second ? ib.first : baseMap::end();
 	}
 
-	void eraseAll() { erase(baseMap::begin(), baseMap::end()); }
+	void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
 	T* findPtr(Key key) {
 		iterator it = baseMap::find(key);
 		return (it == baseMap::end()) ? (T *)NULL : &((*it).second);
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart.cc ns-allinone-2.35/ns-2.35/mdart/mdart.cc
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart.cc	2010-05-10 06:28:41.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart.cc	2014-01-12 01:40:15.000000000 +0800
@@ -47,7 +47,7 @@
 #include 
     
     
      
      
 #include 
      
      
       
       
 #include 
       
       
        
        
-
+using namespace stlplus;
 
 
 //------------------------------------------------------------------------------
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart_adp.cc ns-allinone-2.35/ns-2.35/mdart/mdart_adp.cc
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart_adp.cc	2010-05-10 06:28:41.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart_adp.cc	2014-01-12 01:00:18.000000000 +0800
@@ -105,7 +105,7 @@
 #ifdef DEBUG_ADP
 	fprintf(stdout, "%.9f\tADP::sendDarq(%d)\t\t\tin node %d\twith address %s\n", CURRENT_TIME, reqId, mdart_->id_, bitString(mdart_->address_));
 #endif
-	nsaddr_t dstAdd_ = hash(reqId);
+	nsaddr_t dstAdd_ = stlplus::hash(reqId);
 #ifdef DEBUG_ADP
 	fprintf(stdout, "\tsending darq for node %s\n", bitString(dstAdd_));
 #endif
@@ -393,7 +393,7 @@
 	fprintf(stdout, "%.9f\tMDART::sendDaup()\t\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
 //	printDHT();
 #endif
-	nsaddr_t dstAdd_ = hash(mdart_->id_);
+	nsaddr_t dstAdd_ = stlplus::hash(mdart_->id_);
 #ifdef DEBUG_ADP
 	fprintf(stdout, "\tsending daup for node  %s\n", bitString(dstAdd_));
 	mdart_->routingTable_->print();
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart_dht.cc ns-allinone-2.35/ns-2.35/mdart/mdart_dht.cc
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart_dht.cc	2010-05-10 06:28:41.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart_dht.cc	2014-01-12 01:18:54.000000000 +0800
@@ -268,7 +268,7 @@
 	dhtTable::iterator entry_;
 	fprintf(stdout, "\tDHT::printDHT()\n");
 	for(entry_ = table_->begin(); entry_ != table_->end(); ++entry_) {
-		fprintf(stdout, "\t\tnode id = %d\tnode address = %s\texpire time = %f\n", (*entry_)->id(), bitString((*entry_)->address()), (*entry_)->expire());
+		fprintf(stdout, "\t\tnode id = %d\tnode address = %s\texpire time = %f\n", (*entry_)->id(), stlplus::bitString((*entry_)->address()), (*entry_)->expire());
 	}
 }
 
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart_function.h ns-allinone-2.35/ns-2.35/mdart/mdart_function.h
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart_function.h	2010-05-10 06:28:41.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart_function.h	2014-01-12 00:57:40.000000000 +0800
@@ -88,6 +88,8 @@
 //#define DEBUG_PRINT_TABLE
 //#define DEBUG_ROBY
 
+namespace stlplus{
+	
 
 
 //------------------------------------------------------------------------------
@@ -256,6 +258,6 @@
 	return addr;
 }*/
 
-
+}
 
 #endif /*__mdart_function__*/
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart_ndp.cc ns-allinone-2.35/ns-2.35/mdart/mdart_ndp.cc
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart_ndp.cc	2010-05-10 06:28:41.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart_ndp.cc	2014-01-12 01:25:38.000000000 +0800
@@ -299,6 +299,7 @@
 */}
 
 void NDP::neighborPrint() {
+	using namespace stlplus;
 #ifdef DEBUG_ADDRESS_ALLOCATION
  	fprintf(stdout, "\tNDP::neighborPrint()\t\t\tin node %d\twith address %s\n", mdart_->id_, bitString(mdart_->address_));
 #endif
@@ -439,6 +440,7 @@
 
 
 bool NDP::validateAddress() {
+	using namespace stlplus;
 #ifdef DEBUG_ADDRESS_ALLOCATION
 	fprintf(stdout, "\tNDP::validateAddress()\t\t\tin node %d\twith address %s\n", mdart_->id_, bitString(mdart_->address_));
 	mdart_->routingTable_->print();
diff -aur ns-allinone-2.35.orig/ns-2.35/mdart/mdart_table.cc ns-allinone-2.35/ns-2.35/mdart/mdart_table.cc
--- ns-allinone-2.35.orig/ns-2.35/mdart/mdart_table.cc	2011-10-03 06:32:34.000000000 +0800
+++ ns-allinone-2.35/ns-2.35/mdart/mdart_table.cc	2014-01-12 01:31:51.000000000 +0800
@@ -47,7 +47,7 @@
 #include 
        
        
          #include 
         
           - +using namespace stlplus; //------------------------------------------------------------------------------ // MDART routing table management functions diff -aur ns-allinone-2.35.orig/ns-2.35/mobile/god.cc ns-allinone-2.35/ns-2.35/mobile/god.cc --- ns-allinone-2.35.orig/ns-2.35/mobile/god.cc 2006-12-27 22:57:23.000000000 +0800 +++ ns-allinone-2.35/ns-2.35/mobile/god.cc 2014-01-12 03:16:56.000000000 +0800 @@ -57,7 +57,7 @@ #include "diffusion/hash_table.h" #include "mobilenode.h" - +using namespace NSGOD; God* God::instance_; static class GodClass : public TclClass { @@ -474,9 +474,9 @@ return false; } - vector a(mb_node[i]->X(), mb_node[i]->Y(), mb_node[i]->Z()); - vector b(mb_node[j]->X(), mb_node[j]->Y(), mb_node[j]->Z()); - vector d = a - b; + NSGOD::vector a(mb_node[i]->X(), mb_node[i]->Y(), mb_node[i]->Z()); + NSGOD::vector b(mb_node[j]->X(), mb_node[j]->Y(), mb_node[j]->Z()); + NSGOD::vector d = a - b; if (d.length() < RANGE) return true; diff -aur ns-allinone-2.35.orig/ns-2.35/mobile/god.h ns-allinone-2.35/ns-2.35/mobile/god.h --- ns-allinone-2.35.orig/ns-2.35/mobile/god.h 2006-02-21 23:20:19.000000000 +0800 +++ ns-allinone-2.35/ns-2.35/mobile/god.h 2014-01-12 03:13:40.000000000 +0800 @@ -75,7 +75,8 @@ // Cut and Paste from setdest.h -- Chalermek 12/1/99 - +// To bypass compile error caused by ambigious definition, Jedihy +namespace NSGOD{ class vector { public: vector(double x = 0.0, double y = 0.0, double z = 0.0) { @@ -115,7 +116,7 @@ double Y; double Z; }; - +} // ------------------------ diff -aur ns-allinone-2.35.orig/ns-2.35/nix/classifier-nix.cc ns-allinone-2.35/ns-2.35/nix/classifier-nix.cc --- ns-allinone-2.35.orig/ns-2.35/nix/classifier-nix.cc 2006-02-21 23:20:19.000000000 +0800 +++ ns-allinone-2.35/ns-2.35/nix/classifier-nix.cc 2014-01-12 03:35:56.000000000 +0800 @@ -62,7 +62,7 @@ #include "nixvec.h" #include "classifier-nix.h" #include "hdr_nv.h" - +using namespace NIX; /* Define the TCL Class */ static class NixClassifierClass : public TclClass { public: diff -aur ns-allinone-2.35.orig/ns-2.35/nix/nixnode.cc ns-allinone-2.35/ns-2.35/nix/nixnode.cc --- ns-allinone-2.35.orig/ns-2.35/nix/nixnode.cc 2005-09-22 15:44:42.000000000 +0800 +++ ns-allinone-2.35/ns-2.35/nix/nixnode.cc 2014-01-12 03:49:00.000000000 +0800 @@ -62,7 +62,7 @@ #include "nix/nixvec.h" #include "routealgo/routealgo.h" #include "nix/hdr_nv.h" - +using namespace NIX; static RNodeVec_t Nodes; // Vector of known nodes static int NVCount = 0; // Number of nix vectors static Nixl_t NVMin = 0; // Smallest nv @@ -156,7 +156,7 @@ if (last.first == NODE_NONE) { prev = m_Adj.begin(); - if (prev == (EdgeVec_it) NULL) // ! How can this happen? + if (prev == m_Adj.end()) // ! How can this happen? return(NodeWeight_t(NODE_NONE, 0)); pE = *prev; if(0)printf("NextAdj returning first edge %ld\n", diff -aur ns-allinone-2.35.orig/ns-2.35/nix/nixnode.h ns-allinone-2.35/ns-2.35/nix/nixnode.h --- ns-allinone-2.35.orig/ns-2.35/nix/nixnode.h 2001-04-18 01:30:44.000000000 +0800 +++ ns-allinone-2.35/ns-2.35/nix/nixnode.h 2014-01-12 02:18:32.000000000 +0800 @@ -9,7 +9,7 @@ #include "routealgo/rnode.h" #include "object.h" #include 
           - +namespace NIX{ // Define the edge class class Edge { public : @@ -53,6 +53,8 @@ int m_Map; // Which system this node is mapped to NVMap_t* m_pNixVecs; // Hash-map list of known NixVectors }; + +} #endif  
          
        
       
       
      
      
     
     
    
    

改进的install脚本如下
#! /bin/sh
#
# Copyright (C) 2000 by USC/ISI
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation, advertising
# materials, and other materials related to such distribution and use
# acknowledge that the software was developed by the University of
# Southern California, Information Sciences Institute.  The name of the
# University may not be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# $Header: /cvsroot/nsnam/ns-2/allinone/install,v 1.31 2007/03/10 23:40:05 tom_henderson Exp $

die() {
	echo "$@"  1>&2
	test ! -z "$blame" && echo "$blame" 1>&2
	exit 1
}

warn() {
	echo "$@"
}

test_proceed() { 
        echo "";
        echo "The above test indicates that your installation of Cygwin";
        echo "is probably NOT SUITABLE for installing ns-2 allinone.";
        echo "(More details can be found in the specific error message above.)";
        echo "";
        echo -n "Do you wish to proceed regardless? [y/N] "
        read answer;
        if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then
                die "Installation aborted...";
                exit 1;
        fi;
        echo "";
        echo "*** OK, but you're on your own... ***";
        echo "";
}

test_packages() {
         for i in $@; do 
                echo -n "Checking for ${i}... ";
                cygcheck -c ${i} | grep ${i} >/dev/null 2>&1;
                if [ "$?" -eq "0" ]; then
                        echo "ok"; 
                else
                        echo "NO!";
                        echo "";
                        echo "Package ${i} is not present on your system.";
                        echo "";
                        echo "Please install it using Cygwin's setup.exe";
                        echo "before trying to install the ns-2 distribution.";
                        test_proceed;
                fi; 
        done;
}

cygwin_tests() {
        echo -n "Checking Cygwin version is >= 1.7.1... "
        cmaj=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\1/'`;
        echo $cmaj | grep -v [0-9] >/dev/null 2>&1
        if [ "$?" -eq "0" ]; then
                cmaj=0;
        fi;
        cmin=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\2/'`;
        echo $cmin | grep -v [0-9] >/dev/null 2>&1
        if [ "$?" -eq "0" ]; then
                cmin=0;
        fi;
        cpat=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\3/'`;
        echo $cpat | grep -v [0-9] >/dev/null 2>&1
        if [ "$?" -eq "0" ]; then
                cpat=0;
        fi;
        echo -n "$cmaj.$cmin.$cpat ";
        if ([ "$cmaj" -gt "1" ]) || ([ "$cmaj" -eq "1" ] && [ $cmin -gt "7" ]) || ([ "$cmaj" -eq 1 ] && [ $cmin -eq "7" ] && [ "$cpat" -ge "1" ]); then
                echo "(should be ok)";
        else
                echo "(NO!)";
                echo "";
                echo "ns-allinone-${NSVER} has not been tested under versions of Cygwin older than";
                echo "1.7.1. Your version ($cmaj.$cmin.$cpat) appears to be older than that. Success of";
                echo "the install process is therefore NOT GUARANTEED.";
                echo "";
                cygversion="failed";
                test_proceed;
        fi;
        echo -n "Checking filesystems are mounted as UNIX filetype... ";
        mount | grep "textmode" >/dev/null 2>&1;
        if [ "$?" -eq "0" ]; then
                echo "NO!";
                mount_test="failed";
                echo "";
                echo "It appears that some of your Cygwin shares are mounted as DOS file";
                echo "type. This has not been tested, but is likely to result in failure of";
                echo "validation tests. Success of the install process is also NOT";
                echo "GUARANTEED.";
                echo "";
                echo "Refer to the Cygwin user guide for how to install Cygwin with the UNIX";
                echo "file text mode.";
                test_proceed;
        else
                echo "yes";
                echo -n "Checking default mode is binmode... ";
                echo ${CYGWIN} | grep "nobinmode" >/dev/null 2>&1;
                if [ "$?" -eq "0" ]; then
                        cyg_env_var="failed";
                        echo "*** NO! ***";
                        echo "";
                        echo "Your \$CYGWIN environment variable specifies \"nobinmode\". This is";
                        echo "likely to result in failure of validation tests, and (possibly) of";
                        echo "the whole install process. You need to have the \$CYGWIN environment";
                        echo "variable set to \"binmode\". Please refer to the Cygwin user guide for";
                        echo "details on how to change this.";
                        test_proceed;
                else 
                        echo "yes";
                fi;
        fi;                           

        login=`whoami`
        echo -n "Checking legitimate login name... ";
        echo ${login} | grep " " >/dev/null 2>&1;
        if [ "$?" -eq "0" ]; then
                echo "NO!"; 
                echo "";
                echo "Your username (${login}) contains spaces,";
                echo "which makes the installation of ns-2 impossible.";
                echo "Please try to install ns-2 as a different user, whose";
                echo "name does not contain any spaces.";
                
                test_proceed;
        else 
                echo "ok";
        fi;

        echo -n "Checking legitimate path name... ";
        
        installpath=`cygpath -d /`;
        echo ${installpath} | grep " " >/dev/null 2>&1;
        if [ "$?" -eq "0" ]; then
                echo "NO!"; 
                echo "";
                echo "Your Cygwin installation path (${installpath}) contains spaces,";
                echo "which makes the installation of ns-2 impossible.";
                echo "Please reinstall Cygwin in a different directory, which";
                echo "does not contain any spaces.";
                test_proceed;
        else 
                echo "ok";
        fi;

        test_packages ${packages_base}        

        echo -n "Checking for diff... ";
        diff -v 2>&1 | grep -iv "not found" >/dev/null 2>&1;
        if [ "$?" -eq "0" ]; then
                echo "ok";
        else
                echo "NO!";
                echo "";
                echo "diff is not present on your system.";
                echo "";
                echo "Please install it using Cygwin's setup.exe";
                echo "before trying to install the ns-2 distribution.";
                test_proceed;
        fi;     

        echo -n "Checking for X... ";
        test_packages ${packages_xorg}
    }


# Package VERSIONs. Change these when releasing new packages
TCLVER=8.5.10
TKVER=8.5.10
OTCLVER=1.14
TCLCLVER=1.20
NSVER=2.35
NAMVER=1.15
XGRAPHVER=12.2
ZLIBVER=1.2.3
DEI80211MRVER=1.1.4

# Get current path
CUR_PATH=`pwd`

echo "============================================================"
echo "* Testing for Darwin (OS X) environment"
echo "============================================================"
if  [ `uname` = "Darwin" ]; then
    echo "Darwin detected";
    DYLD_LIBRARY_PATH=$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix:$DYLD_LIBRARY_PATH
    export DYLD_LIBRARY_PATH
    export LDFLAGS="-framework CoreFoundation"
    test_darwin=true
fi

# A Cygwin install requires these packages:
packages_base="gcc4 gcc4-g++ gawk tar gzip make patch perl w32api"
packages_xorg="xorg-server xinit libX11-devel libXmu-devel"

# Check if we are using Cygwin, and if so, if it is a good install
# Most Cygwin fixes in the tree and this part of the install script were 
# contributed by Nicolas Christin 

echo "============================================================"
echo "* Testing for Cygwin environment"
echo "============================================================"

if [ -x /usr/bin/uname ]; then
        # it may be a Cygwin install
        test_cygwin=`uname | tr [a-z] [A-Z] | sed -e 's|.*CYGWIN.*|true|'`;
        if  [ "${test_cygwin}" = "true" ]; then
                echo "Cygwin detected";
                echo "Note: Cygwin install is still considered EXPERIMENTAL";
                echo "";
                cygwin_tests;
               
                echo "Patching Tcl/Tk for Cygwin.";
                if [ ! -f ./tcl${TCLVER}/generic/tcl.h.orig ]; then
                        cp ./tcl${TCLVER}/generic/tcl.h ./tcl${TCLVER}/generic/tcl.h.orig;
                        echo "The original tcl${TCLVER}/generic/tcl.h is backed up as tcl${TCLVER}/generic/tcl.h.orig";
                        sed -e 's/\#define _TCL/\#define _TCL\`\`\#ifdef __CYGWIN__\`\#define HAVE_TM_ZONE 1\`\#endif \/\* __CYGWIN__ \*\//g' ./tcl${TCLVER}/generic/tcl.h.orig | tr '\`' '\n' > ./tcl${TCLVER}/generic/tcl.h;
			cp ./tk${TCLVER}/generic/default.h ./tk${TCLVER}/generic/default.h.orig;
                        echo "The original tk${TKVER}/generic/default.h is backed up as tk${TKVER}/generic/default.h.orig";
                        sed -e 's/defined(__CYGWIN__) || defined(__MINGW32__)/0/g' ./tk${TKVER}/generic/default.h.orig > ./tk${TKVER}/generic/default.h;
                fi;
                touch ./tcl${TCLVER}/generic/tclStubInit.c;
                echo "Patching sgb for Cygwin.";
                cp ./sgb/Makefile ./sgb/Makefile.orig;
                echo "The original sgb/Makefile is backed up as sgb/Makefile.orig";
                sed -e 's|rm \(.*\)test_io test_graph test_flip test_sample\(.*\)|rm -f \1test_io.exe test_graph.exe test_flip.exe test_sample.exe\2|' ./sgb/Makefile.orig > ./sgb/Makefile;
                echo "Setting executable format to .exe...";
                EXE=".exe";
        else
                echo "Cygwin not detected, proceeding with regular install.";
                EXE=;
        fi;
else
        echo "Cygwin not detected, proceeding with regular install.";
fi;

echo "============================================================"
echo "* Testing for FreeBSD environment"
echo "============================================================"
# See if we need to use gmake.
if [ "`uname -s`" = "FreeBSD" ]; then
 echo "FreeBSD detected; using gmake instead of make"
 if (type gmake &>/dev/null); then
   alias make="gmake"
 fi
else
 echo "FreeBSD not detected"
fi

# Compile and install xgraph

echo "============================================================"
echo "* Build XGraph-$XGRAPHVER"
echo "============================================================"

cd ./xgraph-$XGRAPHVER
./configure --prefix=../
if  [ "${test_cygwin}" = "true" ]; then
       touch stamp-h;
fi;
if make 
then
	echo "xgraph has been installed successfully. "
else 
	echo "Can not create xgraph; But xgraph is an optional package, continuing..."
fi

cd ../

# Compile and install cweb and sgblib

echo "============================================================"
echo "* Build CWeb"
echo "============================================================"

cd ./cweb

if [ ! -f ./Makefile ]
then
	echo "ns-allinone unable to install cweb for you. Please install it manually. cweb is used by sgb to create sgblibrary needed by scenario-generator. But this will not affect the use of ns as such, so continue.."
else
	echo "Making cweb"
	touch *.c
	make all || warn "cweb failed to make, but it's optional"
	# xxx: other stuff will fail...
	chmod 755 cweave${EXE}
	chmod 755 ctangle${EXE}
	cd ..
	#echo "cd .."
	if [ ! -d bin ]
	then
		mkdir bin
	fi
	cd bin
	ln -s $CUR_PATH/cweb/cweave${EXE} cweave${EXE}
	ln -s $CUR_PATH/cweb/ctangle${EXE} ctangle${EXE}
fi

cd ..
PATH=$CUR_PATH/bin:$PATH
export PATH

echo "============================================================"
echo "* Build Stanford GraphBase"
echo "============================================================"

cd ./sgb
if [ ! -f ./Makefile ]
	then
	echo "Unable to create sgb library. This library is used by gt-itm and so for scenario generators. If you already have sgblib (possible if you are on solaris,sunos or freebsd platforms) you may still be able to run gt-itm. so continuing.."
else
	echo "Making sgb"
	if make tests
	then
                if [ -f libgb.a ] ; then
                        rm -f ../gt-itm/lib/libgb.a
			cp libgb.a ../gt-itm/lib/libgb.a
                else 
		        echo "* Weird: sgb said it has been built but we can't find libgb.a! "
			exit -1
                fi
	else
	        echo "Unable to create sgb library, but it's optional, so continuing..."
	fi
fi

cd ..

# Compile and install gt-itm & sgb2ns

echo "============================================================"
echo "* Build GT-ITM"
echo "============================================================"

if [ -f ./gt-itm/lib/libgb.a ]
then
 if [ ! -f ./gt-itm/src/Makefile ] 
    then
    echo "ns-alline is unable to install gt-itm sgb2ns for you, please install"
    echo "them manually. You can't run scenario generator without gt-itm"
    echo "and sgb2ns. But it will not affect you use ns, so continue ..."
 else
    cd ./gt-itm/src
    if make
    then
      echo "gt-itm has been installed successfully."
    fi
    
    cd ../sgb2ns
    if make
    then
      echo "sgb2ns has been installed successfully."
    fi
   cd ../../
 fi
else
    echo "sgb lib not found. gt-itm & sgb2ns could not be installed. Continuing.."
fi

# Build zlib

echo "============================================================"
echo "* Build zlib"
echo "============================================================"

cd ./zlib-$ZLIBVER

if ./configure --exec-prefix=../ --prefix=../
then
	if make
	then
		echo "Zlib has been installed successfully."
	else
		warn "Zlib make failed, but it's optional Continue ..."
	fi
else
	warn "Zlib-$ZLIBVER configuration failed, but it's optional, so continuing ..."
fi

cd ../

# Build Tcl8.4.18

echo "============================================================"
echo "* Build tcl$TCLVER"
echo "============================================================"

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

blame='Tcl is not part of the ns project.  Please see www.Scriptics.com
to see if they have a fix for your platform.'
autoconf
./configure --enable-gcc --disable-shared --prefix=$CUR_PATH || die "tcl$TCLVER configuration failed! Exiting ..."
if make 
then 
	echo "tcl$TCLVER make succeeded."
	make install || die "tcl$TCLVER installation failed."
	make install-private-headers || die "tcl$TCLVER installation failed."
	echo "tcl$TCLVER installation succeeded."
	#cp ../generic/*.h ../../include
else
	echo "tcl$TCLVER make failed! Exiting ..."
	echo "For problems with Tcl/Tk see http://www.scriptics.com"
	exit
fi

cd ../../

# compile and install tk

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.'
autoconf
./configure --enable-gcc --disable-shared --disable-xft --disable-xss --prefix=$CUR_PATH || die "tk$TKVER configuration failed! Exiting ..."
if make 
then
	echo "tk$TKVER build succeeded."
	make install || die "tk$TKVER installation failed."
	make install-private-headers || die "tcl$TCLVER 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 ../../

#
# Since our configures search for tclsh in $PATH, the following 
# is needed. This is necessary for otcl/tclcl/ns/nam
#
#PATH=$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix:$PATH
#LD_LIBRARY_PATH=$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix:$LD_LIBRARY_PATH

# However, the above library path setting has been found to be still 
# fragile for systems that have multiple versions of Tcl/Tk installed
# in various places, so in the below, we will force the allinone build
# to use the tcl/tk version installed with allinone by passing the
# --with-tcl-ver and --with-tk-ver options

# Build otcl

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 --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER --disable-shlib || die "otcl-$OTCLVER configuration failed! Exiting ...";
	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
else
        ./configure --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "otcl-$OTCLVER configuration failed! Exiting ...";

	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
fi

cd ..

# Build tclcl

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 --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "tclcl-$TCLCLVER configuration failed! Exiting ...";
else
        ./configure --with-otcl=../otcl-$OTCLVER --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || 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 ../

# John's hack
test -f ./otcl-$OTCLVER/libotcl.a && rm ./otcl-$OTCLVER/libotcl.so

echo "============================================================"
echo "* Build ns-$NSVER"
echo "============================================================"

cd ./ns-$NSVER
if [ -f Makefile ] ; then 
	make distclean
fi

if  [ "${test_cygwin}" = "true" ]; then
        ./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "Ns configuration failed! Exiting ...";
else
        ./configure --with-otcl=../otcl-$OTCLVER --with-tclcl=../tclcl-$TCLCLVER --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "Ns configuration failed! Exiting ...";
fi

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

cd ../

# Build nam

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

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

cd ./nam-$NAMVER

if  [ "${test_cygwin}" = "true" ]; then
        ./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --with-tclcl=$CUR_PATH/tclcl-$TCLCLVER  --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "Nam configuration failed! Exiting ...";
else
        ./configure --with-otcl=../otcl-$OTCLVER --with-tclcl=../tclcl-$TCLCLVER --with-tcl-ver=$TCLVER --with-tk-ver=$TKVER || die "Nam configuration failed! Exiting ...";
fi

if make
then 
    echo "Nam has been installed successfully."
elif  [ "${test_darwin}" = "true" ]; then
    # XXX workaround for OS X nam Tcl/Tk problems
    echo "Nam make failed! Trying to relink..."
    echo "g++ -o nam tkcompat.o tkUnixInit.o xwd.o netview.o netmodel.o edge.o packet.o node.o main.o trace.o queue.o drop.o animation.o agent.o feature.o route.o transform.o paint.o state.o monitor.o anetmodel.o rng.o view.o graphview.o netgraph.o tracehook.o lan.o psview.o group.o editview.o tag.o address.o animator.o wnetmodel.o nam_stream.o enetmodel.o testview.o parser.o trafficsource.o lossmodel.o queuehandle.o gen/version.o gen/nam_tcl.o  ../tcl8.5.10/unix/libtcl8.5.a ../tk8.5.10/unix/libtk8.5.a ../tcl8.5.10/unix/libtclstub8.5.a -L../tclcl-1.20 -ltclcl -L../otcl -lotcl -L/usr/lib -lz -L/usr/X11R6/lib -lXext -lX11 -lm -L. -lcorefoundation"
    g++ -o nam tkcompat.o tkUnixInit.o xwd.o netview.o netmodel.o edge.o packet.o node.o main.o trace.o queue.o drop.o animation.o agent.o feature.o route.o transform.o paint.o state.o monitor.o anetmodel.o rng.o view.o graphview.o netgraph.o tracehook.o lan.o psview.o group.o editview.o tag.o address.o animator.o wnetmodel.o nam_stream.o enetmodel.o testview.o parser.o trafficsource.o lossmodel.o queuehandle.o gen/version.o gen/nam_tcl.o  ../tcl8.5.10/unix/libtcl8.5.a ../tk8.5.10/unix/libtk8.5.a ../tcl8.5.10/unix/libtclstub8.5.a -L../tclcl-1.20 -ltclcl -L../otcl -lotcl -L/usr/lib -lz -L/usr/X11R6/lib -lXext -lX11 -lm -L. -lcorefoundation
    if [ -e nam ]; then
        echo "Nam relinking succeeded; nam has been installed successfully."
    else
        echo "Nam make failed! You may want to tweak the above linker path if libraries are not being picked up successfuly.  Continue ..."
        echo "See http://www.isi.edu/nsnam/ns-problems.html for problems"
    fi
else
    echo "Nam make failed! Continue ..."
    echo "See http://www.isi.edu/nsnam/ns-problems.html for problems"
fi

cd ../



# Building dei80211mr

cd ./dei80211mr-${DEI80211MRVER}

./configure --with-ns-allinone=${CUR_PATH} --prefix=${CUR_PATH} \
    && make \
    && make install

cd ..


# Install nam, ns, xgraph into bin

if [ ! -d bin ] ; then
    mkdir bin
fi

cd bin

ln -s $CUR_PATH/ns-$NSVER/ns${EXE} ns${EXE}

if test -x $CUR_PATH/nam-$NAMVER/nam${EXE}
then
    ln -s $CUR_PATH/nam-$NAMVER/nam${EXE} nam${EXE}
else
    echo "Please compile your nam separately."
fi

if test -x $CUR_PATH/xgraph-$XGRAPHVER/xgraph${EXE}
then
    ln -s $CUR_PATH/xgraph-$XGRAPHVER/xgraph${EXE} xgraph${EXE}
else
    echo "Please compile your xgraph separately."
fi

if test -x $CUR_PATH/gt-itm/bin/sgb2ns${EXE}
then 
    ln -s $CUR_PATH/gt-itm/bin/sgb2ns${EXE} sgb2ns${EXE}
    ln -s $CUR_PATH/gt-itm/bin/sgb2hierns${EXE} sgb2hierns${EXE}
    ln -s $CUR_PATH/gt-itm/bin/sgb2comns${EXE} sgb2comns${EXE}
    ln -s $CUR_PATH/gt-itm/bin/itm${EXE} itm${EXE}
    ln -s $CUR_PATH/gt-itm/bin/sgb2alt${EXE} sgb2alt${EXE}
    ln -s $CUR_PATH/gt-itm/bin/edriver${EXE} edriver${EXE}
else
    echo "Please compile your gt-itm & sgb2ns separately."
fi

echo ""
echo "Ns-allinone package has been installed successfully."
echo "Here are the installation places:"
echo "tcl$TCLVER:	$CUR_PATH/{bin,include,lib}"
echo "tk$TKVER:		$CUR_PATH/{bin,include,lib}"
echo "otcl:		$CUR_PATH/otcl-$OTCLVER"
echo "tclcl:		$CUR_PATH/tclcl-$TCLCLVER"
echo "ns:		$CUR_PATH/ns-$NSVER/ns"

if [ -x $CUR_PATH/nam-$NAMVER/nam ]
then
echo "nam:	$CUR_PATH/nam-$NAMVER/nam"
fi

if [ -x $CUR_PATH/xgraph-$XGRAPHVER/xgraph ]
then
echo "xgraph:	$CUR_PATH/xgraph-$XGRAPHVER"
fi
if [ -x $CUR_PATH/gt-itm/bin/sgb2ns ] 
then
echo "gt-itm:   $CUR_PATH/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns"
fi

echo ""
echo "----------------------------------------------------------------------------------"
echo "The install script will automatically add environment variable to your system,if you run \"ns\" and then system says \"command not found\", you should check your environment varible (~/.bash_profile or ~/.bash_rc)"
echo "Please put $CUR_PATH/bin:$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix" 
echo "into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph."
#Add env var
echo "export PATH=$PATH:$CUR_PATH/bin:$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix" >>~/.bash_profile
echo ""
echo "IMPORTANT NOTICES:"
echo ""
echo "(1) You MUST put $CUR_PATH/otcl-$OTCLVER, $CUR_PATH/lib, "
echo "    into your LD_LIBRARY_PATH environment variable."
#Add env var
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUR_PATH/otcl-$OTCLVER:$CUR_PATH/lib" >>~/.bash_profile

echo "    If it complains about X libraries, add path to your X libraries "
echo "    into LD_LIBRARY_PATH."
echo "    If you are using csh, you can set it like:"
echo "		setenv LD_LIBRARY_PATH "
echo "    If you are using sh, you can set it like:"
echo "		export LD_LIBRARY_PATH="
echo ""
echo "(2) You MUST put $CUR_PATH/tcl$TCLVER/library into your TCL_LIBRARY environmental"
#Add env var
echo "export TCL_LIBRARY=$TCL_LIBRARY:$CUR_PATH/tcl$TCLVER/library " >>~/.bash_profile

echo "    variable. Otherwise ns/nam will complain during startup."
echo ""
echo ""
echo "After these steps, you can now run the ns validation suite with"
echo "cd ns-$NSVER; ./validate"
echo ""
echo "For trouble shooting, please first read ns problems page "
echo "http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive"
echo "for related posts." 
echo ""

exit 0



你可能感兴趣的:(C/C++,ns-2,mac)