Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / config / xml / object.xsl
1 <?xml version="1.0" encoding="ISO-8859-15" ?>
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
4  
5  <!-- wrapper that calls "objects" with parameters -->
6  <xsl:template match="/" mode="objects">
7   <xsl:call-template name="objects">
8    <xsl:with-param name="target" select="'host'"/>
9   </xsl:call-template>
10   <xsl:call-template name="objects">
11    <xsl:with-param name="target" select="'target'"/>
12   </xsl:call-template>
13  </xsl:template>
14
15  <!-- main work happens here -->
16  <xsl:template name="objects">
17
18   <xsl:param name="target"/>
19     
20   <xsl:text>&#10;#&#10;# </xsl:text>
21   <xsl:value-of select="$target"/>
22   <xsl:text> compiler rules&#10;#&#10;&#10;</xsl:text>
23   
24   <!-- create rules for all compile objects -->
25   <xsl:for-each select="//object[(ancestor-or-self::*)[@target = $target]]">
26   
27    <xsl:variable name="path">
28     <xsl:for-each select="ancestor::build">
29      <xsl:call-template name="get-dirname">
30       <xsl:with-param select="@base" name="path"/>
31      </xsl:call-template>
32     </xsl:for-each>
33    </xsl:variable>
34      
35    <xsl:variable name="conditions">
36     <xsl:text>0</xsl:text>
37     <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
38      <xsl:call-template name="resolve-condition">
39       <xsl:with-param select="@condition" name="expression"/>
40      </xsl:call-template>
41     </xsl:for-each>
42    </xsl:variable>
43      
44    <xsl:if test="$conditions=0">
45
46     <!-- full path of object file -->
47     <xsl:text>$(ODIR)/</xsl:text>
48     <xsl:value-of select="$target"/>
49     <xsl:text>/</xsl:text>
50     <xsl:value-of select="$path"/>
51     <xsl:value-of select="substring-before(@source,'.')"/>
52     <xsl:text>.o: </xsl:text>
53  
54     <!-- path of source file -->
55     <xsl:value-of select="$path"/>
56     <xsl:value-of select="@source"/>
57
58
59     <xsl:choose>
60      <xsl:when test="child::rule">
61       <xsl:value-of select="child::rule"/>
62       <xsl:text>&#10;</xsl:text>
63      </xsl:when>
64      <xsl:otherwise>
65        <xsl:choose>
66          <xsl:when test="@flags!=''">
67            <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='object'][@extracflags='1']"/>
68            <xsl:text> </xsl:text>
69            <xsl:value-of select="@flags"/>
70            <xsl:text> </xsl:text>
71            <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='object'][@extracflags='2']"/>
72          </xsl:when>
73          <xsl:otherwise>
74            <!-- FIXME this requires strict spaces in rules.xml -->
75            <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='object']"/>
76          </xsl:otherwise>
77        </xsl:choose>
78      </xsl:otherwise>
79     </xsl:choose>
80  
81    </xsl:if>
82   </xsl:for-each>
83  
84   <!-- Create linker targets for all executables -->
85   <xsl:for-each select="//executable">
86  
87    <xsl:variable name="outer-conditions">
88     <xsl:text>0</xsl:text>
89     <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
90      <xsl:call-template name="resolve-condition">
91       <xsl:with-param select="@condition" name="expression"/>
92      </xsl:call-template>
93     </xsl:for-each>
94    </xsl:variable>
95    
96    <xsl:if test="$outer-conditions = 0">
97     <xsl:if test="(ancestor-or-self::*)[@target = $target]">
98  
99      <!-- executable name -->
100      <xsl:text>$(ODIR)/</xsl:text>
101      <xsl:value-of select="@name"/>
102      <xsl:text>:</xsl:text>
103       
104      <!-- add all objects -->
105      <xsl:for-each select="object">
106   
107       <xsl:variable name="conditions">
108        <xsl:text>0</xsl:text>
109        <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
110         <xsl:call-template name="resolve-condition">
111          <xsl:with-param select="@condition" name="expression"/>
112         </xsl:call-template>
113        </xsl:for-each>
114       </xsl:variable>
115       
116       <xsl:if test="$conditions=0">
117        
118        <xsl:variable name="path">
119         <xsl:for-each select="ancestor::build">
120          <xsl:call-template name="get-dirname">
121           <xsl:with-param select="@base" name="path"/>
122          </xsl:call-template>
123         </xsl:for-each>
124        </xsl:variable>
125       
126        <xsl:text> $(ODIR)/</xsl:text>
127        <xsl:value-of select="$target"/>
128        <xsl:text>/</xsl:text>
129        <xsl:value-of select="$path"/>
130        <xsl:value-of select="substring-before(@source,'.')"/>
131        <xsl:text>.o</xsl:text>
132  
133       </xsl:if>
134      </xsl:for-each>
135  
136      <!-- external objects last -->
137      <xsl:for-each select="external-object">
138  
139       <xsl:variable name="conditions">
140        <xsl:text>0</xsl:text>
141        <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
142         <xsl:call-template name="resolve-condition">
143          <xsl:with-param select="@condition" name="expression"/>
144         </xsl:call-template>
145        </xsl:for-each>
146       </xsl:variable>
147       
148       <xsl:if test="$conditions=0">
149        <xsl:text> $(ODIR)/</xsl:text>
150        <xsl:value-of select="@source"/>
151       </xsl:if>
152         
153      </xsl:for-each>
154        
155      <!-- print executable rule --> 
156      <xsl:choose>
157       <xsl:when test="child::rule">
158        <xsl:value-of select="child::rule"/>
159        <xsl:text>&#10;</xsl:text>
160       </xsl:when>
161       <xsl:otherwise>
162        <!-- FIXME this requires strict spaces in rules.xml -->
163        <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='executable']"/>
164       </xsl:otherwise>
165      </xsl:choose>
166        
167     </xsl:if>
168    </xsl:if>
169   </xsl:for-each>
170
171   <!-- create linker targets for all libs -->
172   <xsl:for-each select="//library">
173    <xsl:sort select="@name"/>
174  
175    <xsl:variable name="outer-conditions">
176     <xsl:text>0</xsl:text>
177     <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
178      <xsl:call-template name="resolve-condition">
179       <xsl:with-param select="@condition" name="expression"/>
180      </xsl:call-template>
181     </xsl:for-each>
182    </xsl:variable>
183    
184    <xsl:if test="$outer-conditions = 0">
185
186    
187    <xsl:if test="(ancestor-or-self::*)[@target = $target]">
188    
189     <xsl:if test="not(preceding::library/@name = @name)">
190      
191      <!-- output library name -->
192      <xsl:text>$(ODIR)/lib</xsl:text>
193      <xsl:value-of select="@name"/>
194         
195      <xsl:choose>
196       <xsl:when test="@type='static'">
197        <xsl:text>.a</xsl:text>
198       </xsl:when>
199       <xsl:when test="@type='dynamic'">
200        <xsl:text>.so</xsl:text>
201       </xsl:when>
202      </xsl:choose>
203      <xsl:text>: </xsl:text>
204        
205      <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
206        
207      <!-- enumerate all objects for library target -->
208      <xsl:for-each select="//library[@name=$name]/object">
209      
210       <xsl:variable name="conditions">
211        <xsl:text>0</xsl:text>
212        <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
213         <xsl:call-template name="resolve-condition">
214          <xsl:with-param select="@condition" name="expression"/>
215         </xsl:call-template>
216        </xsl:for-each>
217       </xsl:variable>
218      
219       <xsl:if test="$conditions=0">
220         
221        <xsl:variable name="path">
222         <xsl:for-each select="ancestor::build">
223          <xsl:call-template name="get-dirname">
224           <xsl:with-param select="@base" name="path"/>
225          </xsl:call-template>
226         </xsl:for-each>
227        </xsl:variable>
228   
229        <xsl:text>$(ODIR)/</xsl:text>
230        <xsl:value-of select="$target"/>
231        <xsl:text>/</xsl:text>
232        <xsl:value-of select="$path"/>
233        <xsl:value-of select="substring-before(@source,'.')"/>
234        <xsl:text>.o </xsl:text>
235         
236       </xsl:if>
237        
238      </xsl:for-each>
239         
240      <!-- external objects last -->
241      <xsl:for-each select="external-object">
242  
243       <xsl:variable name="conditions">
244        <xsl:text>0</xsl:text>
245        <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
246         <xsl:call-template name="resolve-condition">
247          <xsl:with-param select="@condition" name="expression"/>
248         </xsl:call-template>
249        </xsl:for-each>
250       </xsl:variable>
251       
252       <xsl:if test="$conditions=0">
253        <xsl:text> $(ODIR)/</xsl:text>
254        <xsl:value-of select="@source"/>
255       </xsl:if>
256         
257      </xsl:for-each>
258        
259
260      <!-- FIXME this requires strict spaces in rules.xml -->
261      <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='library']"/>
262      
263     </xsl:if>
264    </xsl:if>
265    </xsl:if>
266   </xsl:for-each>
267  
268   <!-- create libs rule for all libraries -->
269   <xsl:value-of select="$target"/>
270   <xsl:text>-libraries: </xsl:text>
271   
272   <!-- don't build unused libraries
273   <xsl:for-each select="//library">
274    <xsl:if test="object[(ancestor-or-self::*)[@target = $target]]">
275  
276     <xsl:variable name="conditions">
277      <xsl:text>0</xsl:text>
278      <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
279       <xsl:call-template name="resolve-condition">
280        <xsl:with-param select="@condition" name="expression"/>
281       </xsl:call-template>
282      </xsl:for-each>
283     </xsl:variable>
284     <xsl:if test="$conditions=0">
285     <xsl:text> $(ODIR)/</xsl:text>
286     <xsl:text>lib</xsl:text>
287     <xsl:value-of select="@name"/>
288      <xsl:choose>
289       <xsl:when test="@type='static'">
290        <xsl:text>.a</xsl:text>
291       </xsl:when>
292       <xsl:when test="@type='dynamic'">
293        <xsl:text>.so</xsl:text>
294       </xsl:when>
295      </xsl:choose>
296     </xsl:if>
297    </xsl:if>
298   </xsl:for-each>
299   -->
300   <xsl:text>&#10;</xsl:text>
301   
302   <!-- create exe rule for all executables -->
303   <xsl:value-of select="$target"/>
304   <xsl:text>-executables: </xsl:text>
305   
306   <xsl:for-each select="//executable">
307    <xsl:if test="(ancestor-or-self::*)[@target = $target]">
308
309     <xsl:variable name="conditions">
310      <xsl:text>0</xsl:text>
311      <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
312       <xsl:call-template name="resolve-condition">
313        <xsl:with-param select="@condition" name="expression"/>
314       </xsl:call-template>
315      </xsl:for-each>
316     </xsl:variable>
317     <xsl:if test="$conditions=0">
318      <xsl:text> $(ODIR)/</xsl:text>
319      <xsl:value-of select="@name"/>
320     </xsl:if>
321    </xsl:if>
322   </xsl:for-each>
323   <xsl:text>&#10;</xsl:text>
324   
325  </xsl:template>
326  
327 </xsl:stylesheet>