Code

remove rudimental general-purpose clipart, add some Inkscape-related graphics, update...
[inkscape.git] / buildtool.cpp
index 90ccd69668671e6cbc2d9e5c1191f1a330bf10fd..f78bf8ee87b9f6b16335b5e5978ee5421c056c6d 100644 (file)
 /**
  * To use this file, compile with:
  * <pre>
- * g++ -O3 buildtool.cpp -o build.exe
+ * g++ -O3 buildtool.cpp -o btool.exe
  * (or whatever your compiler might be) 
  * Then
- * build
+ * btool
  * or 
- * build {target}
+ * btool {target}
  */  
 
 
 #endif
 
 
+#include <errno.h>
+
+
+//########################################################################
+//# Definition of gettimeofday() for those who don't have it
+//########################################################################
+#ifdef __WIN32__
+#include <sys/timeb.h>
+struct timezone {
+      int tz_minuteswest; /* minutes west of Greenwich */
+      int tz_dsttime;     /* type of dst correction */
+    };
+
+static int gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+   struct _timeb tb;
+
+   if (!tv)
+      return (-1);
+
+    _ftime (&tb);
+    tv->tv_sec  = tb.time;
+    tv->tv_usec = tb.millitm * 1000 + 500;
+    if (tz)
+        {
+        tz->tz_minuteswest = -60 * _timezone;
+        tz->tz_dsttime = _daylight;
+        }
+    return 0;
+}
+#endif
+
+
+
+
+
+
 
 namespace buildtool
 {
 
 
 
+
 //########################################################################
 //########################################################################
 //##  R E G E X P
@@ -76,29 +114,29 @@ namespace buildtool
 #ifndef _TREX_H_
 #define _TREX_H_
 /***************************************************************
-       T-Rex a tiny regular expression library
+    T-Rex a tiny regular expression library
 
-       Copyright (C) 2003-2006 Alberto Demichelis
+    Copyright (C) 2003-2006 Alberto Demichelis
 
-       This software is provided 'as-is', without any express 
-       or implied warranty. In no event will the authors be held 
-       liable for any damages arising from the use of this software.
+    This software is provided 'as-is', without any express 
+    or implied warranty. In no event will the authors be held 
+    liable for any damages arising from the use of this software.
 
-       Permission is granted to anyone to use this software for 
-       any purpose, including commercial applications, and to alter
-       it and redistribute it freely, subject to the following restrictions:
+    Permission is granted to anyone to use this software for 
+    any purpose, including commercial applications, and to alter
+    it and redistribute it freely, subject to the following restrictions:
 
-               1. The origin of this software must not be misrepresented;
-               you must not claim that you wrote the original software.
-               If you use this software in a product, an acknowledgment
-               in the product documentation would be appreciated but
-               is not required.
+        1. The origin of this software must not be misrepresented;
+        you must not claim that you wrote the original software.
+        If you use this software in a product, an acknowledgment
+        in the product documentation would be appreciated but
+        is not required.
 
-               2. Altered source versions must be plainly marked as such,
-               and must not be misrepresented as being the original software.
+        2. Altered source versions must be plainly marked as such,
+        and must not be misrepresented as being the original software.
 
-               3. This notice may not be removed or altered from any
-               source distribution.
+        3. This notice may not be removed or altered from any
+        source distribution.
 
 ****************************************************************/
 
@@ -127,8 +165,8 @@ typedef unsigned int TRexBool;
 typedef struct TRex TRex;
 
 typedef struct {
-       const TRexChar *begin;
-       int len;
+    const TRexChar *begin;
+    int len;
 } TRexMatch;
 
 TREX_API TRex *trex_compile(const TRexChar *pattern,const TRexChar **error);
@@ -173,26 +211,26 @@ TREX_API TRexBool trex_getsubexp(TRex* exp, int n, TRexMatch *subexp);
 
 static const TRexChar *g_nnames[] =
 {
-       _SC("NONE"),_SC("OP_GREEDY"),   _SC("OP_OR"),
-       _SC("OP_EXPR"),_SC("OP_NOCAPEXPR"),_SC("OP_DOT"),       _SC("OP_CLASS"),
-       _SC("OP_CCLASS"),_SC("OP_NCLASS"),_SC("OP_RANGE"),_SC("OP_CHAR"),
-       _SC("OP_EOL"),_SC("OP_BOL"),_SC("OP_WB")
+    _SC("NONE"),_SC("OP_GREEDY"),    _SC("OP_OR"),
+    _SC("OP_EXPR"),_SC("OP_NOCAPEXPR"),_SC("OP_DOT"),    _SC("OP_CLASS"),
+    _SC("OP_CCLASS"),_SC("OP_NCLASS"),_SC("OP_RANGE"),_SC("OP_CHAR"),
+    _SC("OP_EOL"),_SC("OP_BOL"),_SC("OP_WB")
 };
 
 #endif
-#define OP_GREEDY              (MAX_CHAR+1) // * + ? {n}
-#define OP_OR                  (MAX_CHAR+2)
-#define OP_EXPR                        (MAX_CHAR+3) //parentesis ()
-#define OP_NOCAPEXPR   (MAX_CHAR+4) //parentesis (?:)
-#define OP_DOT                 (MAX_CHAR+5)
-#define OP_CLASS               (MAX_CHAR+6)
-#define OP_CCLASS              (MAX_CHAR+7)
-#define OP_NCLASS              (MAX_CHAR+8) //negates class the [^
-#define OP_RANGE               (MAX_CHAR+9)
-#define OP_CHAR                        (MAX_CHAR+10)
-#define OP_EOL                 (MAX_CHAR+11)
-#define OP_BOL                 (MAX_CHAR+12)
-#define OP_WB                  (MAX_CHAR+13)
+#define OP_GREEDY        (MAX_CHAR+1) // * + ? {n}
+#define OP_OR            (MAX_CHAR+2)
+#define OP_EXPR            (MAX_CHAR+3) //parentesis ()
+#define OP_NOCAPEXPR    (MAX_CHAR+4) //parentesis (?:)
+#define OP_DOT            (MAX_CHAR+5)
+#define OP_CLASS        (MAX_CHAR+6)
+#define OP_CCLASS        (MAX_CHAR+7)
+#define OP_NCLASS        (MAX_CHAR+8) //negates class the [^
+#define OP_RANGE        (MAX_CHAR+9)
+#define OP_CHAR            (MAX_CHAR+10)
+#define OP_EOL            (MAX_CHAR+11)
+#define OP_BOL            (MAX_CHAR+12)
+#define OP_WB            (MAX_CHAR+13)
 
 #define TREX_SYMBOL_ANY_CHAR ('.')
 #define TREX_SYMBOL_GREEDY_ONE_OR_MORE ('+')
@@ -207,589 +245,589 @@ static const TRexChar *g_nnames[] =
 typedef int TRexNodeType;
 
 typedef struct tagTRexNode{
-       TRexNodeType type;
-       int left;
-       int right;
-       int next;
+    TRexNodeType type;
+    int left;
+    int right;
+    int next;
 }TRexNode;
 
 struct TRex{
-       const TRexChar *_eol;
-       const TRexChar *_bol;
-       const TRexChar *_p;
-       int _first;
-       int _op;
-       TRexNode *_nodes;
-       int _nallocated;
-       int _nsize;
-       int _nsubexpr;
-       TRexMatch *_matches;
-       int _currsubexp;
-       void *_jmpbuf;
-       const TRexChar **_error;
+    const TRexChar *_eol;
+    const TRexChar *_bol;
+    const TRexChar *_p;
+    int _first;
+    int _op;
+    TRexNode *_nodes;
+    int _nallocated;
+    int _nsize;
+    int _nsubexpr;
+    TRexMatch *_matches;
+    int _currsubexp;
+    void *_jmpbuf;
+    const TRexChar **_error;
 };
 
 static int trex_list(TRex *exp);
 
 static int trex_newnode(TRex *exp, TRexNodeType type)
 {
-       TRexNode n;
-       int newid;
-       n.type = type;
-       n.next = n.right = n.left = -1;
-       if(type == OP_EXPR)
-               n.right = exp->_nsubexpr++;
-       if(exp->_nallocated < (exp->_nsize + 1)) {
-               //int oldsize = exp->_nallocated;
-               exp->_nallocated *= 2;
-               exp->_nodes = (TRexNode *)realloc(exp->_nodes, exp->_nallocated * sizeof(TRexNode));
-       }
-       exp->_nodes[exp->_nsize++] = n;
-       newid = exp->_nsize - 1;
-       return (int)newid;
+    TRexNode n;
+    int newid;
+    n.type = type;
+    n.next = n.right = n.left = -1;
+    if(type == OP_EXPR)
+        n.right = exp->_nsubexpr++;
+    if(exp->_nallocated < (exp->_nsize + 1)) {
+        //int oldsize = exp->_nallocated;
+        exp->_nallocated *= 2;
+        exp->_nodes = (TRexNode *)realloc(exp->_nodes, exp->_nallocated * sizeof(TRexNode));
+    }
+    exp->_nodes[exp->_nsize++] = n;
+    newid = exp->_nsize - 1;
+    return (int)newid;
 }
 
 static void trex_error(TRex *exp,const TRexChar *error)
 {
-       if(exp->_error) *exp->_error = error;
-       longjmp(*((jmp_buf*)exp->_jmpbuf),-1);
+    if(exp->_error) *exp->_error = error;
+    longjmp(*((jmp_buf*)exp->_jmpbuf),-1);
 }
 
 static void trex_expect(TRex *exp, int n){
-       if((*exp->_p) != n) 
-               trex_error(exp, _SC("expected paren"));
-       exp->_p++;
+    if((*exp->_p) != n) 
+        trex_error(exp, _SC("expected paren"));
+    exp->_p++;
 }
 
 static TRexChar trex_escapechar(TRex *exp)
 {
-       if(*exp->_p == TREX_SYMBOL_ESCAPE_CHAR){
-               exp->_p++;
-               switch(*exp->_p) {
-               case 'v': exp->_p++; return '\v';
-               case 'n': exp->_p++; return '\n';
-               case 't': exp->_p++; return '\t';
-               case 'r': exp->_p++; return '\r';
-               case 'f': exp->_p++; return '\f';
-               default: return (*exp->_p++);
-               }
-       } else if(!scisprint(*exp->_p)) trex_error(exp,_SC("letter expected"));
-       return (*exp->_p++);
+    if(*exp->_p == TREX_SYMBOL_ESCAPE_CHAR){
+        exp->_p++;
+        switch(*exp->_p) {
+        case 'v': exp->_p++; return '\v';
+        case 'n': exp->_p++; return '\n';
+        case 't': exp->_p++; return '\t';
+        case 'r': exp->_p++; return '\r';
+        case 'f': exp->_p++; return '\f';
+        default: return (*exp->_p++);
+        }
+    } else if(!scisprint(*exp->_p)) trex_error(exp,_SC("letter expected"));
+    return (*exp->_p++);
 }
 
 static int trex_charclass(TRex *exp,int classid)
 {
-       int n = trex_newnode(exp,OP_CCLASS);
-       exp->_nodes[n].left = classid;
-       return n;
+    int n = trex_newnode(exp,OP_CCLASS);
+    exp->_nodes[n].left = classid;
+    return n;
 }
 
 static int trex_charnode(TRex *exp,TRexBool isclass)
 {
-       TRexChar t;
-       if(*exp->_p == TREX_SYMBOL_ESCAPE_CHAR) {
-               exp->_p++;
-               switch(*exp->_p) {
-                       case 'n': exp->_p++; return trex_newnode(exp,'\n');
-                       case 't': exp->_p++; return trex_newnode(exp,'\t');
-                       case 'r': exp->_p++; return trex_newnode(exp,'\r');
-                       case 'f': exp->_p++; return trex_newnode(exp,'\f');
-                       case 'v': exp->_p++; return trex_newnode(exp,'\v');
-                       case 'a': case 'A': case 'w': case 'W': case 's': case 'S': 
-                       case 'd': case 'D': case 'x': case 'X': case 'c': case 'C': 
-                       case 'p': case 'P': case 'l': case 'u': 
-                               {
-                               t = *exp->_p; exp->_p++; 
-                               return trex_charclass(exp,t);
-                               }
-                       case 'b': 
-                       case 'B':
-                               if(!isclass) {
-                                       int node = trex_newnode(exp,OP_WB);
-                                       exp->_nodes[node].left = *exp->_p;
-                                       exp->_p++; 
-                                       return node;
-                               } //else default
-                       default: 
-                               t = *exp->_p; exp->_p++; 
-                               return trex_newnode(exp,t);
-               }
-       }
-       else if(!scisprint(*exp->_p)) {
-               
-               trex_error(exp,_SC("letter expected"));
-       }
-       t = *exp->_p; exp->_p++; 
-       return trex_newnode(exp,t);
+    TRexChar t;
+    if(*exp->_p == TREX_SYMBOL_ESCAPE_CHAR) {
+        exp->_p++;
+        switch(*exp->_p) {
+            case 'n': exp->_p++; return trex_newnode(exp,'\n');
+            case 't': exp->_p++; return trex_newnode(exp,'\t');
+            case 'r': exp->_p++; return trex_newnode(exp,'\r');
+            case 'f': exp->_p++; return trex_newnode(exp,'\f');
+            case 'v': exp->_p++; return trex_newnode(exp,'\v');
+            case 'a': case 'A': case 'w': case 'W': case 's': case 'S': 
+            case 'd': case 'D': case 'x': case 'X': case 'c': case 'C': 
+            case 'p': case 'P': case 'l': case 'u': 
+                {
+                t = *exp->_p; exp->_p++; 
+                return trex_charclass(exp,t);
+                }
+            case 'b': 
+            case 'B':
+                if(!isclass) {
+                    int node = trex_newnode(exp,OP_WB);
+                    exp->_nodes[node].left = *exp->_p;
+                    exp->_p++; 
+                    return node;
+                } //else default
+            default: 
+                t = *exp->_p; exp->_p++; 
+                return trex_newnode(exp,t);
+        }
+    }
+    else if(!scisprint(*exp->_p)) {
+        
+        trex_error(exp,_SC("letter expected"));
+    }
+    t = *exp->_p; exp->_p++; 
+    return trex_newnode(exp,t);
 }
 static int trex_class(TRex *exp)
 {
-       int ret = -1;
-       int first = -1,chain;
-       if(*exp->_p == TREX_SYMBOL_BEGINNING_OF_STRING){
-               ret = trex_newnode(exp,OP_NCLASS);
-               exp->_p++;
-       }else ret = trex_newnode(exp,OP_CLASS);
-       
-       if(*exp->_p == ']') trex_error(exp,_SC("empty class"));
-       chain = ret;
-       while(*exp->_p != ']' && exp->_p != exp->_eol) {
-               if(*exp->_p == '-' && first != -1){ 
-                       int r,t;
-                       if(*exp->_p++ == ']') trex_error(exp,_SC("unfinished range"));
-                       r = trex_newnode(exp,OP_RANGE);
-                       if(first>*exp->_p) trex_error(exp,_SC("invalid range"));
-                       if(exp->_nodes[first].type == OP_CCLASS) trex_error(exp,_SC("cannot use character classes in ranges"));
-                       exp->_nodes[r].left = exp->_nodes[first].type;
-                       t = trex_escapechar(exp);
-                       exp->_nodes[r].right = t;
+    int ret = -1;
+    int first = -1,chain;
+    if(*exp->_p == TREX_SYMBOL_BEGINNING_OF_STRING){
+        ret = trex_newnode(exp,OP_NCLASS);
+        exp->_p++;
+    }else ret = trex_newnode(exp,OP_CLASS);
+    
+    if(*exp->_p == ']') trex_error(exp,_SC("empty class"));
+    chain = ret;
+    while(*exp->_p != ']' && exp->_p != exp->_eol) {
+        if(*exp->_p == '-' && first != -1){ 
+            int r,t;
+            if(*exp->_p++ == ']') trex_error(exp,_SC("unfinished range"));
+            r = trex_newnode(exp,OP_RANGE);
+            if(first>*exp->_p) trex_error(exp,_SC("invalid range"));
+            if(exp->_nodes[first].type == OP_CCLASS) trex_error(exp,_SC("cannot use character classes in ranges"));
+            exp->_nodes[r].left = exp->_nodes[first].type;
+            t = trex_escapechar(exp);
+            exp->_nodes[r].right = t;
             exp->_nodes[chain].next = r;
-                       chain = r;
-                       first = -1;
-               }
-               else{
-                       if(first!=-1){
-                               int c = first;
-                               exp->_nodes[chain].next = c;
-                               chain = c;
-                               first = trex_charnode(exp,TRex_True);
-                       }
-                       else{
-                               first = trex_charnode(exp,TRex_True);
-                       }
-               }
-       }
-       if(first!=-1){
-               int c = first;
-               exp->_nodes[chain].next = c;
-               chain = c;
-               first = -1;
-       }
-       /* hack? */
-       exp->_nodes[ret].left = exp->_nodes[ret].next;
-       exp->_nodes[ret].next = -1;
-       return ret;
+            chain = r;
+            first = -1;
+        }
+        else{
+            if(first!=-1){
+                int c = first;
+                exp->_nodes[chain].next = c;
+                chain = c;
+                first = trex_charnode(exp,TRex_True);
+            }
+            else{
+                first = trex_charnode(exp,TRex_True);
+            }
+        }
+    }
+    if(first!=-1){
+        int c = first;
+        exp->_nodes[chain].next = c;
+        chain = c;
+        first = -1;
+    }
+    /* hack? */
+    exp->_nodes[ret].left = exp->_nodes[ret].next;
+    exp->_nodes[ret].next = -1;
+    return ret;
 }
 
 static int trex_parsenumber(TRex *exp)
 {
-       int ret = *exp->_p-'0';
-       int positions = 10;
-       exp->_p++;
-       while(isdigit(*exp->_p)) {
-               ret = ret*10+(*exp->_p++-'0');
-               if(positions==1000000000) trex_error(exp,_SC("overflow in numeric constant"));
-               positions *= 10;
-       };
-       return ret;
+    int ret = *exp->_p-'0';
+    int positions = 10;
+    exp->_p++;
+    while(isdigit(*exp->_p)) {
+        ret = ret*10+(*exp->_p++-'0');
+        if(positions==1000000000) trex_error(exp,_SC("overflow in numeric constant"));
+        positions *= 10;
+    };
+    return ret;
 }
 
 static int trex_element(TRex *exp)
 {
-       int ret = -1;
-       switch(*exp->_p)
-       {
-       case '(': {
-               int expr,newn;
-               exp->_p++;
-
-
-               if(*exp->_p =='?') {
-                       exp->_p++;
-                       trex_expect(exp,':');
-                       expr = trex_newnode(exp,OP_NOCAPEXPR);
-               }
-               else
-                       expr = trex_newnode(exp,OP_EXPR);
-               newn = trex_list(exp);
-               exp->_nodes[expr].left = newn;
-               ret = expr;
-               trex_expect(exp,')');
-                         }
-                         break;
-       case '[':
-               exp->_p++;
-               ret = trex_class(exp);
-               trex_expect(exp,']');
-               break;
-       case TREX_SYMBOL_END_OF_STRING: exp->_p++; ret = trex_newnode(exp,OP_EOL);break;
-       case TREX_SYMBOL_ANY_CHAR: exp->_p++; ret = trex_newnode(exp,OP_DOT);break;
-       default:
-               ret = trex_charnode(exp,TRex_False);
-               break;
-       }
-
-       {
-               int op;
-               TRexBool isgreedy = TRex_False;
-               unsigned short p0 = 0, p1 = 0;
-               switch(*exp->_p){
-                       case TREX_SYMBOL_GREEDY_ZERO_OR_MORE: p0 = 0; p1 = 0xFFFF; exp->_p++; isgreedy = TRex_True; break;
-                       case TREX_SYMBOL_GREEDY_ONE_OR_MORE: p0 = 1; p1 = 0xFFFF; exp->_p++; isgreedy = TRex_True; break;
-                       case TREX_SYMBOL_GREEDY_ZERO_OR_ONE: p0 = 0; p1 = 1; exp->_p++; isgreedy = TRex_True; break;
-                       case '{':
-                               exp->_p++;
-                               if(!isdigit(*exp->_p)) trex_error(exp,_SC("number expected"));
-                               p0 = (unsigned short)trex_parsenumber(exp);
-                               /*******************************/
-                               switch(*exp->_p) {
-                       case '}':
-                               p1 = p0; exp->_p++;
-                               break;
-                       case ',':
-                               exp->_p++;
-                               p1 = 0xFFFF;
-                               if(isdigit(*exp->_p)){
-                                       p1 = (unsigned short)trex_parsenumber(exp);
-                               }
-                               trex_expect(exp,'}');
-                               break;
-                       default:
-                               trex_error(exp,_SC(", or } expected"));
-               }
-               /*******************************/
-               isgreedy = TRex_True; 
-               break;
-
-               }
-               if(isgreedy) {
-                       int nnode = trex_newnode(exp,OP_GREEDY);
-                       op = OP_GREEDY;
-                       exp->_nodes[nnode].left = ret;
-                       exp->_nodes[nnode].right = ((p0)<<16)|p1;
-                       ret = nnode;
-               }
-       }
-       if((*exp->_p != TREX_SYMBOL_BRANCH) && (*exp->_p != ')') && (*exp->_p != TREX_SYMBOL_GREEDY_ZERO_OR_MORE) && (*exp->_p != TREX_SYMBOL_GREEDY_ONE_OR_MORE) && (*exp->_p != '\0')) {
-               int nnode = trex_element(exp);
-               exp->_nodes[ret].next = nnode;
-       }
-
-       return ret;
+    int ret = -1;
+    switch(*exp->_p)
+    {
+    case '(': {
+        int expr,newn;
+        exp->_p++;
+
+
+        if(*exp->_p =='?') {
+            exp->_p++;
+            trex_expect(exp,':');
+            expr = trex_newnode(exp,OP_NOCAPEXPR);
+        }
+        else
+            expr = trex_newnode(exp,OP_EXPR);
+        newn = trex_list(exp);
+        exp->_nodes[expr].left = newn;
+        ret = expr;
+        trex_expect(exp,')');
+              }
+              break;
+    case '[':
+        exp->_p++;
+        ret = trex_class(exp);
+        trex_expect(exp,']');
+        break;
+    case TREX_SYMBOL_END_OF_STRING: exp->_p++; ret = trex_newnode(exp,OP_EOL);break;
+    case TREX_SYMBOL_ANY_CHAR: exp->_p++; ret = trex_newnode(exp,OP_DOT);break;
+    default:
+        ret = trex_charnode(exp,TRex_False);
+        break;
+    }
+
+    {
+        int op;
+        TRexBool isgreedy = TRex_False;
+        unsigned short p0 = 0, p1 = 0;
+        switch(*exp->_p){
+            case TREX_SYMBOL_GREEDY_ZERO_OR_MORE: p0 = 0; p1 = 0xFFFF; exp->_p++; isgreedy = TRex_True; break;
+            case TREX_SYMBOL_GREEDY_ONE_OR_MORE: p0 = 1; p1 = 0xFFFF; exp->_p++; isgreedy = TRex_True; break;
+            case TREX_SYMBOL_GREEDY_ZERO_OR_ONE: p0 = 0; p1 = 1; exp->_p++; isgreedy = TRex_True; break;
+            case '{':
+                exp->_p++;
+                if(!isdigit(*exp->_p)) trex_error(exp,_SC("number expected"));
+                p0 = (unsigned short)trex_parsenumber(exp);
+                /*******************************/
+                switch(*exp->_p) {
+            case '}':
+                p1 = p0; exp->_p++;
+                break;
+            case ',':
+                exp->_p++;
+                p1 = 0xFFFF;
+                if(isdigit(*exp->_p)){
+                    p1 = (unsigned short)trex_parsenumber(exp);
+                }
+                trex_expect(exp,'}');
+                break;
+            default:
+                trex_error(exp,_SC(", or } expected"));
+        }
+        /*******************************/
+        isgreedy = TRex_True; 
+        break;
+
+        }
+        if(isgreedy) {
+            int nnode = trex_newnode(exp,OP_GREEDY);
+            op = OP_GREEDY;
+            exp->_nodes[nnode].left = ret;
+            exp->_nodes[nnode].right = ((p0)<<16)|p1;
+            ret = nnode;
+        }
+    }
+    if((*exp->_p != TREX_SYMBOL_BRANCH) && (*exp->_p != ')') && (*exp->_p != TREX_SYMBOL_GREEDY_ZERO_OR_MORE) && (*exp->_p != TREX_SYMBOL_GREEDY_ONE_OR_MORE) && (*exp->_p != '\0')) {
+        int nnode = trex_element(exp);
+        exp->_nodes[ret].next = nnode;
+    }
+
+    return ret;
 }
 
 static int trex_list(TRex *exp)
 {
-       int ret=-1,e;
-       if(*exp->_p == TREX_SYMBOL_BEGINNING_OF_STRING) {
-               exp->_p++;
-               ret = trex_newnode(exp,OP_BOL);
-       }
-       e = trex_element(exp);
-       if(ret != -1) {
-               exp->_nodes[ret].next = e;
-       }
-       else ret = e;
-
-       if(*exp->_p == TREX_SYMBOL_BRANCH) {
-               int temp,tright;
-               exp->_p++;
-               temp = trex_newnode(exp,OP_OR);
-               exp->_nodes[temp].left = ret;
-               tright = trex_list(exp);
-               exp->_nodes[temp].right = tright;
-               ret = temp;
-       }
-       return ret;
+    int ret=-1,e;
+    if(*exp->_p == TREX_SYMBOL_BEGINNING_OF_STRING) {
+        exp->_p++;
+        ret = trex_newnode(exp,OP_BOL);
+    }
+    e = trex_element(exp);
+    if(ret != -1) {
+        exp->_nodes[ret].next = e;
+    }
+    else ret = e;
+
+    if(*exp->_p == TREX_SYMBOL_BRANCH) {
+        int temp,tright;
+        exp->_p++;
+        temp = trex_newnode(exp,OP_OR);
+        exp->_nodes[temp].left = ret;
+        tright = trex_list(exp);
+        exp->_nodes[temp].right = tright;
+        ret = temp;
+    }
+    return ret;
 }
 
 static TRexBool trex_matchcclass(int cclass,TRexChar c)
 {
-       switch(cclass) {
-       case 'a': return isalpha(c)?TRex_True:TRex_False;
-       case 'A': return !isalpha(c)?TRex_True:TRex_False;
-       case 'w': return (isalnum(c) || c == '_')?TRex_True:TRex_False;
-       case 'W': return (!isalnum(c) && c != '_')?TRex_True:TRex_False;
-       case 's': return isspace(c)?TRex_True:TRex_False;
-       case 'S': return !isspace(c)?TRex_True:TRex_False;
-       case 'd': return isdigit(c)?TRex_True:TRex_False;
-       case 'D': return !isdigit(c)?TRex_True:TRex_False;
-       case 'x': return isxdigit(c)?TRex_True:TRex_False;
-       case 'X': return !isxdigit(c)?TRex_True:TRex_False;
-       case 'c': return iscntrl(c)?TRex_True:TRex_False;
-       case 'C': return !iscntrl(c)?TRex_True:TRex_False;
-       case 'p': return ispunct(c)?TRex_True:TRex_False;
-       case 'P': return !ispunct(c)?TRex_True:TRex_False;
-       case 'l': return islower(c)?TRex_True:TRex_False;
-       case 'u': return isupper(c)?TRex_True:TRex_False;
-       }
-       return TRex_False; /*cannot happen*/
+    switch(cclass) {
+    case 'a': return isalpha(c)?TRex_True:TRex_False;
+    case 'A': return !isalpha(c)?TRex_True:TRex_False;
+    case 'w': return (isalnum(c) || c == '_')?TRex_True:TRex_False;
+    case 'W': return (!isalnum(c) && c != '_')?TRex_True:TRex_False;
+    case 's': return isspace(c)?TRex_True:TRex_False;
+    case 'S': return !isspace(c)?TRex_True:TRex_False;
+    case 'd': return isdigit(c)?TRex_True:TRex_False;
+    case 'D': return !isdigit(c)?TRex_True:TRex_False;
+    case 'x': return isxdigit(c)?TRex_True:TRex_False;
+    case 'X': return !isxdigit(c)?TRex_True:TRex_False;
+    case 'c': return iscntrl(c)?TRex_True:TRex_False;
+    case 'C': return !iscntrl(c)?TRex_True:TRex_False;
+    case 'p': return ispunct(c)?TRex_True:TRex_False;
+    case 'P': return !ispunct(c)?TRex_True:TRex_False;
+    case 'l': return islower(c)?TRex_True:TRex_False;
+    case 'u': return isupper(c)?TRex_True:TRex_False;
+    }
+    return TRex_False; /*cannot happen*/
 }
 
 static TRexBool trex_matchclass(TRex* exp,TRexNode *node,TRexChar c)
 {
-       do {
-               switch(node->type) {
-                       case OP_RANGE:
-                               if(c >= node->left && c <= node->right) return TRex_True;
-                               break;
-                       case OP_CCLASS:
-                               if(trex_matchcclass(node->left,c)) return TRex_True;
-                               break;
-                       default:
-                               if(c == node->type)return TRex_True;
-               }
-       } while((node->next != -1) && (node = &exp->_nodes[node->next]));
-       return TRex_False;
+    do {
+        switch(node->type) {
+            case OP_RANGE:
+                if(c >= node->left && c <= node->right) return TRex_True;
+                break;
+            case OP_CCLASS:
+                if(trex_matchcclass(node->left,c)) return TRex_True;
+                break;
+            default:
+                if(c == node->type)return TRex_True;
+        }
+    } while((node->next != -1) && (node = &exp->_nodes[node->next]));
+    return TRex_False;
 }
 
 static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *str,TRexNode *next)
 {
-       
-       TRexNodeType type = node->type;
-       switch(type) {
-       case OP_GREEDY: {
-               //TRexNode *greedystop = (node->next != -1) ? &exp->_nodes[node->next] : NULL;
-               TRexNode *greedystop = NULL;
-               int p0 = (node->right >> 16)&0x0000FFFF, p1 = node->right&0x0000FFFF, nmaches = 0;
-               const TRexChar *s=str, *good = str;
-
-               if(node->next != -1) {
-                       greedystop = &exp->_nodes[node->next];
-               }
-               else {
-                       greedystop = next;
-               }
-
-               while((nmaches == 0xFFFF || nmaches < p1)) {
-
-                       const TRexChar *stop;
-                       if(!(s = trex_matchnode(exp,&exp->_nodes[node->left],s,greedystop)))
-                               break;
-                       nmaches++;
-                       good=s;
-                       if(greedystop) {
-                               //checks that 0 matches satisfy the expression(if so skips)
-                               //if not would always stop(for instance if is a '?')
-                               if(greedystop->type != OP_GREEDY ||
-                               (greedystop->type == OP_GREEDY && ((greedystop->right >> 16)&0x0000FFFF) != 0))
-                               {
-                                       TRexNode *gnext = NULL;
-                                       if(greedystop->next != -1) {
-                                               gnext = &exp->_nodes[greedystop->next];
-                                       }else if(next && next->next != -1){
-                                               gnext = &exp->_nodes[next->next];
-                                       }
-                                       stop = trex_matchnode(exp,greedystop,s,gnext);
-                                       if(stop) {
-                                               //if satisfied stop it
-                                               if(p0 == p1 && p0 == nmaches) break;
-                                               else if(nmaches >= p0 && p1 == 0xFFFF) break;
-                                               else if(nmaches >= p0 && nmaches <= p1) break;
-                                       }
-                               }
-                       }
-                       
-                       if(s >= exp->_eol)
-                               break;
-               }
-               if(p0 == p1 && p0 == nmaches) return good;
-               else if(nmaches >= p0 && p1 == 0xFFFF) return good;
-               else if(nmaches >= p0 && nmaches <= p1) return good;
-               return NULL;
-       }
-       case OP_OR: {
-                       const TRexChar *asd = str;
-                       TRexNode *temp=&exp->_nodes[node->left];
-                       while( (asd = trex_matchnode(exp,temp,asd,NULL)) ) {
-                               if(temp->next != -1)
-                                       temp = &exp->_nodes[temp->next];
-                               else
-                                       return asd;
-                       }
-                       asd = str;
-                       temp = &exp->_nodes[node->right];
-                       while( (asd = trex_matchnode(exp,temp,asd,NULL)) ) {
-                               if(temp->next != -1)
-                                       temp = &exp->_nodes[temp->next];
-                               else
-                                       return asd;
-                       }
-                       return NULL;
-                       break;
-       }
-       case OP_EXPR:
-       case OP_NOCAPEXPR:{
-                       TRexNode *n = &exp->_nodes[node->left];
-                       const TRexChar *cur = str;
-                       int capture = -1;
-                       if(node->type != OP_NOCAPEXPR && node->right == exp->_currsubexp) {
-                               capture = exp->_currsubexp;
-                               exp->_matches[capture].begin = cur;
-                               exp->_currsubexp++;
-                       }
-                       
-                       do {
-                               TRexNode *subnext = NULL;
-                               if(n->next != -1) {
-                                       subnext = &exp->_nodes[n->next];
-                               }else {
-                                       subnext = next;
-                               }
-                               if(!(cur = trex_matchnode(exp,n,cur,subnext))) {
-                                       if(capture != -1){
-                                               exp->_matches[capture].begin = 0;
-                                               exp->_matches[capture].len = 0;
-                                       }
-                                       return NULL;
-                               }
-                       } while((n->next != -1) && (n = &exp->_nodes[n->next]));
-
-                       if(capture != -1) 
-                               exp->_matches[capture].len = cur - exp->_matches[capture].begin;
-                       return cur;
-       }                                
-       case OP_WB:
-               if(str == exp->_bol && !isspace(*str)
-                || (str == exp->_eol && !isspace(*(str-1)))
-                || (!isspace(*str) && isspace(*(str+1)))
-                || (isspace(*str) && !isspace(*(str+1))) ) {
-                       return (node->left == 'b')?str:NULL;
-               }
-               return (node->left == 'b')?NULL:str;
-       case OP_BOL:
-               if(str == exp->_bol) return str;
-               return NULL;
-       case OP_EOL:
-               if(str == exp->_eol) return str;
-               return NULL;
-       case OP_DOT:{
-               *str++;
-                               }
-               return str;
-       case OP_NCLASS:
-       case OP_CLASS:
-               if(trex_matchclass(exp,&exp->_nodes[node->left],*str)?(type == OP_CLASS?TRex_True:TRex_False):(type == OP_NCLASS?TRex_True:TRex_False)) {
-                       *str++;
-                       return str;
-               }
-               return NULL;
-       case OP_CCLASS:
-               if(trex_matchcclass(node->left,*str)) {
-                       *str++;
-                       return str;
-               }
-               return NULL;
-       default: /* char */
-               if(*str != node->type) return NULL;
-               *str++;
-               return str;
-       }
-       return NULL;
+    
+    TRexNodeType type = node->type;
+    switch(type) {
+    case OP_GREEDY: {
+        //TRexNode *greedystop = (node->next != -1) ? &exp->_nodes[node->next] : NULL;
+        TRexNode *greedystop = NULL;
+        int p0 = (node->right >> 16)&0x0000FFFF, p1 = node->right&0x0000FFFF, nmaches = 0;
+        const TRexChar *s=str, *good = str;
+
+        if(node->next != -1) {
+            greedystop = &exp->_nodes[node->next];
+        }
+        else {
+            greedystop = next;
+        }
+
+        while((nmaches == 0xFFFF || nmaches < p1)) {
+
+            const TRexChar *stop;
+            if(!(s = trex_matchnode(exp,&exp->_nodes[node->left],s,greedystop)))
+                break;
+            nmaches++;
+            good=s;
+            if(greedystop) {
+                //checks that 0 matches satisfy the expression(if so skips)
+                //if not would always stop(for instance if is a '?')
+                if(greedystop->type != OP_GREEDY ||
+                (greedystop->type == OP_GREEDY && ((greedystop->right >> 16)&0x0000FFFF) != 0))
+                {
+                    TRexNode *gnext = NULL;
+                    if(greedystop->next != -1) {
+                        gnext = &exp->_nodes[greedystop->next];
+                    }else if(next && next->next != -1){
+                        gnext = &exp->_nodes[next->next];
+                    }
+                    stop = trex_matchnode(exp,greedystop,s,gnext);
+                    if(stop) {
+                        //if satisfied stop it
+                        if(p0 == p1 && p0 == nmaches) break;
+                        else if(nmaches >= p0 && p1 == 0xFFFF) break;
+                        else if(nmaches >= p0 && nmaches <= p1) break;
+                    }
+                }
+            }
+            
+            if(s >= exp->_eol)
+                break;
+        }
+        if(p0 == p1 && p0 == nmaches) return good;
+        else if(nmaches >= p0 && p1 == 0xFFFF) return good;
+        else if(nmaches >= p0 && nmaches <= p1) return good;
+        return NULL;
+    }
+    case OP_OR: {
+            const TRexChar *asd = str;
+            TRexNode *temp=&exp->_nodes[node->left];
+            while( (asd = trex_matchnode(exp,temp,asd,NULL)) ) {
+                if(temp->next != -1)
+                    temp = &exp->_nodes[temp->next];
+                else
+                    return asd;
+            }
+            asd = str;
+            temp = &exp->_nodes[node->right];
+            while( (asd = trex_matchnode(exp,temp,asd,NULL)) ) {
+                if(temp->next != -1)
+                    temp = &exp->_nodes[temp->next];
+                else
+                    return asd;
+            }
+            return NULL;
+            break;
+    }
+    case OP_EXPR:
+    case OP_NOCAPEXPR:{
+            TRexNode *n = &exp->_nodes[node->left];
+            const TRexChar *cur = str;
+            int capture = -1;
+            if(node->type != OP_NOCAPEXPR && node->right == exp->_currsubexp) {
+                capture = exp->_currsubexp;
+                exp->_matches[capture].begin = cur;
+                exp->_currsubexp++;
+            }
+            
+            do {
+                TRexNode *subnext = NULL;
+                if(n->next != -1) {
+                    subnext = &exp->_nodes[n->next];
+                }else {
+                    subnext = next;
+                }
+                if(!(cur = trex_matchnode(exp,n,cur,subnext))) {
+                    if(capture != -1){
+                        exp->_matches[capture].begin = 0;
+                        exp->_matches[capture].len = 0;
+                    }
+                    return NULL;
+                }
+            } while((n->next != -1) && (n = &exp->_nodes[n->next]));
+
+            if(capture != -1) 
+                exp->_matches[capture].len = cur - exp->_matches[capture].begin;
+            return cur;
+    }                 
+    case OP_WB:
+        if(str == exp->_bol && !isspace(*str)
+         || (str == exp->_eol && !isspace(*(str-1)))
+         || (!isspace(*str) && isspace(*(str+1)))
+         || (isspace(*str) && !isspace(*(str+1))) ) {
+            return (node->left == 'b')?str:NULL;
+        }
+        return (node->left == 'b')?NULL:str;
+    case OP_BOL:
+        if(str == exp->_bol) return str;
+        return NULL;
+    case OP_EOL:
+        if(str == exp->_eol) return str;
+        return NULL;
+    case OP_DOT:{
+        *str++;
+                }
+        return str;
+    case OP_NCLASS:
+    case OP_CLASS:
+        if(trex_matchclass(exp,&exp->_nodes[node->left],*str)?(type == OP_CLASS?TRex_True:TRex_False):(type == OP_NCLASS?TRex_True:TRex_False)) {
+            *str++;
+            return str;
+        }
+        return NULL;
+    case OP_CCLASS:
+        if(trex_matchcclass(node->left,*str)) {
+            *str++;
+            return str;
+        }
+        return NULL;
+    default: /* char */
+        if(*str != node->type) return NULL;
+        *str++;
+        return str;
+    }
+    return NULL;
 }
 
 /* public api */
 TRex *trex_compile(const TRexChar *pattern,const TRexChar **error)
 {
-       TRex *exp = (TRex *)malloc(sizeof(TRex));
-       exp->_eol = exp->_bol = NULL;
-       exp->_p = pattern;
-       exp->_nallocated = (int)scstrlen(pattern) * sizeof(TRexChar);
-       exp->_nodes = (TRexNode *)malloc(exp->_nallocated * sizeof(TRexNode));
-       exp->_nsize = 0;
-       exp->_matches = 0;
-       exp->_nsubexpr = 0;
-       exp->_first = trex_newnode(exp,OP_EXPR);
-       exp->_error = error;
-       exp->_jmpbuf = malloc(sizeof(jmp_buf));
-       if(setjmp(*((jmp_buf*)exp->_jmpbuf)) == 0) {
-               int res = trex_list(exp);
-               exp->_nodes[exp->_first].left = res;
-               if(*exp->_p!='\0')
-                       trex_error(exp,_SC("unexpected character"));
+    TRex *exp = (TRex *)malloc(sizeof(TRex));
+    exp->_eol = exp->_bol = NULL;
+    exp->_p = pattern;
+    exp->_nallocated = (int)scstrlen(pattern) * sizeof(TRexChar);
+    exp->_nodes = (TRexNode *)malloc(exp->_nallocated * sizeof(TRexNode));
+    exp->_nsize = 0;
+    exp->_matches = 0;
+    exp->_nsubexpr = 0;
+    exp->_first = trex_newnode(exp,OP_EXPR);
+    exp->_error = error;
+    exp->_jmpbuf = malloc(sizeof(jmp_buf));
+    if(setjmp(*((jmp_buf*)exp->_jmpbuf)) == 0) {
+        int res = trex_list(exp);
+        exp->_nodes[exp->_first].left = res;
+        if(*exp->_p!='\0')
+            trex_error(exp,_SC("unexpected character"));
 #ifdef _DEBUG
-               {
-                       int nsize,i;
-                       TRexNode *t;
-                       nsize = exp->_nsize;
-                       t = &exp->_nodes[0];
-                       scprintf(_SC("\n"));
-                       for(i = 0;i < nsize; i++) {
-                               if(exp->_nodes[i].type>MAX_CHAR)
-                                       scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
-                               else
-                                       scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type);
-                               scprintf(_SC("left %02d right %02d next %02d\n"),exp->_nodes[i].left,exp->_nodes[i].right,exp->_nodes[i].next);
-                       }
-                       scprintf(_SC("\n"));
-               }
+        {
+            int nsize,i;
+            TRexNode *t;
+            nsize = exp->_nsize;
+            t = &exp->_nodes[0];
+            scprintf(_SC("\n"));
+            for(i = 0;i < nsize; i++) {
+                if(exp->_nodes[i].type>MAX_CHAR)
+                    scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
+                else
+                    scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type);
+                scprintf(_SC("left %02d right %02d next %02d\n"),exp->_nodes[i].left,exp->_nodes[i].right,exp->_nodes[i].next);
+            }
+            scprintf(_SC("\n"));
+        }
 #endif
-               exp->_matches = (TRexMatch *) malloc(exp->_nsubexpr * sizeof(TRexMatch));
-               memset(exp->_matches,0,exp->_nsubexpr * sizeof(TRexMatch));
-       }
-       else{
-               trex_free(exp);
-               return NULL;
-       }
-       return exp;
+        exp->_matches = (TRexMatch *) malloc(exp->_nsubexpr * sizeof(TRexMatch));
+        memset(exp->_matches,0,exp->_nsubexpr * sizeof(TRexMatch));
+    }
+    else{
+        trex_free(exp);
+        return NULL;
+    }
+    return exp;
 }
 
 void trex_free(TRex *exp)
 {
-       if(exp) {
-               if(exp->_nodes) free(exp->_nodes);
-               if(exp->_jmpbuf) free(exp->_jmpbuf);
-               if(exp->_matches) free(exp->_matches);
-               free(exp);
-       }
+    if(exp)    {
+        if(exp->_nodes) free(exp->_nodes);
+        if(exp->_jmpbuf) free(exp->_jmpbuf);
+        if(exp->_matches) free(exp->_matches);
+        free(exp);
+    }
 }
 
 TRexBool trex_match(TRex* exp,const TRexChar* text)
 {
-       const TRexChar* res = NULL;
-       exp->_bol = text;
-       exp->_eol = text + scstrlen(text);
-       exp->_currsubexp = 0;
-       res = trex_matchnode(exp,exp->_nodes,text,NULL);
-       if(res == NULL || res != exp->_eol)
-               return TRex_False;
-       return TRex_True;
+    const TRexChar* res = NULL;
+    exp->_bol = text;
+    exp->_eol = text + scstrlen(text);
+    exp->_currsubexp = 0;
+    res = trex_matchnode(exp,exp->_nodes,text,NULL);
+    if(res == NULL || res != exp->_eol)
+        return TRex_False;
+    return TRex_True;
 }
 
 TRexBool trex_searchrange(TRex* exp,const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end)
 {
-       const TRexChar *cur = NULL;
-       int node = exp->_first;
-       if(text_begin >= text_end) return TRex_False;
-       exp->_bol = text_begin;
-       exp->_eol = text_end;
-       do {
-               cur = text_begin;
-               while(node != -1) {
-                       exp->_currsubexp = 0;
-                       cur = trex_matchnode(exp,&exp->_nodes[node],cur,NULL);
-                       if(!cur)
-                               break;
-                       node = exp->_nodes[node].next;
-               }
-               *text_begin++;
-       } while(cur == NULL && text_begin != text_end);
-
-       if(cur == NULL)
-               return TRex_False;
-
-       --text_begin;
-
-       if(out_begin) *out_begin = text_begin;
-       if(out_end) *out_end = cur;
-       return TRex_True;
+    const TRexChar *cur = NULL;
+    int node = exp->_first;
+    if(text_begin >= text_end) return TRex_False;
+    exp->_bol = text_begin;
+    exp->_eol = text_end;
+    do {
+        cur = text_begin;
+        while(node != -1) {
+            exp->_currsubexp = 0;
+            cur = trex_matchnode(exp,&exp->_nodes[node],cur,NULL);
+            if(!cur)
+                break;
+            node = exp->_nodes[node].next;
+        }
+        *text_begin++;
+    } while(cur == NULL && text_begin != text_end);
+
+    if(cur == NULL)
+        return TRex_False;
+
+    --text_begin;
+
+    if(out_begin) *out_begin = text_begin;
+    if(out_end) *out_end = cur;
+    return TRex_True;
 }
 
 TRexBool trex_search(TRex* exp,const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end)
 {
-       return trex_searchrange(exp,text,text + scstrlen(text),out_begin,out_end);
+    return trex_searchrange(exp,text,text + scstrlen(text),out_begin,out_end);
 }
 
 int trex_getsubexpcount(TRex* exp)
 {
-       return exp->_nsubexpr;
+    return exp->_nsubexpr;
 }
 
 TRexBool trex_getsubexp(TRex* exp, int n, TRexMatch *subexp)
 {
-       if( n<0 || n >= exp->_nsubexpr) return TRex_False;
-       *subexp = exp->_matches[n];
-       return TRex_True;
+    if( n<0 || n >= exp->_nsubexpr) return TRex_False;
+    *subexp = exp->_matches[n];
+    return TRex_True;
 }
 
 
