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 |
} |