From d2c2cf3296eaaa746134f20655be6770232c79c3 Mon Sep 17 00:00:00 2001
From: Jim Miller <millerjv@crd.ge.com>
Date: Mon, 25 Jun 2001 13:34:09 -0400
Subject: FIX: added AddDefinition() to store site name and build name in
 makefile.  Also stripped      white space from the result of hostname.

---
 Source/cmBuildNameCommand.cxx |  2 ++
 Source/cmSiteNameCommand.cxx  | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 53f5b1d..f5f0658 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -86,6 +86,8 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
                   buildname.c_str(),
                   "Name of build.",
                   cmCacheManager::STRING);
+
+  m_Makefile->AddDefinition("BUILDNAME", buildname.c_str());
   return true;
 }
 
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index 5ebc707..fe81cd7 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -69,9 +69,22 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
   std::string host;
   cmSystemTools::RunCommand(hostname,
                             host);
+  if (host.length())
+    {
+    // remove any white space from the host name
+    std::string hostRegExp = "[ \t\n\r]*([^\t\n\r ]*)[ \t\n\r]*";
+    cmRegularExpression hostReg (hostRegExp.c_str());
+    if (hostReg.find(host.c_str()))
+      {
+      // strip whitespace
+      host = hostReg.match(1);
+      }
+    }
+  
   std::string siteName = host;
   if(host.length())
     {
+    // try to find the domain name for this computer
     std::string nsCmd = nslookup;
     nsCmd += " ";
     nsCmd += host;
@@ -93,6 +106,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
                   siteName.c_str(),
                   "Name of the computer/site where compile is being run",
                   cmCacheManager::STRING);
+
+  m_Makefile->AddDefinition("SITE", siteName.c_str());
   return true;
 }
 
-- 
cgit v0.12