@@ -2795,7 +2833,7 @@ public:
         {}
 
     /**
-     *         Return the URI of the file associated with this object 
+     *     Return the URI of the file associated with this object 
      */     
     URI getURI()
         { return uri; }
@@ -2824,7 +2862,7 @@ public:
 protected:
 
     /**
-     * The path to the file associated with this object
+     *    The path to the file associated with this object
      */     
     URI uri;
 
@@ -2859,7 +2897,7 @@ protected:
      * in delimiters.  Null-length substrings are ignored
      */  
     std::vector<String> tokenize(const String &val,
-                             const String &delimiters);
+                          const String &delimiters);
 
     /**
      *  replace runs of whitespace with a space
@@ -2885,30 +2923,30 @@ protected:
     /**
      * Execute a shell command.  Outbuf is a ref to a string
      * to catch the result.     
-     */             
+     */         
     bool executeCommand(const String &call,
-                           const String &inbuf,
-                                               String &outbuf,
-                                               String &errbuf);
+                        const String &inbuf,
+                        String &outbuf,
+                        String &errbuf);
     /**
      * List all directories in a given base and starting directory
      * It is usually called like:
-     *          bool ret = listDirectories("src", "", result);    
-     */             
+     *        bool ret = listDirectories("src", "", result);    
+     */         
     bool listDirectories(const String &baseName,
                          const String &dirname,
                          std::vector<String> &res);
 
     /**
      * Find all files in the named directory 
-     */             
+     */         
     bool listFiles(const String &baseName,
                    const String &dirname,
                    std::vector<String> &result);
 
     /**
      * Perform a listing for a fileset 
-     */             
+     */         
     bool listFiles(MakeBase &propRef, FileSet &fileSet);
 
     /**
@@ -2916,8 +2954,8 @@ protected:
      */  
     bool parsePatternSet(Element *elem,
                        MakeBase &propRef,
-                                          std::vector<String> &includes,
-                                          std::vector<String> &excludes);
+                       std::vector<String> &includes,
+                       std::vector<String> &excludes);
 
     /**
      * Parse a <fileset> entry, and determine which files
@@ -2925,7 +2963,7 @@ protected:
      */  
     bool parseFileSet(Element *elem,
                     MakeBase &propRef,
-                                       FileSet &fileSet);
+                    FileSet &fileSet);
 
     /**
      * Return this object's property list
@@ -2951,13 +2989,13 @@ protected:
 
     /**
      * Turn 'true' and 'false' into boolean values
-     */                    
+     */             
     bool getBool(const String &str, bool &val);
 
     /**
      * Create a directory, making intermediate dirs
      * if necessary
-     */                            
+     */                  
     bool createDirectory(const String &dirname);
 
     /**
@@ -2989,7 +3027,7 @@ private:
 
     /**
      * replace variable refs like ${a} with their values
-     */             
+     */         
     bool getSubstitutions(const String &s, String &result);
 
 
