View | Details | Raw Unified | Return to issue 73499
Collapse All | Expand All

(-)dmake/dag.c (-4 / +36 lines)
Lines 46-54 Link Here
46
   switch( hp->ht_flag & M_VAR_MASK )	/* only one var type per var */
46
   switch( hp->ht_flag & M_VAR_MASK )	/* only one var type per var */
47
   {
47
   {
48
      case M_VAR_STRING:
48
      case M_VAR_STRING:
49
         *hp->MV_SVAR = hp->ht_value;
49
	 *hp->MV_SVAR = hp->ht_value;
50
         break;
50
	 /* Add special treatment for PWD/MAKEDIR for .WINPATH. */
51
         
51
	 if( hp->MV_SVAR == &Pwd_macval ) {
52
	    if( Pwd )
53
	       FREE(Pwd);
54
	    Pwd = hp->ht_value;
55
	    /* Use the "DOSified" path for the macro. */
56
	    *hp->MV_SVAR = hp->ht_value = DmStrDup(DO_WINPATH(hp->ht_value));
57
	    DB_PRINT( "smv", ("PWD: %s/%s", Pwd_macval, Pwd) );
58
	 } else if( hp->MV_SVAR == &Makedir_macval ) {
59
	    if( Makedir )
60
	       FREE(Makedir);
61
	    Makedir = hp->ht_value;
62
	    /* Use the "DOSified" path for the macro. */
63
	    *hp->MV_SVAR = hp->ht_value = DmStrDup(DO_WINPATH(hp->ht_value));
64
	    DB_PRINT( "smv", ("MAKEDIR: %s/%s", Makedir_macval, Makedir) );
65
	 }
66
	 /* No special treatment for TMD needed. */
67
	 break;
68
52
      case M_VAR_CHAR:
69
      case M_VAR_CHAR:
53
         *hp->MV_CVAR = (hp->ht_value == NIL(char)) ? '\0':*hp->ht_value;
70
         *hp->MV_CVAR = (hp->ht_value == NIL(char)) ? '\0':*hp->ht_value;
54
         break;
71
         break;
Lines 102-107 Link Here
102
	    if( (hp->MV_MASK & A_SEQ) && (Max_proc != 1) )
119
	    if( (hp->MV_MASK & A_SEQ) && (Max_proc != 1) )
103
	       Def_macro( "MAXPROCESS", "1", M_MULTI|M_EXPANDED);
120
	       Def_macro( "MAXPROCESS", "1", M_MULTI|M_EXPANDED);
104
	 }
121
	 }
122
123
	 /* Global .WINPATH change. */
124
	 if(hp->MV_MASK & A_SWAP) {
125
	    UseWinpath = ((Glob_attr&A_SWAP) != 0);
126
	    /* Change MAKEDIR, PWD according to .WINPATH. During
127
	     * makefile evaluation this cannot change TMD and later
128
	     * TMD is set in Make(). */
129
	    Def_macro( "MAKEDIR", Makedir, M_FORCE | M_EXPANDED );
130
	    Def_macro( "PWD", Pwd, M_FORCE | M_EXPANDED );
131
	 }
105
         break;
132
         break;
106
   }
133
   }
107
}
134
}
Lines 640-646 Link Here
640
	 case '@' : ++atcount;        break;
667
	 case '@' : ++atcount;        break;
641
	 case '-' : flag |= A_IGNORE; break;
668
	 case '-' : flag |= A_IGNORE; break;
642
	 case '+' : flag |= A_SHELL;  break;
669
	 case '+' : flag |= A_SHELL;  break;
643
	 case '%' : flag |= A_SWAP;   break;
670
	 case '%' :
671
#if !defined(__CYGWIN__)
672
	    /* Ignore % in the non-MSDOS case. */
673
	    flag |= A_SWAP;
674
#endif
675
	    break;
644
676
645
	 case ' ' :
677
	 case ' ' :
646
	 case '\t': break;
678
	 case '\t': break;
(-)dmake/dmake.c (+1 lines)
Lines 171-176 Link Here
171
   Check     = FALSE;
171
   Check     = FALSE;
172
   Microsoft = FALSE;
172
   Microsoft = FALSE;
173
   Makemkf   = FALSE;
173
   Makemkf   = FALSE;
174
   UseWinpath= FALSE;
174
   No_exec   = FALSE;
175
   No_exec   = FALSE;
175
   m_export  = FALSE;
176
   m_export  = FALSE;
176
   cmdmacs   = NIL(char);
177
   cmdmacs   = NIL(char);
(-)dmake/dmake.h (-1 / +3 lines)
Lines 89-95 Link Here
89
#define A_WFC              A_SEQ
89
#define A_WFC              A_SEQ
90
#define A_SETDIR         0x00400        /* cd to dir when making target */
90
#define A_SETDIR         0x00400        /* cd to dir when making target */
91
#define A_SHELL          0x00800        /* run the recipe using a shell */
91
#define A_SHELL          0x00800        /* run the recipe using a shell */
92
#define A_SWAP           0x01000        /* swap on exec.                */
92
#define A_SWAP           0x01000        /* Use swap on MSDOS            */
93
/* Reuse A_SWAP for the .WINPATH attribute to convert cygwin POSIX paths
94
 * into DOS style paths. */
