|
|
1.1 ! root 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> # # </xsl:text> ! 21: <xsl:value-of select="$target"/> ! 22: <xsl:text> compiler rules # </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:text>$(SRCDIR)/</xsl:text> ! 56: <xsl:value-of select="$path"/> ! 57: <xsl:value-of select="@source"/> ! 58: ! 59: ! 60: <xsl:choose> ! 61: <xsl:when test="child::rule"> ! 62: <xsl:value-of select="child::rule"/> ! 63: <xsl:text> </xsl:text> ! 64: </xsl:when> ! 65: <xsl:otherwise> ! 66: <xsl:choose> ! 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']"/> ! 73: </xsl:when> ! 74: <xsl:otherwise> ! 75: <!-- FIXME this requires strict spaces in rules.xml --> ! 76: <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='object']"/> ! 77: </xsl:otherwise> ! 78: </xsl:choose> ! 79: </xsl:otherwise> ! 80: </xsl:choose> ! 81: ! 82: </xsl:if> ! 83: </xsl:for-each> ! 84: ! 85: <!-- Create linker targets for all executables --> ! 86: <xsl:for-each select="//executable"> ! 87: ! 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"/> ! 93: </xsl:call-template> ! 94: </xsl:for-each> ! 95: </xsl:variable> ! 96: ! 97: <xsl:if test="$outer-conditions = 0"> ! 98: <xsl:if test="(ancestor-or-self::*)[@target = $target]"> ! 99: ! 100: <!-- executable name --> ! 101: <xsl:text>$(ODIR)/</xsl:text> ! 102: <xsl:value-of select="@name"/> ! 103: <xsl:text>:</xsl:text> ! 104: ! 105: <!-- add all objects --> ! 106: <xsl:for-each select="object"> ! 107: ! 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"/> ! 113: </xsl:call-template> ! 114: </xsl:for-each> ! 115: </xsl:variable> ! 116: ! 117: <xsl:if test="$conditions=0"> ! 118: ! 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"/> ! 123: </xsl:call-template> ! 124: </xsl:for-each> ! 125: </xsl:variable> ! 126: ! 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> ! 133: ! 134: </xsl:if> ! 135: </xsl:for-each> ! 136: ! 137: <!-- external objects last --> ! 138: <xsl:for-each select="external-object"> ! 139: ! 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"/> ! 145: </xsl:call-template> ! 146: </xsl:for-each> ! 147: </xsl:variable> ! 148: ! 149: <xsl:if test="$conditions=0"> ! 150: <xsl:text> $(ODIR)/</xsl:text> ! 151: <xsl:value-of select="@source"/> ! 152: </xsl:if> ! 153: ! 154: </xsl:for-each> ! 155: ! 156: <!-- print executable rule --> ! 157: <xsl:choose> ! 158: <xsl:when test="child::rule"> ! 159: <xsl:value-of select="child::rule"/> ! 160: <xsl:text> </xsl:text> ! 161: </xsl:when> ! 162: <xsl:otherwise> ! 163: <!-- FIXME this requires strict spaces in rules.xml --> ! 164: <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='executable']"/> ! 165: </xsl:otherwise> ! 166: </xsl:choose> ! 167: ! 168: </xsl:if> ! 169: </xsl:if> ! 170: </xsl:for-each> ! 171: ! 172: <!-- create linker targets for all libs --> ! 173: <xsl:for-each select="//library"> ! 174: <xsl:sort select="@name"/> ! 175: ! 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"/> ! 181: </xsl:call-template> ! 182: </xsl:for-each> ! 183: </xsl:variable> ! 184: ! 185: <xsl:if test="$outer-conditions = 0"> ! 186: ! 187: ! 188: <xsl:if test="(ancestor-or-self::*)[@target = $target]"> ! 189: ! 190: <xsl:if test="not(preceding::library/@name = @name)"> ! 191: ! 192: <!-- output library name --> ! 193: <xsl:text>$(ODIR)/lib</xsl:text> ! 194: <xsl:value-of select="@name"/> ! 195: ! 196: <xsl:choose> ! 197: <xsl:when test="@type='static'"> ! 198: <xsl:text>.a</xsl:text> ! 199: </xsl:when> ! 200: <xsl:when test="@type='dynamic'"> ! 201: <xsl:text>.so</xsl:text> ! 202: </xsl:when> ! 203: </xsl:choose> ! 204: <xsl:text>: </xsl:text> ! 205: ! 206: <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable> ! 207: ! 208: <!-- enumerate all objects for library target --> ! 209: <xsl:for-each select="//library[@name=$name]/object"> ! 210: ! 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"/> ! 216: </xsl:call-template> ! 217: </xsl:for-each> ! 218: </xsl:variable> ! 219: ! 220: <xsl:if test="$conditions=0"> ! 221: ! 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"/> ! 226: </xsl:call-template> ! 227: </xsl:for-each> ! 228: </xsl:variable> ! 229: ! 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> ! 236: ! 237: </xsl:if> ! 238: ! 239: </xsl:for-each> ! 240: ! 241: <!-- external objects last --> ! 242: <xsl:for-each select="external-object"> ! 243: ! 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"/> ! 249: </xsl:call-template> ! 250: </xsl:for-each> ! 251: </xsl:variable> ! 252: ! 253: <xsl:if test="$conditions=0"> ! 254: <xsl:text> $(ODIR)/</xsl:text> ! 255: <xsl:value-of select="@source"/> ! 256: </xsl:if> ! 257: ! 258: </xsl:for-each> ! 259: ! 260: ! 261: <!-- FIXME this requires strict spaces in rules.xml --> ! 262: <xsl:value-of select="document('rules.xml',.)//rule[@target=$target][@entity='library']"/> ! 263: ! 264: </xsl:if> ! 265: </xsl:if> ! 266: </xsl:if> ! 267: </xsl:for-each> ! 268: ! 269: <!-- create libs rule for all libraries --> ! 270: <xsl:value-of select="$target"/> ! 271: <xsl:text>-libraries: </xsl:text> ! 272: ! 273: <!-- don't build unused libraries ! 274: <xsl:for-each select="//library"> ! 275: <xsl:if test="object[(ancestor-or-self::*)[@target = $target]]"> ! 276: ! 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"/> ! 282: </xsl:call-template> ! 283: </xsl:for-each> ! 284: </xsl:variable> ! 285: <xsl:if test="$conditions=0"> ! 286: <xsl:text> $(ODIR)/</xsl:text> ! 287: <xsl:text>lib</xsl:text> ! 288: <xsl:value-of select="@name"/> ! 289: <xsl:choose> ! 290: <xsl:when test="@type='static'"> ! 291: <xsl:text>.a</xsl:text> ! 292: </xsl:when> ! 293: <xsl:when test="@type='dynamic'"> ! 294: <xsl:text>.so</xsl:text> ! 295: </xsl:when> ! 296: </xsl:choose> ! 297: </xsl:if> ! 298: </xsl:if> ! 299: </xsl:for-each> ! 300: --> ! 301: <xsl:text> </xsl:text> ! 302: ! 303: <!-- create exe rule for all executables --> ! 304: <xsl:value-of select="$target"/> ! 305: <xsl:text>-executables: </xsl:text> ! 306: ! 307: <xsl:for-each select="//executable"> ! 308: <xsl:if test="(ancestor-or-self::*)[@target = $target]"> ! 309: ! 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"/> ! 315: </xsl:call-template> ! 316: </xsl:for-each> ! 317: </xsl:variable> ! 318: <xsl:if test="$conditions=0"> ! 319: <xsl:text> $(ODIR)/</xsl:text> ! 320: <xsl:value-of select="@name"/> ! 321: </xsl:if> ! 322: </xsl:if> ! 323: </xsl:for-each> ! 324: <xsl:text> </xsl:text> ! 325: ! 326: </xsl:template> ! 327: ! 328: </xsl:stylesheet>
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.