@@ -3061,30 +3099,30 @@ void MakeBase::trace(char *fmt, ...)
  */
 bool MakeBase::regexMatch(const String &str, const String &pattern)
 {
-       const TRexChar *terror = NULL;
-       const TRexChar *cpat = pattern.c_str();
-       TRex *expr = trex_compile(cpat, &terror);
-       if (!expr)
-           {
-           if (!terror)
-               terror = "undefined";
-               error("compilation error [%s]!\n", terror);
-           return false;
-               
+    const TRexChar *terror = NULL;
+    const TRexChar *cpat = pattern.c_str();
+    TRex *expr = trex_compile(cpat, &terror);
+    if (!expr)
+        {
+        if (!terror)
+            terror = "undefined";
+        error("compilation error [%s]!\n", terror);
+        return false;
+        } 
 
     bool ret = true;
 
-       const TRexChar *cstr = str.c_str();
-       if (trex_match(expr, cstr))
-               {
-               ret = true;
-               }
-       else
-           {
-               ret = false;
-               }
+    const TRexChar *cstr = str.c_str();
+    if (trex_match(expr, cstr))
+        {
+        ret = true;
+        }
+    else
+        {
+        ret = false;
+        }
 
-       trex_free(expr);
+    trex_free(expr);
 
     return ret;
 }
@@ -3194,16 +3232,16 @@ String MakeBase::leftJustify(const String &s)
         //Skip to first visible character
         while (i<len)
             {
-                       ch = s[i];
-                       if (ch == '\n' || ch == '\r'
-                         || !isspace(ch))
-                             break;
-                       i++;
-                       }
+            ch = s[i];
+            if (ch == '\n' || ch == '\r'
+              || !isspace(ch))
+                  break;
+            i++;
+            }
         //Copy the rest of the line
