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:text>$(SRCDIR)/
</xsl:text>
56 <xsl:value-of select=
"$path"/>
57 <xsl:value-of select=
"@source"/>
61 <xsl:when test=
"child::rule">
62 <xsl:value-of select=
"child::rule"/>
63 <xsl:text> </xsl:text>
67 <xsl:when test=
"@flags!=''">
68 <xsl:value-of select=
"document('rules.xml',.)//rule[@target=$target][@entity='object'][@extracflags='1']"/>
69 <xsl:text> </xsl:text>
70 <xsl:value-of select=
"@flags"/>
71 <xsl:text> </xsl:text>
72 <xsl:value-of select=
"document('rules.xml',.)//rule[@target=$target][@entity='object'][@extracflags='2']"/>
75 <!-- FIXME this requires strict spaces in rules.xml -->
76 <xsl:value-of select=
"document('rules.xml',.)//rule[@target=$target][@entity='object']"/>
85 <!-- Create linker targets for all executables -->
86 <xsl:for-each select=
"//executable">
88 <xsl:variable name=
"outer-conditions">
89 <xsl:text>0</xsl:text>
90 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
91 <xsl:call-template name=
"resolve-condition">
92 <xsl:with-param select=
"@condition" name=
"expression"/>
97 <xsl:if test=
"$outer-conditions = 0">
98 <xsl:if test=
"(ancestor-or-self::*)[@target = $target]">
100 <!-- executable name -->
101 <xsl:text>$(ODIR)/
</xsl:text>
102 <xsl:value-of select=
"@name"/>
103 <xsl:text>:
</xsl:text>
105 <!-- add all objects -->
106 <xsl:for-each select=
"object">
108 <xsl:variable name=
"conditions">
109 <xsl:text>0</xsl:text>
110 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
111 <xsl:call-template name=
"resolve-condition">
112 <xsl:with-param select=
"@condition" name=
"expression"/>
117 <xsl:if test=
"$conditions=0">
119 <xsl:variable name=
"path">
120 <xsl:for-each select=
"ancestor::build">
121 <xsl:call-template name=
"get-dirname">
122 <xsl:with-param select=
"@base" name=
"path"/>
127 <xsl:text> $(ODIR)/
</xsl:text>
128 <xsl:value-of select=
"$target"/>
129 <xsl:text>/
</xsl:text>
130 <xsl:value-of select=
"$path"/>
131 <xsl:value-of select=
"substring-before(@source,'.')"/>
132 <xsl:text>.o
</xsl:text>
137 <!-- external objects last -->
138 <xsl:for-each select=
"external-object">
140 <xsl:variable name=
"conditions">
141 <xsl:text>0</xsl:text>
142 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
143 <xsl:call-template name=
"resolve-condition">
144 <xsl:with-param select=
"@condition" name=
"expression"/>
149 <xsl:if test=
"$conditions=0">
150 <xsl:text> $(ODIR)/
</xsl:text>
151 <xsl:value-of select=
"@source"/>
156 <!-- print executable rule -->
158 <xsl:when test=
"child::rule">
159 <xsl:value-of select=
"child::rule"/>
160 <xsl:text> </xsl:text>
163 <!-- FIXME this requires strict spaces in rules.xml -->
164 <xsl:value-of select=
"document('rules.xml',.)//rule[@target=$target][@entity='executable']"/>
172 <!-- create linker targets for all libs -->
173 <xsl:for-each select=
"//library">
174 <xsl:sort select=
"@name"/>
176 <xsl:variable name=
"outer-conditions">
177 <xsl:text>0</xsl:text>
178 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
179 <xsl:call-template name=
"resolve-condition">
180 <xsl:with-param select=
"@condition" name=
"expression"/>
185 <xsl:if test=
"$outer-conditions = 0">
188 <xsl:if test=
"(ancestor-or-self::*)[@target = $target]">
190 <xsl:if test=
"not(preceding::library/@name = @name)">
192 <!-- output library name -->
193 <xsl:text>$(ODIR)/lib
</xsl:text>
194 <xsl:value-of select=
"@name"/>
197 <xsl:when test=
"@type='static'">
198 <xsl:text>.a
</xsl:text>
200 <xsl:when test=
"@type='dynamic'">
201 <xsl:text>.so
</xsl:text>
204 <xsl:text>:
</xsl:text>
206 <xsl:variable name=
"name"><xsl:value-of select=
"@name"/></xsl:variable>
208 <!-- enumerate all objects for library target -->
209 <xsl:for-each select=
"//library[@name=$name]/object">
211 <xsl:variable name=
"conditions">
212 <xsl:text>0</xsl:text>
213 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
214 <xsl:call-template name=
"resolve-condition">
215 <xsl:with-param select=
"@condition" name=
"expression"/>
220 <xsl:if test=
"$conditions=0">
222 <xsl:variable name=
"path">
223 <xsl:for-each select=
"ancestor::build">
224 <xsl:call-template name=
"get-dirname">
225 <xsl:with-param select=
"@base" name=
"path"/>
230 <xsl:text>$(ODIR)/
</xsl:text>
231 <xsl:value-of select=
"$target"/>
232 <xsl:text>/
</xsl:text>
233 <xsl:value-of select=
"$path"/>
234 <xsl:value-of select=
"substring-before(@source,'.')"/>
235 <xsl:text>.o
</xsl:text>
241 <!-- external objects last -->
242 <xsl:for-each select=
"external-object">
244 <xsl:variable name=
"conditions">
245 <xsl:text>0</xsl:text>
246 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
247 <xsl:call-template name=
"resolve-condition">
248 <xsl:with-param select=
"@condition" name=
"expression"/>
253 <xsl:if test=
"$conditions=0">
254 <xsl:text> $(ODIR)/
</xsl:text>
255 <xsl:value-of select=
"@source"/>
261 <!-- FIXME this requires strict spaces in rules.xml -->
262 <xsl:value-of select=
"document('rules.xml',.)//rule[@target=$target][@entity='library']"/>
269 <!-- create libs rule for all libraries -->
270 <xsl:value-of select=
"$target"/>
271 <xsl:text>-libraries:
</xsl:text>
273 <!-- don't build unused libraries
274 <xsl:for-each select="//library">
275 <xsl:if test="object[(ancestor-or-self::*)[@target = $target]]">
277 <xsl:variable name="conditions">
278 <xsl:text>0</xsl:text>
279 <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
280 <xsl:call-template name="resolve-condition">
281 <xsl:with-param select="@condition" name="expression"/>
285 <xsl:if test="$conditions=0">
286 <xsl:text> $(ODIR)/</xsl:text>
287 <xsl:text>lib</xsl:text>
288 <xsl:value-of select="@name"/>
290 <xsl:when test="@type='static'">
291 <xsl:text>.a</xsl:text>
293 <xsl:when test="@type='dynamic'">
294 <xsl:text>.so</xsl:text>
301 <xsl:text> </xsl:text>
303 <!-- create exe rule for all executables -->
304 <xsl:value-of select=
"$target"/>
305 <xsl:text>-executables:
</xsl:text>
307 <xsl:for-each select=
"//executable">
308 <xsl:if test=
"(ancestor-or-self::*)[@target = $target]">
310 <xsl:variable name=
"conditions">
311 <xsl:text>0</xsl:text>
312 <xsl:for-each select=
"(ancestor-or-self::*)[@condition!='']">
313 <xsl:call-template name=
"resolve-condition">
314 <xsl:with-param select=
"@condition" name=
"expression"/>
318 <xsl:if test=
"$conditions=0">
319 <xsl:text> $(ODIR)/
</xsl:text>
320 <xsl:value-of select=
"@name"/>
324 <xsl:text> </xsl:text>