1 /* $RCSfile: rmprq.c,v $
3 -- last change: $Author: obo $ $Date: 2007-06-12 06:09:05 $
6 -- Remove prerequisites code.
9 -- This code is different for DOS and for UNIX and parallel make
10 -- architectures since the parallel case requires the rm's to be
11 -- run in parallel, whereas DOS guarantees to run them sequentially.
14 -- Dennis Vadura, dvadura@dmake.wticorp.com
17 -- http://dmake.wticorp.com/
20 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
22 -- This program is NOT free software; you can redistribute it and/or
23 -- modify it under the terms of the Software License Agreement Provided
24 -- in the file <distribution-root>/readme/license.txt.
27 -- Use cvs log to obtain detailed change logs.
35 Removable targets (ie. an inferred intermediate node) are removed
36 by this function by running Make() on the special target .REMOVE
38 As this function can be called from within another Make() (for example
40 Make()->Exec_commands()->Do_cmnd()->runargv()->..->_finished_child()
41 ->Update_time_stamp()->Remove_prq() )
42 it is necessary to store and restore the dynamic macros when Make()
45 FIXME: Another potential problem is that while building .REMOVE another
46 previously started target finishes and from _finished_child() calls
47 Remove_prq() again. This will delete the dynamic macros and possibly
48 clear/reset the prerequisites of the previous .REMOVE target.
52 static LINKPTR rlp
= NIL(LINK
);
54 static HASHPTR m_at
, m_q
, m_b
, m_g
, m_l
, m_bb
, m_up
;
55 char *m_at_s
, *m_g_s
, *m_q_s
, *m_b_s
, *m_l_s
, *m_bb_s
, *m_up_s
;
58 /* Unset F_MADE and F_VISITED. */
59 tcp
->ce_flag
&= ~(F_MADE
|F_VISITED
);
62 /* The idea seems to be to create a target that is used to remove
63 * intermediate prerequisites. Why add something to the "CeMeToo(tlp)"
64 * list? I don't understand this yet.
65 * FIXME! Either comment on what is going on or fix the code. */
66 for( tlp
=rlp
; tlp
!=NIL(LINK
); tlp
=tlp
->cl_next
)
67 /* Find first target that has F_VISITED not set or F_MADE set,
68 * i.e. it is not currently made or already done. */
69 if( (tlp
->cl_prq
->ce_flag
& (F_VISITED
|F_MADE
)) != F_VISITED
)
72 if( tlp
== NIL(LINK
) ) {
74 TALLOC(tlp
->cl_prq
, 1, CELL
);
81 /* We save the dynamic macro values here, as it is possible that the
82 * .REMOVE recipe is getting executed for a target while some other target
83 * is in the middle of executing it's list of recipe lines, in this case
84 * the values of $@ etc, must be preserved so that when we return to
85 * complete the other recipe we must make certain that the values of it's
86 * dynamic macros are unmodified. */
89 /* Do the getting of the macros only once. */
91 m_at
= Get_name("@", Macs
, TRUE
);
92 m_g
= Get_name(">", Macs
, TRUE
);
93 m_q
= Get_name("?", Macs
, TRUE
);
94 m_b
= Get_name("<", Macs
, TRUE
);
95 m_l
= Get_name("&", Macs
, TRUE
);
96 m_bb
= Get_name("*", Macs
, TRUE
);
97 m_up
= Get_name("^", Macs
, TRUE
);
100 m_at_s
= m_at
->ht_value
; m_at
->ht_value
= NIL(char);
101 m_g_s
= m_g
->ht_value
; m_g
->ht_value
= NIL(char);
102 m_q_s
= m_q
->ht_value
; m_q
->ht_value
= NIL(char);
103 m_b_s
= m_b
->ht_value
; m_b
->ht_value
= NIL(char);
104 m_l_s
= m_l
->ht_value
; m_l
->ht_value
= NIL(char);
105 m_bb_s
= m_bb
->ht_value
; m_bb
->ht_value
= NIL(char);
106 m_up_s
= m_up
->ht_value
; m_up
->ht_value
= NIL(char);
108 Make( tlp
->cl_prq
, tcp
);
109 if( tlp
->cl_prq
->ce_dir
){
110 FREE(tlp
->cl_prq
->ce_dir
);
111 tlp
->cl_prq
->ce_dir
=NIL(char);
114 m_at
->ht_value
= m_at_s
;
115 m_g
->ht_value
= m_g_s
;
116 m_q
->ht_value
= m_q_s
;
117 m_b
->ht_value
= m_b_s
;
118 m_l
->ht_value
= m_l_s
;
119 m_bb
->ht_value
= m_bb_s
;
120 m_up
->ht_value
= m_up_s
;