-               while (i<len)
-                   {
-                   ch = s[i];
+        while (i<len)
+            {
+            ch = s[i];
             if (ch == '\n' || ch == '\r')
                 {
                 if (ch != '\r')
@@ -3319,13 +3357,16 @@ static String win32LastError()
  */
 bool MakeBase::executeCommand(const String &command,
                               const String &inbuf,
-                                                         String &outbuf,
-                                                         String &errbuf)
+                              String &outbuf,
+                              String &errbuf)
 {
 
     status("============ cmd ============\n%s\n=============================",
-                   command.c_str());
+                command.c_str());
 
+    outbuf.clear();
+    errbuf.clear();
+    
 #ifdef __WIN32__
 
     /*
@@ -3341,7 +3382,7 @@ bool MakeBase::executeCommand(const String &command,
     if (!paramBuf)
        {
        error("executeCommand cannot allocate command buffer");
-          return false;
+       return false;
        }
     strcpy(paramBuf, (char *)command.c_str());
 
@@ -3354,25 +3395,25 @@ bool MakeBase::executeCommand(const String &command,
     HANDLE stdoutRead, stdoutWrite;
     HANDLE stderrRead, stderrWrite;
     if (!CreatePipe(&stdinRead, &stdinWrite, &saAttr, 0))
-           {
-               error("executeProgram: could not create pipe");
+        {
+        error("executeProgram: could not create pipe");
         delete[] paramBuf;
-               return false;
-               
+        return false;
+        } 
     SetHandleInformation(stdinWrite, HANDLE_FLAG_INHERIT, 0);
-       if (!CreatePipe(&stdoutRead, &stdoutWrite, &saAttr, 0))
-           {
-               error("executeProgram: could not create pipe");
+    if (!CreatePipe(&stdoutRead, &stdoutWrite, &saAttr, 0))
+        {
+        error("executeProgram: could not create pipe");
         delete[] paramBuf;
-               return false;
-               
+        return false;
+        } 
     SetHandleInformation(stdoutRead, HANDLE_FLAG_INHERIT, 0);
-       if (!CreatePipe(&stderrRead, &stderrWrite, &saAttr, 0))
-           {
-               error("executeProgram: could not create pipe");
+    if (!CreatePipe(&stderrRead, &stderrWrite, &saAttr, 0))
+        {
+        error("executeProgram: could not create pipe");
         delete[] paramBuf;
-               return false;
-               
+        return false;
+        } 
     SetHandleInformation(stderrRead, HANDLE_FLAG_INHERIT, 0);
 
     // Create the process
@@ -3391,7 +3432,7 @@ bool MakeBase::executeCommand(const String &command,
                 &piProcessInfo))
         {
         error("executeCommand : could not create process : %s",
-                           win32LastError().c_str());
+                    win32LastError().c_str());
         ret = false;
         }
 
@@ -3401,24 +3442,24 @@ bool MakeBase::executeCommand(const String &command,
                &bytesWritten, NULL))
         {
         error("executeCommand: could not write to pipe");
-               return false;
-               }       
+        return false;
+        }    
     if (!CloseHandle(stdinWrite))
-           {           
+        {          
         error("executeCommand: could not close write pipe");
-               return false;
-               }
+        return false;
+        }
     if (!CloseHandle(stdoutWrite))
-           {
+        {
         error("executeCommand: could not close read pipe");
-               return false;
-               }
+        return false;
+        }
     if (!CloseHandle(stderrWrite))
-           {
+        {
         error("executeCommand: could not close read pipe");
-               return false;
-               }
-       while (true)
+        return false;
+        }
+    while (true)
         {
         //trace("## stderr");
         DWORD avail;
@@ -3453,12 +3494,12 @@ bool MakeBase::executeCommand(const String &command,
             for (unsigned int i=0 ; i<bytesRead ; i++)
                 outbuf.push_back(readBuf[i]);
             }
-               DWORD exitCode;
+        DWORD exitCode;
         GetExitCodeProcess(piProcessInfo.hProcess, &exitCode);
         if (exitCode != STILL_ACTIVE)
             break;
         Sleep(100);
-        }      
+        }    
     //trace("outbuf:%s", outbuf.c_str());
     if (!CloseHandle(stdoutRead))
         {
@@ -3502,15 +3543,15 @@ bool MakeBase::executeCommand(const String &command,
             }
         errnum = pclose(f);
         }
-       outbuf = s;
-       if (errnum < 0)
-           {
-           error("exec of command '%s' failed : %s",
-                    command.c_str(), strerror(errno));
-           return false;
-           }
-       else
-           return true;
+    outbuf = s;
+    if (errnum != 0)
+        {
+        error("exec of command '%s' failed : %s",
+             command.c_str(), strerror(errno));
+        return false;
+        }
+    else
+        return true;
 
 #endif
 } 
@@ -3580,6 +3621,12 @@ bool MakeBase::listFiles(const String &baseDir,
 
     std::vector<String> subdirs;
     DIR *dir = opendir(dirNative.c_str());
+    if (!dir)
+        {
+        error("Could not open directory %s : %s",
+              dirNative.c_str(), strerror(errno));
+        return false;
+        }
     while (true)
         {
         struct dirent *de = readdir(dir);
@@ -3629,7 +3676,7 @@ bool MakeBase::listFiles(MakeBase &propRef, FileSet &fileSet)
     String baseDir = propRef.resolve(fileSet.getDirectory());
     std::vector<String> fileList;
     if (!listFiles(baseDir, "", fileList))
-           return false;
+        return false;
 
     std::vector<String> includes = fileSet.getIncludes();
     std::vector<String> excludes = fileSet.getExcludes();
@@ -3642,9 +3689,9 @@ bool MakeBase::listFiles(MakeBase &propRef, FileSet &fileSet)
     //If there are <includes>, then add files to the output
     //in the order of the include list
     if (includes.size()==0)
-           incs = fileList;
-       else
-           {
+        incs = fileList;
+    else
+        {
         for (iter = includes.begin() ; iter != includes.end() ; iter++)
             {
             String pattern = *iter;
@@ -3682,9 +3729,9 @@ bool MakeBase::listFiles(MakeBase &propRef, FileSet &fileSet)
             res.push_back(s);
         }
         
-       fileSet.setFiles(res);
+    fileSet.setFiles(res);
 
-       return true;
+    return true;
 }
 
 
@@ -3700,44 +3747,44 @@ bool MakeBase::getSubstitutions(const String &str, String &result)
         {
         char ch = s[i];
         if (ch == '$' && s[i+1] == '{')
-                   {
+            {
             String varname;
-                   int j = i+2;
-                   for ( ; j<len ; j++)
-                       {
-                       ch = s[j];
-                       if (ch == '$' && s[j+1] == '{')
-                           {
-                           error("attribute %s cannot have nested variable references",
-                                  s.c_str());
-                           return false;
-                           }
-                       else if (ch == '}')
-                           {
-                           std::map<String, String>::iterator iter;
-                           iter = properties.find(trim(varname));
-                           if (iter != properties.end())
-                               {
-                               val.append(iter->second);
-                               }
-                           else
-                               {
-                               error("property ${%s} not found", varname.c_str());
-                               return false;
-                               }
-                           break;
-                           }
-                       else
-                           {
-                           varname.push_back(ch);
-                           }
-                       }
-                   i = j;
-                       }
-               else
-                   {
-                   val.push_back(ch);
-                   }
+            int j = i+2;
+            for ( ; j<len ; j++)
+                {
+                ch = s[j];
+                if (ch == '$' && s[j+1] == '{')
+                    {
+                    error("attribute %s cannot have nested variable references",
+                           s.c_str());
+                    return false;
+                    }
+                else if (ch == '}')
+                    {
+                    std::map<String, String>::iterator iter;
+                    iter = properties.find(trim(varname));
+                    if (iter != properties.end())
+                        {
+                        val.append(iter->second);
+                        }
+                    else
+                        {
+                        error("property ${%s} not found", varname.c_str());
+                        return false;
+                        }
+                    break;
+                    }
+                else
+                    {
+                    varname.push_back(ch);
+                    }
+                }
+            i = j;
+            }
+        else
+            {
+            val.push_back(ch);
+            }
         }
     result = val;
     return true;
@@ -3762,7 +3809,7 @@ bool MakeBase::getValue(Element *elem, String &result)
 
 /**
  * Turn 'true' and 'false' into boolean values
- */                
+ */             
 bool MakeBase::getBool(const String &str, bool &val)
 {
     if (str == "true")
@@ -3785,9 +3832,9 @@ bool MakeBase::getBool(const String &str, bool &val)
  */  
 bool MakeBase::parsePatternSet(Element *elem,
                           MakeBase &propRef,
-                                                 std::vector<String> &includes,
-                                                 std::vector<String> &excludes
-                                                 )
+                          std::vector<String> &includes,
+                          std::vector<String> &excludes
+                          )
 {
     std::vector<Element *> children  = elem->getChildren();
     for (unsigned int i=0 ; i<children.size() ; i++)
@@ -3797,16 +3844,16 @@ bool MakeBase::parsePatternSet(Element *elem,
         if (tagName == "exclude")
             {
             String fname;
-                       if (!propRef.getAttribute(child, "name", fname))
-                           return false;
+            if (!propRef.getAttribute(child, "name", fname))
+                return false;
             //trace("EXCLUDE: %s", fname.c_str());
             excludes.push_back(fname);
             }
         else if (tagName == "include")
             {
             String fname;
-                       if (!propRef.getAttribute(child, "name", fname))
-                           return false;
+            if (!propRef.getAttribute(child, "name", fname))
+                return false;
             //trace("INCLUDE: %s", fname.c_str());
             includes.push_back(fname);
             }
@@ -3824,7 +3871,7 @@ bool MakeBase::parsePatternSet(Element *elem,
  */  
 bool MakeBase::parseFileSet(Element *elem,
                           MakeBase &propRef,
-                                                 FileSet &fileSet)
+                          FileSet &fileSet)
 {
     String name = elem->getName();
     if (name != "fileset")
@@ -3872,19 +3919,19 @@ bool MakeBase::parseFileSet(Element *elem,
     if (dir.size() > 0)
         {
         String baseDir = propRef.resolve(dir);
-           if (!listFiles(baseDir, "", includes, excludes, fileList))
-               return false;
-           }
+        if (!listFiles(baseDir, "", includes, excludes, fileList))
+            return false;
+        }
     std::sort(fileList.begin(), fileList.end());
-       result = fileList;
-       */
-
-       
-       /*
-       for (unsigned int i=0 ; i<result.size() ; i++)
-           {
-           trace("RES:%s", result[i].c_str());
-           }
+    result = fileList;
+    */
+
+    
+    /*
+    for (unsigned int i=0 ; i<result.size() ; i++)
+        {
+        trace("RES:%s", result[i].c_str());
+        }
     */
 
     
@@ -3896,7 +3943,7 @@ bool MakeBase::parseFileSet(Element *elem,
 /**
  * Create a directory, making intermediate dirs
  * if necessary
- */                        
+ */                  
 bool MakeBase::createDirectory(const String &dirname)
 {
     //trace("## createDirectory: %s", dirname.c_str());
@@ -3904,12 +3951,16 @@ bool MakeBase::createDirectory(const String &dirname)
     struct stat finfo;
     String nativeDir = getNativePath(dirname);
     char *cnative = (char *) nativeDir.c_str();
+#ifdef __WIN32__
+    if (strlen(cnative)==2 && cnative[1]==':')
+        return true;
+#endif
     if (stat(cnative, &finfo)==0)
         {
         if (!S_ISDIR(finfo.st_mode))
             {
             error("mkdir: file %s exists but is not a directory",
-                             cnative);
+                  cnative);
             return false;
             }
         else //exists
@@ -3930,9 +3981,14 @@ bool MakeBase::createDirectory(const String &dirname)
         }
         
     //## 3: now make
+#ifdef __WIN32__
     if (mkdir(cnative)<0)
+#else
+    if (mkdir(cnative, S_IRWXU | S_IRWXG | S_IRWXO)<0)
+#endif
         {
-        error("cannot make directory '%s'", cnative);
+        error("cannot make directory '%s' : %s",
+                 cnative, strerror(errno));
         return false;
         }
         
@@ -3985,10 +4041,10 @@ bool MakeBase::removeDirectory(const String &dirName)
         else if (S_ISDIR(finfo.st_mode))
             {
             //trace("DEL dir: %s", childName.c_str());
-                       if (!removeDirectory(childName))
-                   {
-                           return false;
-                           }
+            if (!removeDirectory(childName))
+                {
+                return false;
+                }
             }
         else if (!S_ISREG(finfo.st_mode))
             {
@@ -4000,9 +4056,9 @@ bool MakeBase::removeDirectory(const String &dirName)
             if (remove(cnative)<0)
                 {
                 error("error deleting %s : %s",
-                                    cnative, strerror(errno));
-                               return false;
-                               }
+                     cnative, strerror(errno));
+                return false;
+                }
             }
         }
     closedir(dir);
@@ -4032,7 +4088,7 @@ bool MakeBase::copyFile(const String &srcFile, const String &destFile)
     if (stat(srcNative.c_str(), &srcinfo)<0)
         {
         error("source file %s for copy does not exist",
-                        srcNative.c_str());
+                 srcNative.c_str());
         return false;
         }
 
@@ -4085,7 +4141,7 @@ bool MakeBase::copyFile(const String &srcFile, const String &destFile)
     if (!CopyFile(srcNative.c_str(), destNative.c_str(), false))
         {
         error("copyFile from %s to %s failed",
-                    srcNative.c_str(), destNative.c_str());
+             srcNative.c_str(), destNative.c_str());
         return false;
         }
         
@@ -4107,12 +4163,12 @@ bool MakeBase::isRegularFile(const String &fileName)
     
     //Exists?
     if (stat(native.c_str(), &finfo)<0)
-               return false;
+        return false;
 
 
     //check the file mode
     if (!S_ISREG(finfo.st_mode))
-               return false;
+        return false;
 
     return true;
 }
