Home | History | Annotate | Line # | Download | only in mca
devlist2h.awk revision 1.1.30.3
      1       1.1  jdolecek #! /usr/bin/awk -f
      2  1.1.30.3     skrll #	$NetBSD: devlist2h.awk,v 1.1.30.3 2004/09/21 13:30:17 skrll Exp $
      3       1.1  jdolecek #
      4       1.1  jdolecek # Copyright (c) 1995, 1996 Christopher G. Demetriou
      5       1.1  jdolecek # All rights reserved.
      6       1.1  jdolecek #
      7       1.1  jdolecek # Redistribution and use in source and binary forms, with or without
      8       1.1  jdolecek # modification, are permitted provided that the following conditions
      9       1.1  jdolecek # are met:
     10       1.1  jdolecek # 1. Redistributions of source code must retain the above copyright
     11       1.1  jdolecek #    notice, this list of conditions and the following disclaimer.
     12       1.1  jdolecek # 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  jdolecek #    notice, this list of conditions and the following disclaimer in the
     14       1.1  jdolecek #    documentation and/or other materials provided with the distribution.
     15       1.1  jdolecek # 3. All advertising materials mentioning features or use of this software
     16       1.1  jdolecek #    must display the following acknowledgement:
     17       1.1  jdolecek #      This product includes software developed by Christopher G. Demetriou.
     18       1.1  jdolecek # 4. The name of the author may not be used to endorse or promote products
     19       1.1  jdolecek #    derived from this software without specific prior written permission
     20       1.1  jdolecek #
     21       1.1  jdolecek # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1  jdolecek # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1  jdolecek # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.1  jdolecek # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1  jdolecek # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1  jdolecek # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1  jdolecek # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1  jdolecek # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1  jdolecek # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1  jdolecek # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1  jdolecek #
     32       1.1  jdolecek 
     33       1.1  jdolecek # Adapted for MCA needs by Jaromir Dolecek.
     34       1.1  jdolecek 
     35       1.1  jdolecek BEGIN {
     36  1.1.30.1     skrll 	nproducts = nvendors = blanklines = 0
     37       1.1  jdolecek 	dfile="mcadevs_data.h"
     38       1.1  jdolecek 	hfile="mcadevs.h"
     39       1.1  jdolecek 	FS=" "
     40       1.1  jdolecek 	alias=""
     41       1.1  jdolecek 	id=""
     42       1.1  jdolecek }
     43       1.1  jdolecek NR == 1 {
     44       1.1  jdolecek 	VERSION = $0
     45       1.1  jdolecek 	gsub("\\$", "", VERSION)
     46       1.1  jdolecek 
     47  1.1.30.1     skrll 	printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
     48       1.1  jdolecek 	printf("/*\n") > dfile
     49       1.1  jdolecek 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
     50       1.1  jdolecek 	    > dfile
     51       1.1  jdolecek 	printf(" *\n") > dfile
     52       1.1  jdolecek 	printf(" * generated from:\n") > dfile
     53       1.1  jdolecek 	printf(" *\t%s\n", VERSION) > dfile
     54       1.1  jdolecek 	printf(" */\n") > dfile
     55       1.1  jdolecek 
     56  1.1.30.1     skrll 	printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
     57       1.1  jdolecek 	printf("/*\n") > hfile
     58       1.1  jdolecek 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
     59       1.1  jdolecek 	    > hfile
     60       1.1  jdolecek 	printf(" *\n") > hfile
     61       1.1  jdolecek 	printf(" * generated from:\n") > hfile
     62       1.1  jdolecek 	printf(" *\t%s\n", VERSION) > hfile
     63       1.1  jdolecek 	printf(" */\n") > hfile
     64       1.1  jdolecek 
     65       1.1  jdolecek 	next
     66       1.1  jdolecek }
     67       1.1  jdolecek 
     68  1.1.30.1     skrll NF > 0 && $1 == "product" {
     69       1.1  jdolecek 	nproducts++
     70       1.1  jdolecek 
     71       1.1  jdolecek 	alias = $3
     72       1.1  jdolecek 	id = $2
     73       1.1  jdolecek 
     74       1.1  jdolecek 	products[nproducts, 1] = $2;		# product id
     75       1.1  jdolecek 
     76       1.1  jdolecek 	# get name - it's enclosed in parenthesis
     77       1.1  jdolecek 	sub("[^\"]*\"", "")
     78       1.1  jdolecek 	sub("\".*", "")
     79       1.1  jdolecek 	products[nproducts, 2] = $0;		# name
     80       1.1  jdolecek 
     81       1.1  jdolecek 	# if third parameter is an alias, print appropriate entry to hfile,
     82       1.1  jdolecek 	# otherwise just store the entry for later processing
     83       1.1  jdolecek 	if (substr(alias, 1, 1) != "\"") {
     84       1.1  jdolecek 		printf("#define\tMCA_PRODUCT_%s\t%s\t/* %s */\n", alias, id,\
     85       1.1  jdolecek 			$0) > hfile
     86       1.1  jdolecek 	}
     87       1.1  jdolecek 
     88       1.1  jdolecek }
     89       1.1  jdolecek {
     90       1.1  jdolecek 	if ($0 == "")
     91       1.1  jdolecek 		blanklines++
     92       1.1  jdolecek 	if (blanklines < 2) {
     93       1.1  jdolecek 		print $0 > hfile
     94       1.1  jdolecek 		print $0 > dfile
     95       1.1  jdolecek 	}
     96       1.1  jdolecek 	else if (blanklines == 2) {
     97       1.1  jdolecek 		printf("\n/*\n * List of known MCA devices\n */\n\n") > dfile
     98       1.1  jdolecek 		printf("\n/*\n * Supported MCA devices\n */\n\n") > hfile
     99       1.1  jdolecek 	}
    100       1.1  jdolecek 
    101       1.1  jdolecek 	next
    102       1.1  jdolecek }
    103       1.1  jdolecek END {
    104       1.1  jdolecek 	# print out the match tables
    105       1.1  jdolecek 
    106       1.1  jdolecek 	printf("const struct mca_knowndev mca_knowndevs[] = {\n") > dfile
    107       1.1  jdolecek 	for (i = 1; i <= nproducts; i++) {
    108       1.1  jdolecek 		printf("    { %s,\t\"%s\" },\n", products[i, 1],
    109       1.1  jdolecek 			products[i, 2]) > dfile
    110       1.1  jdolecek 	}
    111       1.1  jdolecek 	printf("    { 0, NULL, }\n") > dfile
    112       1.1  jdolecek 	printf("};\n") > dfile
    113  1.1.30.1     skrll 	close(dfile)
    114  1.1.30.1     skrll 	close(hfile)
    115       1.1  jdolecek }
    116