GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / pci / devlist2h.awk
blob1f0b9b4398ce06e106494d1a4102a9ecf02fdc0c
1 #! /usr/bin/awk -f
2 # $NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp $
4 # Copyright (c) 1995, 1996 Christopher G. Demetriou
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed by Christopher G. Demetriou.
18 # 4. The name of the author may not be used to endorse or promote products
19 # derived from this software without specific prior written permission
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 BEGIN {
33 nproducts = nvendors = 0
34 dfile="pcidevs_data.h"
35 hfile="pcidevs.h"
37 NR == 1 {
38 VERSION = $0
39 gsub("\\$", "", VERSION)
41 printf("/*\n") > dfile
42 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
43 > dfile
44 printf(" *\n") > dfile
45 printf(" * generated from:\n") > dfile
46 printf(" *\t%s\n", VERSION) > dfile
47 printf(" */\n") > dfile
49 printf("/*\n") > hfile
50 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
51 > hfile
52 printf(" *\n") > hfile
53 printf(" * generated from:\n") > hfile
54 printf(" *\t%s\n", VERSION) > hfile
55 printf(" */\n") > hfile
57 next
59 $1 == "vendor" {
60 nvendors++
62 vendorindex[$2] = nvendors; # record index for this name, for later.
63 vendors[nvendors, 1] = $2; # name
64 vendors[nvendors, 2] = $3; # id
65 printf("#define\tPCI_VENDOR_%s\t%s\t", vendors[nvendors, 1],
66 vendors[nvendors, 2]) > hfile
68 i = 3; f = 4;
70 # comments
71 ocomment = oparen = 0
72 if (f <= NF) {
73 printf("\t/* ") > hfile
74 ocomment = 1;
76 while (f <= NF) {
77 if ($f == "#") {
78 printf("(") > hfile
79 oparen = 1
80 f++
81 continue
83 if (oparen) {
84 printf("%s", $f) > hfile
85 if (f < NF)
86 printf(" ") > hfile
87 f++
88 continue
90 vendors[nvendors, i] = $f
91 printf("%s", vendors[nvendors, i]) > hfile
92 if (f < NF)
93 printf(" ") > hfile
94 i++; f++;
96 if (oparen)
97 printf(")") > hfile
98 if (ocomment)
99 printf(" */") > hfile
100 printf("\n") > hfile
102 next
104 $1 == "product" {
105 nproducts++
107 products[nproducts, 1] = $2; # vendor name
108 products[nproducts, 2] = $3; # product id
109 products[nproducts, 3] = $4; # id
110 printf("#define\tPCI_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
111 products[nproducts, 2], products[nproducts, 3]) > hfile
113 i=4; f = 5;
115 # comments
116 ocomment = oparen = 0
117 if (f <= NF) {
118 printf("\t/* ") > hfile
119 ocomment = 1;
121 while (f <= NF) {
122 if ($f == "#") {
123 printf("(") > hfile
124 oparen = 1
126 continue
128 if (oparen) {
129 printf("%s", $f) > hfile
130 if (f < NF)
131 printf(" ") > hfile
133 continue
135 products[nproducts, i] = $f
136 printf("%s", products[nproducts, i]) > hfile
137 if (f < NF)
138 printf(" ") > hfile
139 i++; f++;
141 if (oparen)
142 printf(")") > hfile
143 if (ocomment)
144 printf(" */") > hfile
145 printf("\n") > hfile
147 next
150 if ($0 == "")
151 blanklines++
152 print $0 > hfile
153 if (blanklines < 2)
154 print $0 > dfile
156 END {
157 # print out the match tables
159 printf("\n") > dfile
162 printf("static const struct pci_knowndev pci_knowndevs[] = {\n") > dfile
163 for (i = 1; i <= nproducts; i++) {
164 printf("\t{\n") > dfile
165 printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s,\n",
166 products[i, 1], products[i, 1], products[i, 2]) \
167 > dfile
168 printf("\t ") > dfile
169 printf("0") > dfile
170 printf(",\n") > dfile
172 vendi = vendorindex[products[i, 1]];
173 printf("\t \"") > dfile
174 j = 3;
175 needspace = 0;
176 while (vendors[vendi, j] != "") {
177 if (needspace)
178 printf(" ") > dfile
179 printf("%s", vendors[vendi, j]) > dfile
180 needspace = 1
183 printf("\",\n") > dfile
185 printf("\t \"") > dfile
186 j = 4;
187 needspace = 0;
188 while (products[i, j] != "") {
189 if (needspace)
190 printf(" ") > dfile
191 printf("%s", products[i, j]) > dfile
192 needspace = 1
195 printf("\",\n") > dfile
196 printf("\t},\n") > dfile
198 for (i = 1; i <= nvendors; i++) {
199 printf("\t{\n") > dfile
200 printf("\t PCI_VENDOR_%s, 0,\n", vendors[i, 1]) \
201 > dfile
202 printf("\t PCI_KNOWNDEV_NOPROD,\n") \
203 > dfile
204 printf("\t \"") > dfile
205 j = 3;
206 needspace = 0;
207 while (vendors[i, j] != "") {
208 if (needspace)
209 printf(" ") > dfile
210 printf("%s", vendors[i, j]) > dfile
211 needspace = 1
214 printf("\",\n") > dfile
215 printf("\t NULL,\n") > dfile
216 printf("\t},\n") > dfile
218 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
219 printf("};\n") > dfile