@@ -4127,12 +4183,12 @@ bool MakeBase::isDirectory(const String &fileName)
     
     //Exists?
     if (stat(native.c_str(), &finfo)<0)
-               return false;
+        return false;
 
 
     //check the file mode
     if (!S_ISDIR(finfo.st_mode))
-               return false;
+        return false;
 
     return true;
 }
@@ -4150,22 +4206,22 @@ bool MakeBase::isNewerThan(const String &fileA, const String &fileB)
     //IF source does not exist, NOT newer
     if (stat(nativeA.c_str(), &infoA)<0)
         {
-               return false;
-               }
+        return false;
+        }
 
     String nativeB = getNativePath(fileB);
     struct stat infoB;
     //IF dest does not exist, YES, newer
     if (stat(nativeB.c_str(), &infoB)<0)
         {
-               return true;
-               }
+        return true;
+        }
 
     //check the actual times
     if (infoA.st_mtime > infoB.st_mtime)
         {
-               return true;
-               }
+        return true;
+        }
 
     return false;
 }
@@ -4969,7 +5025,9 @@ private:
 
     int depFileSize;
     char *depFileBuf;
-    
+
+    static const int readBufSize = 8192;
+    char readBuf[8193];//byte larger
 
 };
 
@@ -5054,7 +5112,7 @@ bool DepTool::createFileList()
         String sfx;
         parseName(fileName, path, basename, sfx);
         if (sfx == "cpp" || sfx == "c" || sfx == "cxx"   ||
-                   sfx == "cc" || sfx == "CC")
+            sfx == "cc" || sfx == "CC")
             {
             FileRec *fe         = new FileRec(FileRec::CFILE);
             fe->path            = path;
@@ -5217,12 +5275,11 @@ bool DepTool::scanFile(const String &fname, FileRec *frec)
         return false;
         }
     String buf;