93
#define A_MKSARGS        0x02000        /* use MKS argument swapping    */
95
#define A_MKSARGS        0x02000        /* use MKS argument swapping    */
94
#define A_PHONY          0x04000        /* .PHONY attribute             */
96
#define A_PHONY          0x04000        /* .PHONY attribute             */
95
#define A_NOSTATE        0x08000        /* don't track state for me     */
97
#define A_NOSTATE        0x08000        /* don't track state for me     */
(-)dmake/dmdump.c (-1 / +11 lines)
Lines 111-117 Link Here
111
111
112
static char *_attrs[] = { ".PRECIOUS", ".SILENT", ".LIBRARY",
112
static char *_attrs[] = { ".PRECIOUS", ".SILENT", ".LIBRARY",
113
   ".EPILOG", ".PROLOG", ".IGNORE", ".SYMBOL", ".NOINFER",
113
   ".EPILOG", ".PROLOG", ".IGNORE", ".SYMBOL", ".NOINFER",
114
   ".UPDATEALL", ".SEQUENTIAL", ".SETDIR=", ".USESHELL", ".SWAP", ".MKSARGS",
114
   ".UPDATEALL", ".SEQUENTIAL", ".SETDIR=", ".USESHELL",
115
#if defined(MSDOS)
116
   ".SWAP",
117
#else
118
# if defined(__CYGWIN__)
119
   ".WINPATH",
120
# else
121
   "- unused -",
122
# endif
123
#endif
124
   ".MKSARGS",
115
   ".PHONY", ".NOSTATE", ".IGNOREGROUP", ".EXECUTE", ".ERRREMOVE" };
125
   ".PHONY", ".NOSTATE", ".IGNOREGROUP", ".EXECUTE", ".ERRREMOVE" };
116
126
117
static void
127
static void
(-)dmake/extern.h (+9 lines)
Lines 108-113 Link Here
108
/* from path.c */
108
/* from path.c */
109
void Clean_path(char *path);
109
void Clean_path(char *path);
110
110
111
/* from sysintf.c */
112
/* cygdospath()/DO_WINPATH() are only needed for the .WINPATH attribute
113
 * on cygwin. */
114
#if __CYGWIN__
115
char *cygdospath(char *src, int winpath);
116
# define DO_WINPATH(p) cygdospath(p, UseWinpath)
117
#else
118
# define DO_WINPATH(p) p
119
#endif
111
120
112
121
113
/* Define some usefull macros. This is done here and not in config.h
122
/* Define some usefull macros. This is done here and not in config.h
(-)dmake/getinp.c (+5 lines)
Lines 305-313 Link Here
305
	       cmnd = Expand(c+2);
305
	       cmnd = Expand(c+2);
306
	       cmnd[strlen(cmnd)-1] = '\0';	/* strip last newline */
306
	       cmnd[strlen(cmnd)-1] = '\0';	/* strip last newline */
307
	       Current_target = Root;
307
	       Current_target = Root;
308
#if defined(MSDOS)
308
	       Swap_on_exec = TRUE;
309
	       Swap_on_exec = TRUE;
310
#endif
309
	       Wait_for_completion = TRUE;
311
	       Wait_for_completion = TRUE;
310
	       Do_cmnd(cmnd, FALSE, TRUE, Current_target, A_DEFAULT, TRUE);
312
	       Do_cmnd(cmnd, FALSE, TRUE, Current_target, A_DEFAULT, TRUE);
313
#if defined(MSDOS)
314
	       Swap_on_exec = FALSE;
315
#endif
311
	       Wait_for_completion = FALSE;
316
	       Wait_for_completion = FALSE;
312
	       FREE(cmnd);
317
	       FREE(cmnd);
313
	    }
318
	    }
(-)dmake/imacs.c (-3 / +9 lines)
Lines 86-92 Link Here
86
   _set_bit_var(".NOINFER",  "", A_NOINFER );
86
   _set_bit_var(".NOINFER",  "", A_NOINFER );
87
   _set_bit_var(".SEQUENTIAL","",A_SEQ     );
87
   _set_bit_var(".SEQUENTIAL","",A_SEQ     );
88
   _set_bit_var(".USESHELL", "", A_SHELL   );
88
   _set_bit_var(".USESHELL", "", A_SHELL   );
89
   /* .SWAP (MSDOS) and .WINPATH (cygwin) share the same bit. */
89
   _set_bit_var(".SWAP",     "", A_SWAP    );
90
   _set_bit_var(".SWAP",     "", A_SWAP    );
91
   _set_bit_var(".WINPATH",  "", A_SWAP    );
90
   _set_bit_var(".MKSARGS",  "", A_MKSARGS );
92
   _set_bit_var(".MKSARGS",  "", A_MKSARGS );
91
   _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
93
   _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
92
94
Lines 110-119 Link Here
110
#endif
112
#endif
111
   _set_string_var(".DIRCACHERESPCASE", DIRCACHERESPCASEDEFAULT, M_DEFAULT, &DcacheRespCase);
113
   _set_string_var(".DIRCACHERESPCASE", DIRCACHERESPCASEDEFAULT, M_DEFAULT, &DcacheRespCase);
112
114
113
   _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,&Makedir);
115
   _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,
116
		   &Makedir_macval);
117
   Makedir = DmStrDup(Makedir_macval); /* Later done by Def_macro(). */
114
   _set_string_var("MAKEVERSION", VERSION, M_PRECIOUS, &version);
118
   _set_string_var("MAKEVERSION", VERSION, M_PRECIOUS, &version);
115
   _set_string_var("PWD",  Makedir,  M_PRECIOUS|M_NOEXPORT, &Pwd);
119
   _set_string_var("PWD",  Makedir,  M_PRECIOUS|M_NOEXPORT, &Pwd_macval);
116
   _set_string_var("TMD",  ".",      M_PRECIOUS|M_NOEXPORT, &Tmd);
120
   Pwd = DmStrDup(Pwd_macval); /* Later done by Def_macro(). */
121
   _set_string_var("TMD",  ".",      M_PRECIOUS|M_NOEXPORT, &Tmd_macval);
122
   Tmd = DmStrDup(Tmd_macval); /* Later done by _set_tmd(). */
117
123
118
   Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
124
   Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
119
125
(-)dmake/infer.c (-2 / +5 lines)
Lines 523-540 Link Here
523
buildname( tg, meta, per )/*
523
buildname( tg, meta, per )/*
524
============================
524
============================
525
   Replace '%' with per in meta. Expand the result and return it. */ 
525
   Replace '%' with per in meta. Expand the result and return it. */ 
