1 <?xml version="1.0" encoding="ISO-8859-15" ?>
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
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'"/>
10 <xsl:call-template name="objects">
11 <xsl:with-param name="target" select="'target'"/>
15 <!-- main work happens here -->
16 <xsl:template name="objects">
18 <xsl:param name="target"/>
20 <xsl:text> # # </xsl:text>
21 <xsl:value-of select="$target"/>
22 <xsl:text> compiler rules # </xsl:text>
24 <!-- create rules for all compile objects -->
25 <xsl:for-each select="//object[(ancestor-or-self::*)[@target = $target]]">
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"/>
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"/>
44 <xsl:if test="$conditions=0">
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>
54 <!-- path of source file -->
55 <xsl:value-of select="$path"/>
56 <xsl:value-of select="@source"/>
60 <xsl:when test="child::rule">
61 <xsl:value-of select="child::rule"/>
62 <xsl:text> </xsl:text>
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']"/>
74 <!-- FIXME this requires strict spaces in rules.xml -->
75 <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='object']"/>
84 <!-- Create linker targets for all executables -->
85 <xsl:for-each select="//executable">
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"/>
96 <xsl:if test="$outer-conditions = 0">
97 <xsl:if test="(ancestor-or-self::*)[@target = $target]">
99 <!-- executable name -->
100 <xsl:text>$(ODIR)/</xsl:text>
101 <xsl:value-of select="@name"/>
102 <xsl:text>:</xsl:text>
104 <!-- add all objects -->
105 <xsl:for-each select="object">
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"/>
116 <xsl:if test="$conditions=0">
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"/>
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>
136 <!-- external objects last -->
137 <xsl:for-each select="external-object">
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"/>
148 <xsl:if test="$conditions=0">
149 <xsl:text> $(ODIR)/</xsl:text>
150 <xsl:value-of select="@source"/>
155 <!-- print executable rule -->
157 <xsl:when test="child::rule">
158 <xsl:value-of select="child::rule"/>
159 <xsl:text> </xsl:text>
162 <!-- FIXME this requires strict spaces in rules.xml -->
163 <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='executable']"/>
171 <!-- create linker targets for all libs -->
172 <xsl:for-each select="//library">
173 <xsl:sort select="@name"/>
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"/>
184 <xsl:if test="$outer-conditions = 0">
187 <xsl:if test="(ancestor-or-self::*)[@target = $target]">
189 <xsl:if test="not(preceding::library/@name = @name)">
191 <!-- output library name -->
192 <xsl:text>$(ODIR)/lib</xsl:text>
193 <xsl:value-of select="@name"/>
196 <xsl:when test="@type='static'">
197 <xsl:text>.a</xsl:text>
199 <xsl:when test="@type='dynamic'">
200 <xsl:text>.so</xsl:text>
203 <xsl:text>: </xsl:text>
205 <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
207 <!-- enumerate all objects for library target -->
208 <xsl:for-each select="//library[@name=$name]/object">
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"/>
219 <xsl:if test="$conditions=0">
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"/>
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>
240 <!-- external objects last -->
241 <xsl:for-each select="external-object">
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"/>
252 <xsl:if test="$conditions=0">
253 <xsl:text> $(ODIR)/</xsl:text>
254 <xsl:value-of select="@source"/>
260 <!-- FIXME this requires strict spaces in rules.xml -->
261 <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='library']"/>
268 <!-- create libs rule for all libraries -->
269 <xsl:value-of select="$target"/>
270 <xsl:text>-libraries: </xsl:text>
272 <!-- don't build unused libraries
273 <xsl:for-each select="//library">
274 <xsl:if test="object[(ancestor-or-self::*)[@target = $target]]">
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"/>
284 <xsl:if test="$conditions=0">
285 <xsl:text> $(ODIR)/</xsl:text>
286 <xsl:text>lib</xsl:text>
287 <xsl:value-of select="@name"/>
289 <xsl:when test="@type='static'">
290 <xsl:text>.a</xsl:text>
292 <xsl:when test="@type='dynamic'">
293 <xsl:text>.so</xsl:text>
300 <xsl:text> </xsl:text>
302 <!-- create exe rule for all executables -->
303 <xsl:value-of select="$target"/>
304 <xsl:text>-executables: </xsl:text>
306 <xsl:for-each select="//executable">
307 <xsl:if test="(ancestor-or-self::*)[@target = $target]">
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"/>
317 <xsl:if test="$conditions=0">
318 <xsl:text> $(ODIR)/</xsl:text>
319 <xsl:value-of select="@name"/>
323 <xsl:text> </xsl:text>