-    while (true)
+    while (!feof(f))
         {
-        int ch = fgetc(f);
-        if (ch < 0)
-            break;
-        buf.push_back((char)ch);
+        int len = fread(readBuf, 1, readBufSize, f);
+        readBuf[len] = '\0';
+        buf.append(readBuf);
         }
     fclose(f);
 
@@ -5412,7 +5469,7 @@ bool DepTool::saveDepFile(const String &fileName)
         if (frec->type == FileRec::OFILE)
             {
             fprintf(f, "<object path='%s' name='%s' suffix='%s'>\n",
-                            frec->path.c_str(), frec->baseName.c_str(), frec->suffix.c_str());
+                 frec->path.c_str(), frec->baseName.c_str(), frec->suffix.c_str());
             std::map<String, FileRec *>::iterator citer;
             for (citer=frec->files.begin() ; citer!=frec->files.end() ; citer++)
                 {
@@ -5691,20 +5748,26 @@ public:
 
     TaskCC(MakeBase &par) : Task(par)
         {
-               type = TASK_CC; name = "cc";
-               ccCommand   = "gcc";
-               cxxCommand  = "g++";
-               source      = ".";
-               dest        = ".";
-               flags       = "";
-               defines     = "";
-               includes    = "";
-               fileSet.clear();
+        type = TASK_CC; name = "cc";
+        ccCommand   = "gcc";
+        cxxCommand  = "g++";
+        source      = ".";
+        dest        = ".";
+        flags       = "";
+        defines     = "";
+        includes    = "";
+        fileSet.clear();
         }
 
     virtual ~TaskCC()
         {}
 
+    virtual bool needsCompiling(const DepRec &depRec,
+              const String &src, const String &dest)
+        {
+        return false;
+        }
+
     virtual bool execute()
         {
         if (!listFiles(parent, fileSet))
@@ -5714,7 +5777,7 @@ public:
         String fullName = parent.resolve("build.dep");
         if (isNewerThan(parent.getURI().getPath(), fullName))
             {
-            trace("regenerating cache");
+            status("          : regenerating C/C++ dependency cache");
             refreshCache = true;
             }
 
@@ -5769,36 +5832,73 @@ public:
             String sfx = dep.suffix;
             String command = ccCommand;
             if (sfx == "cpp" || sfx == "c++" || sfx == "cc"
-                            || sfx == "CC")
-                           command = cxxCommand;
+                 || sfx == "CC")
+                command = cxxCommand;
  
             //## Make paths
             String destPath = dest;
             String srcPath  = source;
             if (dep.path.size()>0)
-                           {
+                {
                 destPath.append("/");
-                               destPath.append(dep.path);
+                destPath.append(dep.path);
                 srcPath.append("/");
-                               srcPath.append(dep.path);
-                           }
+                srcPath.append(dep.path);
+                }
             //## Make sure destination directory exists
-                       if (!createDirectory(destPath))
-                           return false;
-                           
+            if (!createDirectory(destPath))
+                return false;
+                
             //## Check whether it needs to be done
-                       String destFullName = destPath;
-                       destFullName.append("/");
-                       destFullName.append(dep.name);
-                       destFullName.append(".o");
-                       String srcFullName = srcPath;
-                       srcFullName.append("/");
-                       srcFullName.append(dep.name);
-                       srcFullName.append(".");
-                       srcFullName.append(dep.suffix);
-            if (!isNewerThan(srcFullName, destFullName))
+            String destName;
+            if (destPath.size()>0)
+                {
+                destName.append(destPath);
+                destName.append("/");
+                }
+            destName.append(dep.name);
+            destName.append(".o");
+            String destFullName = parent.resolve(destName);
+            String srcName;
+            if (srcPath.size()>0)
+                {
+                srcName.append(srcPath);
+                srcName.append("/");
+                }
+            srcName.append(dep.name);
+            srcName.append(".");
+            srcName.append(dep.suffix);
+            String srcFullName = parent.resolve(srcName);
+            bool compileMe = false;
+            if (isNewerThan(srcFullName, destFullName))
+                {
+                status("          : compile of %s required by %s",
+                        destFullName.c_str(), srcFullName.c_str());
+                compileMe = true;
+                }
+            else
+                {
+                for (unsigned int i=0 ; i<dep.files.size() ; i++)
+                    {
+                    String depName;
+                    if (srcPath.size()>0)
+                        {
+                        depName.append(srcPath);
+                        depName.append("/");
+                        }
+                    depName.append(dep.files[i]);
+                    String depFullName = parent.resolve(depName);
+                    if (isNewerThan(depFullName, destFullName))
+                        {
+                        status("          : compile of %s required by %s",
+                                destFullName.c_str(), depFullName.c_str());
+                        compileMe = true;
+                        break;
+                        }
+                    }
+                }
+            if (!compileMe)
                 {
-                //trace("%s skipped", srcFullName.c_str());
                 continue;
                 }
 
@@ -5806,14 +5906,14 @@ public:
             String cmd = command;
             cmd.append(" -c ");
             cmd.append(flags);
-                       cmd.append(" ");
+            cmd.append(" ");
             cmd.append(defines);
-                       cmd.append(" ");
+            cmd.append(" ");
             cmd.append(incs);
-                       cmd.append(" ");
-                       cmd.append(srcFullName);
+            cmd.append(" ");
+            cmd.append(srcFullName);
             cmd.append(" -o ");
-                       cmd.append(destFullName);
+            cmd.append(destFullName);
 
             //## Execute the command
 
@@ -5909,11 +6009,11 @@ public:
 
     TaskCopy(MakeBase &par) : Task(par)
         {
-               type = TASK_COPY; name = "copy";
-               cptype = CP_NONE;
-               verbose = false;
-               haveFileSet = false;
-               }
+        type = TASK_COPY; name = "copy";
+        cptype = CP_NONE;
+        verbose = false;
+        haveFileSet = false;
+        }
 
     virtual ~TaskCopy()
         {}