526
char *tg;
526
char *tg; /* Current target name. */
527
char *meta;
527
char *meta;
528
char *per;
528
char *per;
529
{
529
{
530
   char    *name;
530
   char    *name;
531
531
532
   name = Apply_edit( meta, "%", per, FALSE, FALSE );
532
   name = Apply_edit( meta, "%", per, FALSE, FALSE );
533
   /* Handle infered dynamic prerequisites. */
533
   if( strchr(name, '$') ) {
534
   if( strchr(name, '$') ) {
534
      HASHPTR m_at;
535
      HASHPTR m_at;
535
      char *tmp;
536
      char *tmp;
536
537
537
      m_at = Def_macro( "@", tg, M_MULTI );
538
      /* Set $@ so that a Expand() can use it and remove it afterwards. */
539
      m_at = Def_macro( "@", DO_WINPATH(tg), M_MULTI|M_EXPANDED );
538
      tmp = Expand( name );
540
      tmp = Expand( name );
539
541
540
      if( m_at->ht_value != NIL(char) ) {
542
      if( m_at->ht_value != NIL(char) ) {
Lines 542-547 Link Here
542
	 m_at->ht_value = NIL(char);
544
	 m_at->ht_value = NIL(char);
543
      }
545
      }
544
546
547
      /* Free name if Apply_edit() did something. */
545
      if( name != meta ) FREE( name );
548
      if( name != meta ) FREE( name );
546
      name = tmp;
549
      name = tmp;
547
   }
550
   }
(-)dmake/make.c (-26 / +128 lines)
Lines 142-161 Link Here
142
142
143
143
144
static char *
144
static char *
145
list_string(LISTSTRINGPTR s)
145
gen_path_list_string(LISTSTRINGPTR s)/*
146
=======================================
147
   Take a list of filepaths and create a string from it separating
148
   the filenames by a space.
149
   This function honors the cygwin specific .WINPATH attribute. */
146
{
150
{
147
   LISTCELLPTR next, cell;
151
   LISTCELLPTR next, cell;
148
   int         len;
152
   int         len;
153
   int         slen, slen_rest;
149
   char        *result;
154
   char        *result;
150
   char        *p;
155
   char        *p, *tpath;
151
156
152
   if(s->len == 0)
157
   if( (slen_rest = slen = s->len) == 0)
153
      return(NIL(char));
158
      return(NIL(char));
154
159
155
   if((p = result = MALLOC(s->len, char)) == NULL) No_ram();
160
   /* reserve enough space to hold the concated original filenames. */
161
   if((p = result = MALLOC(slen, char)) == NULL) No_ram();
156
162
157
   for (cell=s->first; cell; cell=next) {
163
   for (cell=s->first; cell; cell=next) {
158
      memcpy((void *)p, (void *)cell->datum, len=cell->len);
164
#if !defined(__CYGWIN__)
165
      tpath = cell->datum;
166
      len=cell->len;
167
#else
168
      /* For cygwin with .WINPATH set the lenght of the converted
169
       * filepaths might me longer. Extra checking is needed ... */
170
      tpath = DO_WINPATH(cell->datum);
171
      if( tpath == cell->datum ) {
172
	 len=cell->len;
173
      }
174
      else {
175
	 /* ... but only if DO_WINPATH() did something. */
176
	 len = strlen(tpath);
177
      
178
	 if( len > slen_rest ) {
179
	    /* We need more memory. As DOS paths are usually shorter than the
180
	     * original cygwin POSIX paths (exception mounted paths) this should
181
	     * rarely happen. */
182
	    int p_offset = p - result;
183
	    /* Get more than needed. */
184
	    slen += slen + len-slen_rest + 128;
185
	    if((result = realloc( result, (unsigned)(slen*sizeof(char)) ) ) == NULL)
186
	       No_ram();
187
	    p = result + p_offset;
188
	 }
189
      }
190
191
      slen_rest -= len;
192
#endif
193
194
      memcpy((void *)p, (void *)tpath, len);
159
      p += len;
195
      p += len;
160
      *p++ = ' ';
196
      *p++ = ' ';
161
      next = cell->next;
197
      next = cell->next;
Lines 245-250 Link Here
245
   time_t	    ttime   = (time_t) 1L;
281
   time_t	    ttime   = (time_t) 1L;
246
   int		    mark_made = FALSE;
282
   int		    mark_made = FALSE;
247
283
284
   /* static variable to hold .WINPATH status of previously made target.
285
    * 0, 1 are .WINPATH states, -1 indicates the first target. */
286
   static int prev_winpath_attr = -1;
287
248
   DB_ENTER( "Make" );
288
   DB_ENTER( "Make" );
249
   DB_PRINT( "mem", ("%s:-> mem %ld", cp->CE_NAME, (long) coreleft()) );
289
   DB_PRINT( "mem", ("%s:-> mem %ld", cp->CE_NAME, (long) coreleft()) );
250
290
Lines 268-274 Link Here
268
308
269
   nsetdirroot = setdirroot;
309
   nsetdirroot = setdirroot;
270
   ignore = (((cp->ce_attr|Glob_attr)&A_IGNORE) != 0);
310
   ignore = (((cp->ce_attr|Glob_attr)&A_IGNORE) != 0);
271
   m_at = Def_macro( "@", cp->ce_fname, M_MULTI );
311
312
   /* Transform MAKEDIR, PWD and TMD below. (_set_tmd() needs UseWinpath) */
313
   UseWinpath = (((cp->ce_attr|Glob_attr)&A_SWAP) != 0);
272
314
273
   if( cp->ce_attr & A_SETDIR ) {
315
   if( cp->ce_attr & A_SETDIR ) {
274
      /* Change directory only if the previous .SETDIR is a different
316
      /* Change directory only if the previous .SETDIR is a different
Lines 386-392 Link Here
386
      }
428
      }
387
   }
429
   }
388
430
389
   m_at = Def_macro("@", cp->ce_fname, M_MULTI);
431
   /* Define $@ macro. The only reason for defining it here (that I see ATM)
432
    * is that $@ is already defined in conditional macros. */
433
   m_at = Def_macro("@", DO_WINPATH(cp->ce_fname), M_MULTI|M_EXPANDED);
390
434
391
   /* Define conditional macros if any, note this is done BEFORE we process
435
   /* Define conditional macros if any, note this is done BEFORE we process
392
    * prerequisites for the current target.  Thus the making of a prerequisite
436
    * prerequisites for the current target.  Thus the making of a prerequisite
Lines 417-425 Link Here
417
      int seq;
461
      int seq;
418
462
419
      /* This is the only macro that needs to be reset while building
463
      /* This is the only macro that needs to be reset while building
420
       * prerequisites since it is set when we make each prerequisite. */
464
       * prerequisites since it is set/changed by Make() when we make
465
       * each prerequisite and $@ might be used when expanding potential
466
       * dynamic prerequisites. */
421
      if (m_at->ht_value == NIL(char)) {
467
      if (m_at->ht_value == NIL(char)) {
422
	 m_at = Def_macro("@", cp->ce_fname, M_MULTI);
468
	 m_at = Def_macro("@", DO_WINPATH(cp->ce_fname), M_MULTI|M_EXPANDED);
423
      }
469
      }
424
470
425
      /* Make the prerequisite, note that if the current target has the
471
      /* Make the prerequisite, note that if the current target has the
Lines 568-577 Link Here
568
      }
614
      }
569
   }
615
   }
570
616
571
   all = list_string(&all_list);
617
   /* Create a string with all concatenate filenames. The function
572
   imm = list_string(&imm_list);
618
    * respects .WINPATH. */
573
   outall = list_string(&outall_list);
619
   /* Change MAKEDIR, PWD and TMD only if needed. Pwd and Makedir are
574
   inf = list_string(&inf_list);
620
    * always the natural form, but PWD/MAKEDIR might hold a DOSified
621
    * value according to .WINPATH. */
622
   UseWinpath = (((cp->ce_attr|Glob_attr)&A_SWAP) != 0);
623
624
   /* Note that gen_path_list_string empties its parameter :( */
625
   all = gen_path_list_string(&all_list);
626
   imm = gen_path_list_string(&imm_list);
627
   outall = gen_path_list_string(&outall_list);
628
   inf = gen_path_list_string(&inf_list);
575
   
629
   
576
   DB_PRINT( "mem", ("%s:-C mem %ld", cp->CE_NAME, (long) coreleft()) );
630
   DB_PRINT( "mem", ("%s:-C mem %ld", cp->CE_NAME, (long) coreleft()) );
577
   DB_PRINT( "make", ("I make '%s' if %ld > %ld", cp->CE_NAME, otime,
631
   DB_PRINT( "make", ("I make '%s' if %ld > %ld", cp->CE_NAME, otime,
Lines 588-600 Link Here
588
	 printf( "[%s]\n", cp->CE_NAME );
642
	 printf( "[%s]\n", cp->CE_NAME );
589
   }
643
   }
590
644
591
   m_at = Def_macro( "@", cp->ce_fname, M_MULTI );
645
   /* Why has PWD the right value here? (If a prereq with a .SETDIR
592
   m_g  = Def_macro( ">", cp->ce_lib,   M_MULTI|M_EXPANDED );
646
    * attribute was build). Do we have to use Def_macro()?
647
    * We could change hp->ht_value ? */
648
   if( UseWinpath != prev_winpath_attr ) {
649
      Def_macro( "MAKEDIR", Makedir, M_FORCE | M_EXPANDED );
650
      Def_macro( "PWD", Pwd, M_FORCE | M_EXPANDED );
651
      _set_tmd();
652
   }
653
   prev_winpath_attr = UseWinpath;
654
655
   /* Set the dynamic macros $@, $*, $>, $?, $<, $& and $^. */
656
   /* Are they already expanded? FIXME: Remove this check later. */
657
   if( *DmStrPbrk( cp->ce_fname, "${}" ) != '\0' )
658
      Fatal("$@ [%s] not fully expanded!", cp->ce_fname);
659
   m_at = Def_macro( "@", DO_WINPATH(cp->ce_fname), M_MULTI|M_EXPANDED );
660
661
   /* $* is either expanded as the result of a % inference or defined to
662
    * $(@:db) and hence unexpanded otherwise. The latter doesn't start
663
    * with / and will therefore not be touched by DO_WINPATH(). */
664
   m_bb = Def_macro( "*", DO_WINPATH(cp->ce_per),   M_MULTI );
665
666
   /* This is expanded. */
667
   m_g  = Def_macro( ">", DO_WINPATH(cp->ce_lib),   M_MULTI|M_EXPANDED );
668
   /* These strings are generated with gen_path_list_string() and honor
669
    * .WINPATH */
593
   m_q  = Def_macro( "?", outall,       M_MULTI|M_EXPANDED );
670
   m_q  = Def_macro( "?", outall,       M_MULTI|M_EXPANDED );
594
   m_b  = Def_macro( "<", inf,          M_MULTI|M_EXPANDED );
671
   m_b  = Def_macro( "<", inf,          M_MULTI|M_EXPANDED );
595
   m_l  = Def_macro( "&", all,          M_MULTI|M_EXPANDED );
672
   m_l  = Def_macro( "&", all,          M_MULTI|M_EXPANDED );
596
   m_up = Def_macro( "^", imm,          M_MULTI|M_EXPANDED );
673
   m_up = Def_macro( "^", imm,          M_MULTI|M_EXPANDED );
597
   m_bb = Def_macro( "*", cp->ce_per,   M_MULTI );
598
674
599
   _recipes[ RP_RECIPE ] = cp->ce_recipe;
675
   _recipes[ RP_RECIPE ] = cp->ce_recipe;
600
676
Lines 649-661 Link Here
649
	 /* If a recipe is found use it. Note this misses F_MULTI targets. */
725
	 /* If a recipe is found use it. Note this misses F_MULTI targets. */
650
	 if( !(cp->ce_flag & F_SINGLE) ) /* Execute the recipes once ... */
726
	 if( !(cp->ce_flag & F_SINGLE) ) /* Execute the recipes once ... */
651
	       rval = Exec_commands( cp );
727
	       rval = Exec_commands( cp );
728
	 /* Update_time_stamp() is called inside Exec_commands() after the
729
	  * last recipe line is finished. (In _finished_child()) */
652
	 else {				 /* or for every out of date dependency
730
	 else {				 /* or for every out of date dependency
653
					  * if the ruleop ! was used. */
731
					  * if the ruleop ! was used. */
654
	    TKSTR tk;
732
	    TKSTR tk;
655
733
734
	    /* We will redefine $? to be the prerequisite that the recipes
735
	     * are currently evaluated for. FIXME: Put this in man page. */
656
	    _drop_mac( m_q );
736
	    _drop_mac( m_q );
657
737
658
	    /* Build all out of date prerequisites. */
738
	    /* Execute recipes for each out out of date prerequisites.
739
	     * WARNING! If no prerequisite is given the recipes are not
740
	     * executed at all! */
659
	    if( outall && *outall ) {
741
	    if( outall && *outall ) {
660
	       /* Wait for each prerequisite to finish, save the status
742
	       /* Wait for each prerequisite to finish, save the status
661
		* of Wait_for_completion. */
743
		* of Wait_for_completion. */
Lines 664-675 Link Here
664
746
665
	       SET_TOKEN( &tk, outall );
747
	       SET_TOKEN( &tk, outall );
666
748
667
	       /* No need to update the target timestamp until all
749
	       /* No need to update the target timestamp/removing temporary
668
		* prerequisites are done. */
750
		* prerequisites (Update_time_stamp() in _finished_child())
751
		* until all prerequisites are done. */
669
	       Doing_bang = TRUE;
752
	       Doing_bang = TRUE;
670
	       name = Get_token( &tk, "", FALSE );
753
	       name = Get_token( &tk, "", FALSE );
754
	       /* This loop might fail if outall contains filenames with
755
		* spaces. */
671
	       do {
756
	       do {
672
		  m_q->ht_value = name;
757
		  /* Set $? to current prerequisite. */
758
		   m_q->ht_value = name;
673
759
674
		  rval = Exec_commands( cp );
760
		  rval = Exec_commands( cp );
675
		  Unlink_temp_files(cp);
761
		  Unlink_temp_files(cp);
Lines 680-685 Link Here
680
	    }
766
	    }
681
767
682
	    Update_time_stamp( cp );
768
	    Update_time_stamp( cp );
769
	    /* Erase $? again. Don't free the pointer, it was part of outall. */
683
	    m_q->ht_value = NIL(char);
770
	    m_q->ht_value = NIL(char);
684
	 }
771
	 }
685
      }
772
      }
Lines 724-730 Link Here
724
      if( push ) {
811
      if( push ) {
725
	 char *dir   = nsetdirroot ? nsetdirroot->ce_dir : Makedir;
812
	 char *dir   = nsetdirroot ? nsetdirroot->ce_dir : Makedir;
726
	 /* get relative path from current SETDIR to new SETDIR. */
813
	 /* get relative path from current SETDIR to new SETDIR. */
727
	 char *pref  = _prefix(dir,tcp->ce_dir);
814
	 /* Attention, even with .WINPATH set this has to be a POSIX
815
	  * path as ce_fname neeed to be POSIX. */
816
	 char *pref  = _prefix( dir, tcp->ce_dir );
728
	 char *nname = Build_path(pref, tcp->ce_fname);
817
	 char *nname = Build_path(pref, tcp->ce_fname);
729
818
730
	 FREE(pref);
819
	 FREE(pref);
Lines 761-767 Link Here
761
      }
850
      }
762
   }
851
   }
763
852
764
   while( push-- )
853
   if( push )
765
      Pop_dir(FALSE);
854
      Pop_dir(FALSE);
766
855
767
   /* Undefine the strings that we used for constructing inferred
856
   /* Undefine the strings that we used for constructing inferred
Lines 1196-1201 Link Here
1196
      shell  = ((l_attr & A_SHELL) != 0);
1285
      shell  = ((l_attr & A_SHELL) != 0);
1197
      useshell->ht_value = (group||shell)?"yes":"no";
1286
      useshell->ht_value = (group||shell)?"yes":"no";
1198
1287
1288
      /* All macros are expanded before putting them in the "process queue".
1289
       * Nothing in Expand() should be able to change dynamic macros. */
1199
      cmnd = Expand( rp->st_string );
1290
      cmnd = Expand( rp->st_string );
1200
1291
1201
      if( new_attr && (p = DmStrSpn(cmnd," \t\n+-@%")) != cmnd )
1292
      if( new_attr && (p = DmStrSpn(cmnd," \t\n+-@%")) != cmnd )
Lines 1231-1237 Link Here
1231
	    strcpy(cmnd,p);
1322
	    strcpy(cmnd,p);
1232
      }
1323
      }
1233
1324
1325
#if defined(MSDOS)
1234
      Swap_on_exec = ((l_attr & A_SWAP) != 0);	  /* Swapping for DOS only */
1326
      Swap_on_exec = ((l_attr & A_SWAP) != 0);	  /* Swapping for DOS only */
1327
#endif
1235
      do_it = !Trace;
1328
      do_it = !Trace;
1236
1329
1237
      /* We force execution of the recipe if we are tracing and the .EXECUTE
1330
      /* We force execution of the recipe if we are tracing and the .EXECUTE
Lines 1349-1355 Link Here
1349
   Change the current working directory to dir and save the current
1442
   Change the current working directory to dir and save the current
1350
   working directory on the stack so that we can come back.
1443
   working directory on the stack so that we can come back.
1351
   
1444
   
1352
   If ignore is TRUE then do not complain about _ch_dir if not possible.*/
1445
   If ignore is TRUE then do not complain about _ch_dir if not possible.
1446
1447
   Return 1 if the directory change was successfull and 0 otherwise. */
1353
char *dir;
1448
char *dir;
1354
char *name;
1449
char *name;
1355
int  ignore;
1450
int  ignore;
Lines 1440-1456 Link Here
1440
static void
1535
static void
1441
_set_tmd()/*
1536
_set_tmd()/*
1442
============
1537
============
1443
   Set the TMD Macro. This is the path from the present directory (value of
1538
   Set the TMD Macro and the Tmd global variable. TMD stands for "To MakeDir"
1444
   $(PWD)) to the directory dmake was started up in (value of $(MAKEDIR)).
1539
   and is the path from the present directory (value of $(PWD)) to the directory
1540
   dmake was started up in (value of $(MAKEDIR)). As _prefix() can return absolute
1541
   paths some special .WINPATH treatment is needed.
1445
*/
1542
*/
1446
{
1543
{
1447
   char  *tmd;
1544
   char  *tmd;
1448
1545
1546
   if( Tmd )
1547
      FREE(Tmd);
1548
1449
   tmd = _prefix(Pwd, Makedir);
1549
   tmd = _prefix(Pwd, Makedir);
1450
   if( *tmd ) {
1550
   if( *tmd ) {
1451
      Def_macro( "TMD", tmd, M_FORCE | M_EXPANDED );
1551
      Def_macro( "TMD", DO_WINPATH(tmd), M_FORCE | M_EXPANDED );
1552
      Tmd = DmStrDup(tmd);
1452
   } else {
1553
   } else {
1453
      Def_macro( "TMD", ".", M_FORCE | M_EXPANDED );
1554
      Def_macro( "TMD", ".", M_FORCE | M_EXPANDED );
1555
      Tmd = DmStrDup(".");
1454
   }
1556
   }
1455
   FREE( tmd );
1557
   FREE( tmd );
1456
}
1558
}
(-)dmake/rulparse.c (-1 / +8 lines)
Lines 1460-1466 Link Here
1460
	 else if( flag == A_SEQ )     Def_macro(".SEQUENTIAL","y", M_EXPANDED);
1460
	 else if( flag == A_SEQ )     Def_macro(".SEQUENTIAL","y", M_EXPANDED);
1461
	 else if( flag == A_SHELL )   Def_macro(".USESHELL",  "y", M_EXPANDED);
1461
	 else if( flag == A_SHELL )   Def_macro(".USESHELL",  "y", M_EXPANDED);
1462
	 else if( flag == A_MKSARGS ) Def_macro(".MKSARGS",   "y", M_EXPANDED);
1462
	 else if( flag == A_MKSARGS ) Def_macro(".MKSARGS",   "y", M_EXPANDED);
1463
#if !defined(__CYGWIN__)
1463
	 else if( flag == A_SWAP )    Def_macro(".SWAP",      "y", M_EXPANDED);
1464
	 else if( flag == A_SWAP )    Def_macro(".SWAP",      "y", M_EXPANDED);
1465
#else
1466
	 else if( flag == A_SWAP )    Def_macro(".WINPATH",   "y", M_EXPANDED);
1467
#endif
1464
      }
1468
      }
1465
1469
1466
   attr &= ~A_GLOB;
1470
   attr &= ~A_GLOB;
Lines 1499-1505 Link Here
1499
   
1503
   
1500
   Valid attributes are:  .IGNORE, .SETDIR=, .SILENT, .PRECIOUS, .LIBRARY,
1504
   Valid attributes are:  .IGNORE, .SETDIR=, .SILENT, .PRECIOUS, .LIBRARY,
1501
                          .EPILOG, .PROLOG,  .LIBRARYM, .SYMBOL, .UPDATEALL,
1505
                          .EPILOG, .PROLOG,  .LIBRARYM, .SYMBOL, .UPDATEALL,
1502
			  .USESHELL, .NOINFER, .PHONY, .SWAP, .SEQUENTIAL
1506
			  .USESHELL, .NOINFER, .PHONY, .SWAP/.WINPATH, .SEQUENTIAL
1503
			  .NOSTATE,  .MKSARGS, .IGNOREGROUP, .GROUP, .FIRST
1507
			  .NOSTATE,  .MKSARGS, .IGNOREGROUP, .GROUP, .FIRST
1504
			  .EXECUTE, .ERRREMOVE
1508
			  .EXECUTE, .ERRREMOVE
1505
1509
Lines 1561-1569 Link Here
1561
            else if( !strcmp(name, "SILENT") )    attr = A_SILENT;
1565
            else if( !strcmp(name, "SILENT") )    attr = A_SILENT;
1562
            else if( !strcmp(name, "SYMBOL") )    attr = A_SYMBOL;
1566
            else if( !strcmp(name, "SYMBOL") )    attr = A_SYMBOL;
1563
            else if( !strcmp(name, "SEQUENTIAL")) attr = A_SEQ;
1567
            else if( !strcmp(name, "SEQUENTIAL")) attr = A_SEQ;
1568
	    /* A_SWAP has no meaning except for MSDOS and cygwin (see below). */
1564
            else if( !strcmp(name, "SWAP"))       attr = A_SWAP;
1569
            else if( !strcmp(name, "SWAP"))       attr = A_SWAP;
1565
            else attr = 0;
1570
            else attr = 0;
1566
            break;
1571
            break;
1572
1573
         case 'W': attr = (strcmp(name, "WINPATH"))  ? 0 : A_SWAP; break;
1567
      }
1574
      }
1568
1575
1569
   DB_RETURN( attr );
1576
   DB_RETURN( attr );
(-)dmake/sysintf.c (-6 / +45 lines)
Lines 72-78 Link Here
72
#   include <sys/timeb.h>
72
#   include <sys/timeb.h>
73
#endif
73
#endif
74
74
75
/* for cygwin_conv_to_posix_path() in Prolog() */
75
/* for cygwin_conv_to_posix_path() in Prolog() and for cygdospath()*/
76
#if __CYGWIN__
76
#if __CYGWIN__
77
#   include <sys/cygwin.h>
77
#   include <sys/cygwin.h>
78
#   include <errno.h>
78
#   include <errno.h>
Lines 934-944 Link Here
934
   /* Scan the list of prerequisites and if we find one that is
934
   /* Scan the list of prerequisites and if we find one that is
935
    * marked as being removable, (ie. an inferred intermediate node)
935
    * marked as being removable, (ie. an inferred intermediate node)
936
    * then remove it.  We remove a prerequisite by running the recipe
936
    * then remove it.  We remove a prerequisite by running the recipe
937
    * associated with the special target .REMOVE, with $< set to
937
    * associated with the special target .REMOVE.
938
    * the list of prerequisites to remove. */
938
    * Typically .REMOVE is defined in the startup file as:
939
939
    *  .REMOVE :; $(RM) $<
940
   /* Make sure we don't try to remove prerequisites for the .REMOVE
940
    * with $< being the list of prerequisites specified in the current
941
    * target. */
941
    * target. (Make() sets $< .) */
942
   if( strcmp(cp->CE_NAME,".REMOVE") != 0 &&
942
   if( strcmp(cp->CE_NAME,".REMOVE") != 0 &&
943
       (hp = Get_name(".REMOVE", Defs, FALSE)) != NIL(HASH) ) {
943
       (hp = Get_name(".REMOVE", Defs, FALSE)) != NIL(HASH) ) {
944
      register LINKPTR dp;
944
      register LINKPTR dp;
Lines 1009-1012 Link Here
1009
   if( (buf.st_mode & S_IFMT) == S_IFDIR )
1009
   if( (buf.st_mode & S_IFMT) == S_IFDIR )
1010
      return 1;
1010
      return 1;
1011
   return(unlink(name));
1011
   return(unlink(name));
1012
}
1013
1014
1015
char *
1016
cygdospath(char *src, int winpath)/*
1017
====================================
1018
   Convert to DOS path if winpath is true. The returned pointer is
1019
   either the original pointer or a pointer to a static buffer.
1020
*/
1021
{
1022
   static char *buf = NIL(char);
1023
1024
   if ( !buf && ( (buf = MALLOC( PATH_MAX, char)) == NIL(char) ) )
1025
      No_ram();
1026
1027
   DB_PRINT( "cygdospath", ("converting [%s] with winpath [%d]", src, winpath ) );
1028
1029
   /* Return immediately on NULL pointer or when .WINPATH is
1030
    * not set. */
1031
   if( !src || !winpath )
1032
      return src;
1033
1034
   if( *src && src[0] == '/' ) {
1035
      char *tmp;
1036
      int err = cygwin_conv_to_win32_path(src, buf);
1037
      if (err)
1038
	 Fatal( "error converting \"%s\" - %s\n",
1039
		src, strerror (errno));
1040
1041
      tmp = buf;
1042
      while ((tmp = strchr (tmp, '\\')) != NULL) {
1043
	 *tmp = '/';
1044
	 tmp++;
1045
      }
1046
1047
      return buf;
1048
   }
1049
   else
1050
      return src;
1012
}
1051
}
(-)dmake/vextern.h (-2 / +9 lines)
Lines 40-45 Link Here
40
EXTERN	int	Line_number;	/* Current line number in make file parse */
40
EXTERN	int	Line_number;	/* Current line number in make file parse */
41
EXTERN	t_attr	Glob_attr;	/* Global attrs to control global ops     */
41
EXTERN	t_attr	Glob_attr;	/* Global attrs to control global ops     */
42
EXTERN	char*	Makedir;	/* pointer to macro value for MAKEDIR     */
42
EXTERN	char*	Makedir;	/* pointer to macro value for MAKEDIR     */
43
EXTERN	char*	Makedir_macval;	/* value of MAKEDIR (for .WINPATH)        */
43
EXTERN	char*	Shell;		/* pointer to macro value for SHELL       */
44
EXTERN	char*	Shell;		/* pointer to macro value for SHELL       */
44
EXTERN	char*	Shell_flags;	/* pointer to macro value for SHELLFLAGS  */
45
EXTERN	char*	Shell_flags;	/* pointer to macro value for SHELLFLAGS  */
45
EXTERN	char*	GShell;		/* pointer to macro value for GROUPSHELL  */
46
EXTERN	char*	GShell;		/* pointer to macro value for GROUPSHELL  */
Lines 49-56 Link Here
49
EXTERN	char*   DirSepStr;	/* pointer to macro value for DIRSEPSTR   */
50
EXTERN	char*   DirSepStr;	/* pointer to macro value for DIRSEPSTR   */
50
EXTERN	char*	AbsPname;	/* pointer to macro value for ABSMAKECMD  */
51
EXTERN	char*	AbsPname;	/* pointer to macro value for ABSMAKECMD  */
51
EXTERN	char*	Pname;		/* dmake process invoke name              */
52
EXTERN	char*	Pname;		/* dmake process invoke name              */
52
EXTERN	char*	Pwd;		/* current working dir, value of PWD	  */
53
EXTERN	char*	Pwd;		/* current working dir                    */
54
EXTERN	char*	Pwd_macval;	/* value of PWD	(for .WINPATH)            */
53
EXTERN	char*	Tmd;		/* path to directory where dmake started  */
55
EXTERN	char*	Tmd;		/* path to directory where dmake started  */
56
EXTERN	char*	Tmd_macval;	/* value of TMD (for .WINPATH)            */
54
EXTERN	char*	Spacechar;	/* pointer to macro value for SPACECHAR   */
57
EXTERN	char*	Spacechar;	/* pointer to macro value for SPACECHAR   */
55
EXTERN	char*	Keep_state;	/* current .KEEP_STATE file		  */
58
EXTERN	char*	Keep_state;	/* current .KEEP_STATE file		  */
56
EXTERN  char*   Escape_char;	/* Current escape character               */
59
EXTERN  char*   Escape_char;	/* Current escape character               */
Lines 68-74 Link Here
68
EXTERN	int	Def_targets;	/* TRUE if defining targets - Only used	  *
71
EXTERN	int	Def_targets;	/* TRUE if defining targets - Only used	  *
69
				 * in Def_cell().			  */
72
				 * in Def_cell().			  */
70
EXTERN  int	Skip_to_eof;	/* TRUE if asked to skip to eof on input  */
73
EXTERN  int	Skip_to_eof;	/* TRUE if asked to skip to eof on input  */
71
EXTERN  int     NameMax;        /* The value of NAMEMAX                   */
74
EXTERN	int	NameMax;	/* The value of NAMEMAX                   */
75
EXTERN	int	UseWinpath;	/* True if .WINPATH is set for currently  *
76
				 * made target.                           */
72
#if __CYGWIN__
77
#if __CYGWIN__
73
EXTERN  char*   CygDrvPre;      /* Drive prefix used by cygwin            */
78
EXTERN  char*   CygDrvPre;      /* Drive prefix used by cygwin            */
74
EXTERN  int     CygDrvPreLen;   /* Drive prefix length used by cygwin     */
79
EXTERN  int     CygDrvPreLen;   /* Drive prefix length used by cygwin     */
Lines 87-93 Link Here
87
EXTERN  int	Doing_bang;	/* TRUE if target timestamp needs not to be
92
EXTERN  int	Doing_bang;	/* TRUE if target timestamp needs not to be
88
				 * updated immediately. */
93
				 * updated immediately. */
89
EXTERN  int	Packed_shell;	/* TRUE if packed args to use a shell	  */
94
EXTERN  int	Packed_shell;	/* TRUE if packed args to use a shell	  */
95
#if defined(MSDOS)
90
EXTERN  int	Swap_on_exec;	/* TRUE if going to swap on exec call     */
96
EXTERN  int	Swap_on_exec;	/* TRUE if going to swap on exec call     */
97
#endif
91
EXTERN  int	State;		/* parser state				  */
98
EXTERN  int	State;		/* parser state				  */
92
EXTERN  int	Group;		/* parsing a group recipe ==> TRUE        */
99
EXTERN  int	Group;		/* parsing a group recipe ==> TRUE        */
93
 
100
 
(-)dmake/unix/rmprq.c (-39 / +12 lines)
Lines 30-48 Link Here
30
#include "extern.h"
30
#include "extern.h"
31
31
32
PUBLIC void
32
PUBLIC void
33
Remove_prq( tcp )
33
Remove_prq( tcp )/*
34
===================
35
   The saving of the dynamic macros is not needed as this function
36
   (Update_time_stamp()->Remove_prq()) is always called after Make()
37
   already finished the recipes (Exec_commands()) for this target.
38
*/
34
CELLPTR tcp;
39
CELLPTR tcp;
35
{
40
{
36
   static  LINKPTR rlp = NIL(LINK);
41
   static  LINKPTR rlp = NIL(LINK);
37
   static  int flag = 0;
38
   static  HASHPTR m_at, m_q, m_b, m_g, m_l, m_bb, m_up;
39
   char    *m_at_s, *m_g_s, *m_q_s, *m_b_s, *m_l_s, *m_bb_s, *m_up_s;
40
   LINKPTR tlp;
42
   LINKPTR tlp;
41
43
44
   /* Unset F_MADE and F_VISITED. */
42
   tcp->ce_flag         &= ~(F_MADE|F_VISITED);
45
   tcp->ce_flag         &= ~(F_MADE|F_VISITED);
43
   tcp->ce_time          = 0L;
46
   tcp->ce_time          = 0L;
44
47
48
   /* The idea seems to be to create a target that is used to remove
49
    * intermediate prerequisites. Why add something to the "CeMeToo(tlp)"
50
    * list? I don't understand this yet. */
45
   for( tlp=rlp; tlp !=NIL(LINK); tlp=tlp->cl_next )
51
   for( tlp=rlp; tlp !=NIL(LINK); tlp=tlp->cl_next )
52
      /* Find first target that has F_VISITED not set or F_MADE set,
53
       * i.e. it is not currently made or already done. */
46
      if( (tlp->cl_prq->ce_flag & (F_VISITED|F_MADE)) != F_VISITED )
54
      if( (tlp->cl_prq->ce_flag & (F_VISITED|F_MADE)) != F_VISITED )
47
	 break;
55
	 break;
48
56
Lines 55-98 Link Here
55
63
56
   *tlp->cl_prq = *tcp;
64
   *tlp->cl_prq = *tcp;
57
65
58
   /* We save the dynamic macro values here, as it is possible that the
59
    * .REMOVE recipe is getting executed for a target while some other target
60
    * is in the middle of executing it's list of recipe lines, in this case
61
    * the values of $@ etc, must be preserved so that when we return to
62
    * complete the other recipe we must make certain that the values of it's
63
    * dynamic macros are unmodified. */
64
65
   if( !flag ) {
66
      /* Do the getting of the macros only once. */
67
      flag = 1;
68
      m_at = Get_name("@", Macs, TRUE);
69
      m_g  = Get_name(">", Macs, TRUE);
70
      m_q  = Get_name("?", Macs, TRUE);
71
      m_b  = Get_name("<", Macs, TRUE);
72
      m_l  = Get_name("&", Macs, TRUE);
73
      m_bb = Get_name("*", Macs, TRUE);
74
      m_up = Get_name("^", Macs, TRUE);
75
   }
76
77
   m_at_s = m_at->ht_value; m_at->ht_value = NIL(char);
78
   m_g_s  = m_g->ht_value;  m_g->ht_value  = NIL(char);
79
   m_q_s  = m_q->ht_value;  m_q->ht_value  = NIL(char);
80
   m_b_s  = m_b->ht_value;  m_b->ht_value  = NIL(char);
81
   m_l_s  = m_l->ht_value;  m_l->ht_value  = NIL(char);
82
   m_bb_s = m_bb->ht_value; m_bb->ht_value = NIL(char);
83
   m_up_s = m_up->ht_value; m_up->ht_value = NIL(char);
84
85
   Make( tlp->cl_prq, tcp );
66
   Make( tlp->cl_prq, tcp );
86
   if( tlp->cl_prq->ce_dir ){
67
   if( tlp->cl_prq->ce_dir ){
87
      FREE(tlp->cl_prq->ce_dir);
68
      FREE(tlp->cl_prq->ce_dir);
88
      tlp->cl_prq->ce_dir=NIL(char);
69
      tlp->cl_prq->ce_dir=NIL(char);
89
   }
70
   }
90
91
   m_at->ht_value = m_at_s;
92
   m_g->ht_value  = m_g_s;
93
   m_q->ht_value  = m_q_s;
94
   m_b->ht_value  = m_b_s;
95
   m_l->ht_value  = m_l_s;
96
   m_bb->ht_value = m_bb_s;
97
   m_up->ht_value = m_up_s;
98
}
71
}

Return to issue 73499