1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
<?xml version="1.0" encoding="ISO-8859-15" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/" mode="dictionaries">
<xsl:text> # # dictionary rules # </xsl:text>
<!-- Set all dictionary source lists empty -->
<xsl:for-each select="//dictionary">
<xsl:sort select="@name"/>
<xsl:variable name="conditions">
<xsl:text>0</xsl:text>
<xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
<xsl:call-template name="resolve-condition">
<xsl:with-param select="@condition" name="expression"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$conditions = 0">
<xsl:if test="not(preceding::dictionary/@name = @name)">
<xsl:value-of select="@name"/>
<xsl:text>-DICTIONARY := </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
<!-- Add all forth source files to their dictionaries -->
<xsl:for-each select="//dictionary/object">
<xsl:variable name="path">
<xsl:for-each select="ancestor::build">
<xsl:call-template name="get-dirname">
<xsl:with-param select="@base" name="path"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="conditions">
<xsl:text>0</xsl:text>
<xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
<xsl:call-template name="resolve-condition">
<xsl:with-param select="@condition" name="expression"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="dictname">
<xsl:value-of select="parent::*/@name"/>
</xsl:variable>
<xsl:if test="$conditions=0">
<xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY:=$(</xsl:text>
<xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY) </xsl:text>
<xsl:text>$(SRCDIR)/</xsl:text>
<xsl:value-of select="$path"/>
<xsl:value-of select="@source"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- Create targets for all dictionaries -->
<xsl:for-each select="//dictionary">
<xsl:sort select="@name"/>
<xsl:variable name="outer-conditions">
<xsl:text>0</xsl:text>
<xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
<xsl:call-template name="resolve-condition">
<xsl:with-param select="@condition" name="expression"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$outer-conditions = 0">
<xsl:if test="not(preceding::dictionary/@name = @name)">
<xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
<xsl:variable name="init">
<xsl:value-of select="(//dictionary[@name=$name]/attribute::init)[last()]"/>
</xsl:variable>
<!-- dictionary name and dependencies -->
<xsl:text>$(ODIR)/</xsl:text>
<xsl:value-of select="@name"/><xsl:text>.dict: $(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>-DICTIONARY) $(ODIR)/forthstrap</xsl:text>
<xsl:if test="$init!=''">
<xsl:text> $(ODIR)/</xsl:text><xsl:value-of select="$init"/><xsl:text>.dict</xsl:text>
</xsl:if>
<xsl:text> </xsl:text>
<!-- rule -->
<xsl:text>	$(call quiet-command,$(ODIR)/forthstrap</xsl:text>
<xsl:for-each select="//dictionary[@name = @name]">
<xsl:variable name="conditions">
<xsl:text>0</xsl:text>
<xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
<xsl:call-template name="resolve-condition">
<xsl:with-param select="@condition" name="expression"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="path">
<xsl:for-each select="ancestor::build">
<xsl:call-template name="get-dirname">
<xsl:with-param select="@base" name="path"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$conditions = 0">
<xsl:text> -I</xsl:text>
<xsl:text>$(SRCDIR)/</xsl:text>
<xsl:value-of select="$path"/>
</xsl:if>
</xsl:for-each>
<!-- needed to include config and build date -->
<xsl:text> -I$(ODIR)/forth</xsl:text>
<xsl:text> -D $@</xsl:text>
<xsl:if test="$init!=''">
<xsl:text> -d $(ODIR)/</xsl:text><xsl:value-of select="$init"/><xsl:text>.dict</xsl:text>
</xsl:if>
<xsl:text> $(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>-DICTIONARY)," GEN $(TARGET_DIR)$@") </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
<!-- Create dictionaries target containing all dictionaries -->
<xsl:text>dictionaries: </xsl:text>
<xsl:for-each select="//dictionary">
<xsl:sort select="@name"/>
<xsl:variable name="conditions">
<xsl:text>0</xsl:text>
<xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
<xsl:call-template name="resolve-condition">
<xsl:with-param select="@condition" name="expression"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$conditions = 0">
<xsl:if test="not(preceding::dictionary/@name = @name)">
<xsl:text>$(ODIR)/</xsl:text>
<xsl:value-of select="@name"/><xsl:text>.dict </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
|