@@ -5926,16 +6026,17 @@ public:
                {
                if (fileName.size()>0)
                    {
-                   status("          : %s", fileName.c_str());
+                   status("          : %s to %s",
+                        fileName.c_str(), toFileName.c_str());
                    String fullSource = parent.resolve(fileName);
                    String fullDest = parent.resolve(toFileName);
                    //trace("copy %s to file %s", fullSource.c_str(),
-                                  //                       fullDest.c_str());
-                                  if (!isRegularFile(fullSource))
-                                      {
+                   //                       fullDest.c_str());
+                   if (!isRegularFile(fullSource))
+                       {
                        error("copy : file %s does not exist", fullSource.c_str());
-                                      return false;
-                                      }
+                       return false;
+                       }
                    if (!isNewerThan(fullSource, fullDest))
                        {
                        return true;
@@ -5954,8 +6055,10 @@ public:
                        return false;
                    String fileSetDir = fileSet.getDirectory();
 
+                   status("          : %s to %s",
+                       fileSetDir.c_str(), toDirName.c_str());
+
                    int nrFiles = 0;
-                   status("          : %s", fileSetDir.c_str());
                    for (unsigned int i=0 ; i<fileSet.size() ; i++)
                        {
                        String fileName = fileSet[i];
@@ -5973,11 +6076,11 @@ public:
                        String baseFileSetDir = fileSetDir;
                        unsigned int pos = baseFileSetDir.find_last_of('/');
                        if (pos!=baseFileSetDir.npos &&
-                                                     pos < baseFileSetDir.size()-1)
+                                  pos < baseFileSetDir.size()-1)
                            baseFileSetDir =
-                                                     baseFileSetDir.substr(pos+1,
-                                                              baseFileSetDir.size());
-                                          //Now make the new path
+                              baseFileSetDir.substr(pos+1,
+                                   baseFileSetDir.size());
+                       //Now make the new path
                        String destPath;
                        if (toDirName.size()>0)
                            {
@@ -5993,7 +6096,7 @@ public:
                        String fullDest = parent.resolve(destPath);
                        //trace("fileName:%s", fileName.c_str());
                        //trace("copy %s to new dir : %s", fullSource.c_str(),
-                                      //                   fullDest.c_str());
+                       //                   fullDest.c_str());
                        if (!isNewerThan(fullSource, fullDest))
                            {
                            //trace("copy skipping %s", fullSource.c_str());
@@ -6009,7 +6112,8 @@ public:
                    {
                    //For file->dir we want only the basename of
                    //the source appended to the dest dir
-                   status("          : %s", fileName.c_str());
+                   status("          : %s to %s", 
+                       fileName.c_str(), toDirName.c_str());
                    String baseName = fileName;
                    unsigned int pos = baseName.find_last_of('/');
                    if (pos!=baseName.npos && pos<baseName.size()-1)
@@ -6024,12 +6128,12 @@ public:
                    destPath.append(baseName);
                    String fullDest = parent.resolve(destPath);
                    //trace("copy %s to new dir : %s", fullSource.c_str(),
-                                  //                       fullDest.c_str());
-                                  if (!isRegularFile(fullSource))
-                                      {
+                   //                       fullDest.c_str());
+                   if (!isRegularFile(fullSource))
+                       {
                        error("copy : file %s does not exist", fullSource.c_str());
-                                      return false;
-                                      }
+                       return false;
+                       }
                    if (!isNewerThan(fullSource, fullDest))
                        {
                        return true;
@@ -6075,18 +6179,18 @@ public:
                 if (!parseFileSet(child, parent, fileSet))
                     {
                     error("problem getting fileset");
-                                       return false;
-                                       }
-                               haveFileSet = true;
+                    return false;
+                    }
+                haveFileSet = true;
                 }
             }
 
         //Perform validity checks
-               if (fileName.size()>0 && fileSet.size()>0)
-                   {
-                   error("<copy> can only have one of : file= and <fileset>");
-                   return false;
-                   }
+        if (fileName.size()>0 && fileSet.size()>0)
+            {
+            error("<copy> can only have one of : file= and <fileset>");
+            return false;
+            }
         if (toFileName.size()>0 && toDirName.size()>0)
             {
             error("<copy> can only have one of : tofile= or todir=");
@@ -6097,16 +6201,16 @@ public:
             error("a <copy> task with a <fileset> must have : todir=");
             return false;
             }
-               if (cptype == CP_TOFILE && fileName.size()==0)
-                   {
-                   error("<copy> tofile= must be associated with : file=");
-                   return false;
-                   }
-               if (cptype == CP_TODIR && fileName.size()==0 && !haveFileSet)
-                   {
-                   error("<copy> todir= must be associated with : file= or <fileset>");
-                   return false;
-                   }
+        if (cptype == CP_TOFILE && fileName.size()==0)
+            {
+            error("<copy> tofile= must be associated with : file=");
+            return false;
+            }
+        if (cptype == CP_TODIR && fileName.size()==0 && !haveFileSet)
+            {
+            error("<copy> todir= must be associated with : file= or <fileset>");
+            return false;
+            }
 
         return true;
         }
@@ -6139,13 +6243,13 @@ public:
 
     TaskDelete(MakeBase &par) : Task(par)
         { 
-                 type        = TASK_DELETE;
-                 name        = "delete";
-                 delType     = DEL_FILE;
+          type        = TASK_DELETE;
+          name        = "delete";
+          delType     = DEL_FILE;
           verbose     = false;
           quiet       = false;
           failOnError = true;
-               }
+        }
 
     virtual ~TaskDelete()
         {}
@@ -6290,9 +6394,12 @@ public:
 
     TaskLink(MakeBase &par) : Task(par)
         {
-               type = TASK_LINK; name = "link";
-               command = "g++";
-               }
+        type = TASK_LINK; name = "link";
+        command = "g++";
+        doStrip = false;
+                stripCommand = "strip";
+                objcopyCommand = "objcopy";
+        }
 
     virtual ~TaskLink()
         {}
@@ -6315,8 +6422,8 @@ public:
             cmd.append(" ");
             String obj;
             if (fileSetDir.size()>0)
-                           {
-                               obj.append(fileSetDir);
+                {
+                obj.append(fileSetDir);
                 obj.append("/");
                 }
             obj.append(fileSet[i]);
@@ -6337,12 +6444,40 @@ public:
         //trace("LINK cmd:%s", cmd.c_str());
 
 
-        String outString, errString;
-        if (!executeCommand(cmd.c_str(), "", outString, errString))
+        String outbuf, errbuf;
+        if (!executeCommand(cmd.c_str(), "", outbuf, errbuf))
             {
-            error("LINK problem: %s", errString.c_str());
+            error("LINK problem: %s", errbuf.c_str());
             return false;
             }
+
+        if (symFileName.size()>0)
+            {
+            String symFullName = parent.resolve(symFileName);
+            cmd = objcopyCommand;
+            cmd.append(" --only-keep-debug ");
+            cmd.append(getNativePath(fullTarget));
+            cmd.append(" ");
+            cmd.append(getNativePath(symFullName));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+                {
+                error("<strip> symbol file failed : %s", errbuf.c_str());
+                return false;
+                }
+            }
+            
+        if (doStrip)
+            {
+            cmd = stripCommand;
+            cmd.append(" ");
+            cmd.append(getNativePath(fullTarget));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+               {
+               error("<strip> failed : %s", errbuf.c_str());
+               return false;
+               }
+            }
+
         return true;
         }
 
@@ -6353,8 +6488,22 @@ public:
             return false;
         if (s.size()>0)
             command = s;
+        if (!parent.getAttribute(elem, "objcopycommand", s))
+            return false;
+        if (s.size()>0)
+            objcopyCommand = s;
+        if (!parent.getAttribute(elem, "stripcommand", s))
+            return false;
+        if (s.size()>0)
+            stripCommand = s;
         if (!parent.getAttribute(elem, "out", fileName))
             return false;
+        if (!parent.getAttribute(elem, "strip", s))
+            return false;
+        if (!getBool(s, doStrip))
+            return false;
+        if (!parent.getAttribute(elem, "symfile", symFileName))
+            return false;
             
         std::vector<Element *> children = elem->getChildren();
         for (unsigned int i=0 ; i<children.size() ; i++)
@@ -6384,11 +6533,15 @@ public:
 
 private:
 
-    String command;
-    String fileName;
-    String flags;
-    String libs;
+    String  command;
+    String  fileName;
+    String  flags;
+    String  libs;
     FileSet fileSet;
+    bool    doStrip;
+    String  symFileName;
+    String  stripCommand;
+    String  objcopyCommand;
 
 };
 
@@ -6506,10 +6659,12 @@ public:
 
     TaskMsgFmt(MakeBase &par) : Task(par)
          {
-                type = TASK_MSGFMT;
-                name = "msgfmt";
-                command = "msgfmt";
-                }
+         type    = TASK_MSGFMT;
+         name    = "msgfmt";
+         command = "msgfmt";
+         owndir  = false;
+         outName = "";
+         }
 
     virtual ~TaskMsgFmt()
         {}
@@ -6527,22 +6682,40 @@ public:
             if (getSuffix(fileName) != "po")
                 continue;
             String sourcePath;
-                       if (fileSetDir.size()>0)
-                           {
-                           sourcePath.append(fileSetDir);
+            if (fileSetDir.size()>0)
+                {
+                sourcePath.append(fileSetDir);
                 sourcePath.append("/");
                 }
             sourcePath.append(fileName);
             String fullSource = parent.resolve(sourcePath);
 
             String destPath;
-                       if (toDirName.size()>0)
-                           {
-                           destPath.append(toDirName);
+            if (toDirName.size()>0)
+                {
+                destPath.append(toDirName);
+                destPath.append("/");
+                }
+            if (owndir)
+                {
+                String subdir = fileName;
+                unsigned int pos = subdir.find_last_of('.');
+                if (pos != subdir.npos)
+                    subdir = subdir.substr(0, pos);
+                destPath.append(subdir);
                 destPath.append("/");
                 }
-            destPath.append(fileName);
-            destPath[destPath.size()-2] = 'm';
+            //Pick the output file name
+            if (outName.size() > 0)
+                {
+                destPath.append(outName);
+                }
+            else
+                {
+                destPath.append(fileName);
+                destPath[destPath.size()-2] = 'm';
+                }
+
             String fullDest = parent.resolve(destPath);
 
             if (!isNewerThan(fullSource, fullDest))
@@ -6580,8 +6753,19 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+            command = s;
         if (!parent.getAttribute(elem, "todir", toDirName))
             return false;
+        if (!parent.getAttribute(elem, "out", outName))
+            return false;
+        if (!parent.getAttribute(elem, "owndir", s))
+            return false;
+        if (!getBool(s, owndir))
+            return false;
             
         std::vector<Element *> children = elem->getChildren();
         for (unsigned int i=0 ; i<children.size() ; i++)
@@ -6599,9 +6783,11 @@ public:
 
 private:
 
-    String command;
-    String toDirName;
+    String  command;
+    String  toDirName;
+    String  outName;
     FileSet fileSet;
+    bool    owndir;
 
 };
 
@@ -6617,7 +6803,10 @@ class TaskRanlib : public Task
 public:
 
     TaskRanlib(MakeBase &par) : Task(par)
-        { type = TASK_RANLIB; name = "ranlib"; }
+        {
+        type = TASK_RANLIB; name = "ranlib";
+        command = "ranlib";
+        }
 
     virtual ~TaskRanlib()
         {}
@@ -6626,7 +6815,8 @@ public:
         {
         String fullName = parent.resolve(fileName);
         //trace("fullDir:%s", fullDir.c_str());
-        String cmd = "ranlib ";
+        String cmd = command;
+        cmd.append(" ");
         cmd.append(fullName);
         String outbuf, errbuf;
         if (!executeCommand(cmd, "", outbuf, errbuf))
@@ -6636,6 +6826,11 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+           command = s;
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
         if (fileName.size() == 0)
@@ -6649,6 +6844,7 @@ public:
 private:
 
     String fileName;
+    String command;
 };
 
 
@@ -6662,9 +6858,9 @@ public:
 
     TaskRC(MakeBase &par) : Task(par)
         {
-               type = TASK_RC; name = "rc";
-               command = "windres -o";
-               }
+        type = TASK_RC; name = "rc";
+        command = "windres";
+        }
 
     virtual ~TaskRC()
         {}
@@ -6676,7 +6872,7 @@ public:
         if (!isNewerThan(fullFile, fullOut))
             return true;
         String cmd = command;
-        cmd.append(" ");
+        cmd.append(" -o ");
         cmd.append(fullOut);
         cmd.append(" ");
         cmd.append(flags);
@@ -6734,9 +6930,9 @@ public:
 
     TaskSharedLib(MakeBase &par) : Task(par)
         {
-               type = TASK_SHAREDLIB; name = "dll";
-               command = "ar crv";
-               }
+        type = TASK_SHAREDLIB; name = "dll";
+        command = "ar crv";
+        }
 
     virtual ~TaskSharedLib()
         {}
@@ -6756,9 +6952,9 @@ public:
         for (unsigned int i=0 ; i<fileSet.size() ; i++)
             {
             String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
+            if (fileSetDir.size()>0)
+                {
+                fname.append(fileSetDir);
                 fname.append("/");
                 }
             fname.append(fileSet[i]);
@@ -6791,9 +6987,9 @@ public:
         for (unsigned int i=0 ; i<fileSet.size() ; i++)
             {
             String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
+            if (fileSetDir.size()>0)
+                {
+                fname.append(fileSetDir);
                 fname.append("/");
                 }
             fname.append(fileSet[i]);
@@ -6865,9 +7061,9 @@ public:
 
     TaskStaticLib(MakeBase &par) : Task(par)
         {
-               type = TASK_STATICLIB; name = "staticlib";
-               command = "ar crv";
-               }
+        type = TASK_STATICLIB; name = "staticlib";
+        command = "ar crv";
+        }
 
     virtual ~TaskStaticLib()
         {}
@@ -6887,9 +7083,9 @@ public:
         for (unsigned int i=0 ; i<fileSet.size() ; i++)
             {
             String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
+            if (fileSetDir.size()>0)
+                {
+                fname.append(fileSetDir);
                 fname.append("/");
                 }
             fname.append(fileSet[i]);
@@ -6910,9 +7106,9 @@ public:
         for (unsigned int i=0 ; i<fileSet.size() ; i++)
             {
             String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
+            if (fileSetDir.size()>0)
+                {
+                fname.append(fileSetDir);
                 fname.append("/");
                 }
             fname.append(fileSet[i]);
@@ -6934,6 +7130,11 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+            command = s;
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
             
@@ -6977,12 +7178,30 @@ public:
         {
         String fullName = parent.resolve(fileName);
         //trace("fullDir:%s", fullDir.c_str());
-        String cmd = "strip ";
-        cmd.append(fullName);
-
+        String cmd;
         String outbuf, errbuf;
+
+        if (symFileName.size()>0)
+            {
+            String symFullName = parent.resolve(symFileName);
+            cmd = "objcopy --only-keep-debug ";
+            cmd.append(getNativePath(fullName));
+            cmd.append(" ");
+            cmd.append(getNativePath(symFullName));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+                {
+                error("<strip> symbol file failed : %s", errbuf.c_str());
+                return false;
+                }
+            }
+            
+        cmd = "strip ";
+        cmd.append(getNativePath(fullName));
         if (!executeCommand(cmd, "", outbuf, errbuf))
+            {
+            error("<strip> failed : %s", errbuf.c_str());
             return false;
+            }
         return true;
         }
 
@@ -6990,9 +7209,11 @@ public:
         {
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
+        if (!parent.getAttribute(elem, "symfile", symFileName))
+            return false;
         if (fileName.size() == 0)
             {
-            error("<strip> requires 'file=\"fileNname\"' attribute");
+            error("<strip> requires 'file=\"fileName\"' attribute");
             return false;
             }
         return true;
@@ -7001,6 +7222,7 @@ public:
 private:
 
     String fileName;
+    String symFileName;
 };
 
 
@@ -7299,13 +7521,13 @@ public:
      *
      */
     virtual String version()
-        { return "BuildTool v0.3, 2006 Bob Jamison"; }
+        { return "BuildTool v0.6, 2006 Bob Jamison"; }
 
     /**
      * Overload a <property>
      */
     virtual bool specifyProperty(const String &name,
-                                    const String &value);
+                                 const String &value);
 
     /**
      *
@@ -7346,7 +7568,7 @@ private:
      *
      */
     bool executeTarget(Target &target,
-                std::set<String> &targetsCompleted);
+             std::set<String> &targetsCompleted);
 
 
     /**
@@ -7364,7 +7586,7 @@ private:
      *
      */
     bool parsePropertyFile(const String &fileName,
-                              const String &prefix);
+                           const String &prefix);
 
     /**
      *
@@ -7570,11 +7792,11 @@ bool Make::execute()
         }
 
     std::map<String, Target>::iterator iter =
-                  targets.find(currentTarget);
+               targets.find(currentTarget);
     if (iter == targets.end())
         {
         error("Initial target '%s' not found",
-                        currentTarget.c_str());
+                 currentTarget.c_str());
         return false;
         }
         
@@ -7693,54 +7915,64 @@ bool Make::parsePropertyFile(const String &fileName,
         if (p2 <= p)
             {
             error("property file %s, line %d: expected keyword",
-                               fileName.c_str(), linenr);
-                       return false;
-                       }
-               if (prefix.size() > 0)
-                   {
-                   key.insert(0, prefix);
-                   }
+                    fileName.c_str(), linenr);
+            return false;
+            }
+        if (prefix.size() > 0)
+            {
+            key.insert(0, prefix);
+            }
 
         //skip whitespace
-               for (p=p2 ; p<len ; p++)
-                   if (!isspace(s[p]))
-                       break;
+        for (p=p2 ; p<len ; p++)
+            if (!isspace(s[p]))
+                break;
 
         if (p>=len || s[p]!='=')
             {
             error("property file %s, line %d: expected '='",
-                               fileName.c_str(), linenr);
+                    fileName.c_str(), linenr);
             return false;
             }
         p++;
 
         //skip whitespace
-               for ( ; p<len ; p++)
-                   if (!isspace(s[p]))
-                       break;
+        for ( ; p<len ; p++)
+            if (!isspace(s[p]))
+                break;
 
         /* This way expects a word after the =
-               p2 = getword(p, s, val);
+        p2 = getword(p, s, val);
         if (p2 <= p)
             {
             error("property file %s, line %d: expected value",
-                               fileName.c_str(), linenr);
-                       return false;
-                       }
-               */
+                    fileName.c_str(), linenr);
+            return false;
+            }
+        */
         // This way gets the rest of the line after the =
-               if (p>=len)
+        if (p>=len)
             {
             error("property file %s, line %d: expected value",
-                               fileName.c_str(), linenr);
-                       return false;
-                       }
+                    fileName.c_str(), linenr);
+            return false;
+            }
         val = s.substr(p);
-               if (key.size()==0 || val.size()==0)
-                   continue;
+        if (key.size()==0)
+            continue;
+        //allow property to be set, even if val=""
 
         //trace("key:'%s' val:'%s'", key.c_str(), val.c_str());
-           properties[key] = val;
+        //See if we wanted to overload this property
+        std::map<String, String>::iterator iter =
+            specifiedProperties.find(key);
+        if (iter!=specifiedProperties.end())
+            {
+            val = iter->second;
+            status("overloading property '%s' = '%s'",
+                   key.c_str(), val.c_str());
+            }
+        properties[key] = val;
         }
     fclose(f);
     return true;
@@ -7763,27 +7995,35 @@ bool Make::parseProperty(Element *elem)
         if (attrName == "name")
             {
             String val;
-                       if (!getAttribute(elem, "value", val))
-                           return false;
+            if (!getAttribute(elem, "value", val))
+                return false;
             if (val.size() > 0)
                 {
                 properties[attrVal] = val;
-                continue;
                 }
-            if (!getAttribute(elem, "location", val))
-                return false;
-            if (val.size() > 0)
+            else
                 {
-                //TODO:  process a path relative to build.xml
+                if (!getAttribute(elem, "location", val))
+                    return false;
+                //let the property exist, even if not defined
+                properties[attrVal] = val;
+                }
+            //See if we wanted to overload this property
+            std::map<String, String>::iterator iter =
+                specifiedProperties.find(attrVal);
+            if (iter != specifiedProperties.end())
+                {
+                val = iter->second;
+                status("overloading property '%s' = '%s'",
+                    attrVal.c_str(), val.c_str());
                 properties[attrVal] = val;
-                continue;
                 }
             }
         else if (attrName == "file")
             {
             String prefix;
-                       if (!getAttribute(elem, "prefix", prefix))
-                           return false;
+            if (!getAttribute(elem, "prefix", prefix))
+                return false;
             if (prefix.size() > 0)
                 {
                 if (prefix[prefix.size()-1] != '.')
@@ -7821,7 +8061,7 @@ bool Make::parseFile()
     if (!root)
         {
         error("Could not open %s for reading",
-                     uri.getNativePath().c_str());
+              uri.getNativePath().c_str());
         return false;
         }
 
@@ -7951,43 +8191,61 @@ bool Make::run()
     if (!parseFile())
         return false;
         
-    //Overload properties
-    std::map<String, String>::iterator iter;
-    for (iter = specifiedProperties.begin() ; 
-                iter!=specifiedProperties.end() ; iter++)
-           {
-           String name = iter->first;
-           String value = iter->second;
-               if (properties.find(name) == properties.end())
-                   {
-                   error("Overloading property:%s not found", name.c_str());
-                   return false;
-                   }
-               properties[name] = value;
-           }
-
     if (!execute())
         return false;
+
     return true;
 }
 
 
+
+
+/**
+ * Get a formatted MM:SS.sss time elapsed string
+ */ 
+static String
+timeDiffString(struct timeval &x, struct timeval &y)
+{
+    long microsX  = x.tv_usec;
+    long secondsX = x.tv_sec;
+    long microsY  = y.tv_usec;
+    long secondsY = y.tv_sec;
+    if (microsX < microsY)
+        {
+        microsX += 1000000;
+        secondsX -= 1;
+        }
+
+    int seconds = (int)(secondsX - secondsY);
+    int millis  = (int)((microsX - microsY)/1000);
+
+    int minutes = seconds/60;
+    seconds -= minutes*60;
+    char buf[80];
+    snprintf(buf, 79, "%dm %d.%03ds", minutes, seconds, millis);
+    String ret = buf;
+    return ret;
+    
+}
+
 /**
  *
  */
 bool Make::run(const String &target)
 {
-    status("##################################");
-    status("#   BuildTool");
-    status("#   version 0.4");
-    status("#   17 Nov 06");
-    status("##################################");
+    status("####################################################");
+    status("#   %s", version().c_str());
+    status("####################################################");
+    struct timeval timeStart, timeEnd;
+    ::gettimeofday(&timeStart, NULL);
     specifiedTarget = target;
     if (!run())
         return false;
-    status("##################################");
-    status("#   BuildTool Completed");
-    status("##################################");
+    ::gettimeofday(&timeEnd, NULL);
+    String timeStr = timeDiffString(timeEnd, timeStart);
+    status("####################################################");
+    status("#   BuildTool Completed : %s", timeStr.c_str());
+    status("####################################################");
     return true;
 }
 
@@ -8182,8 +8440,8 @@ static bool depTest()
     if (!deptool.generateDependencies("build.dep"))
         return false;
     std::vector<buildtool::DepRec> res =
-              deptool.loadDepFile("build.dep");
-       if (res.size() == 0)
+           deptool.loadDepFile("build.dep");
+    if (res.size() == 0)
         return false;
     return true;
 }
@@ -8192,7 +8450,7 @@ static bool popenTest()
 {
     buildtool::Make make;
     buildtool::String out, err;
-       bool ret = make.executeCommand("gcc xx.cpp", "", out, err);
+    bool ret = make.executeCommand("gcc xx.cpp", "", out, err);
     printf("Popen test:%d '%s' '%s'\n", ret, out.c_str(), err.c_str());
     return true;
 }