Reimport devlist2h.awk from FreeBSD, this version actually works. It
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Sun, 7 Aug 2005 22:43:17 +0000 (22:43 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Sun, 7 Aug 2005 22:43:17 +0000 (22:43 +0000)
also allows proper dependency handling in Makefile.usbdevs by separating
the output via options. Regen with the new script.

sys/bus/usb/Makefile.usbdevs
sys/bus/usb/devlist2h.awk
sys/bus/usb/usbdevs.h
sys/bus/usb/usbdevs_data.h

index 1e3c2ad..db7e0d6 100644 (file)
@@ -1,7 +1,7 @@
 # The files usbdevs.h and usbdevs_data.h are generated from usbdevs
 #
 # $FreeBSD: src/sys/dev/usb/Makefile.usbdevs,v 1.2 2000/03/15 22:13:50 n_hibma Exp $
-# $DragonFly: src/sys/bus/usb/Attic/Makefile.usbdevs,v 1.2 2003/12/30 01:01:44 dillon Exp $
+# $DragonFly: src/sys/bus/usb/Attic/Makefile.usbdevs,v 1.3 2005/08/07 22:43:17 joerg Exp $
 
 AWK=   awk
 UNAME= uname
@@ -15,7 +15,10 @@ all:
        @echo "Only the 'regen' target may be used to regenerate the"
        @echo "usbdevs.h and usbdevs_data.h header files"
 
-regen: usbdevs devlist2h.awk
-       /bin/rm -f ${.CURDIR}/usbdevs.h ${.CURDIR}/usbdevs_data.h
-       cd ${.CURDIR} && ${AWK} -v type=USB -v os=`${UNAME} -s` -f devlist2h.awk usbdevs
+regen: usbdevs.h usbdevs_data.h
 
+usbdevs.h: usbdevs devlist2h.awk
+       cd ${.CURDIR} && ${AWK} -v type=USB -v os=`${UNAME} -s` -f devlist2h.awk usbdevs -h
+
+usbdevs_data.h: usbdevs devlist2h.awk
+       cd ${.CURDIR} && ${AWK} -v type=USB -v os=`${UNAME} -s` -f devlist2h.awk usbdevs -d
index 50b880f..a707664 100644 (file)
@@ -1,8 +1,8 @@
 #! /usr/bin/awk -f
-#  
-# $NetBSD: usb/devlist2h.awk,v 1.9 2001/01/18 20:28:22 jdolecek Exp $
-# $FreeBSD: src/sys/dev/usb/devlist2h.awk,v 1.2 2002/04/01 19:22:04 joe Exp $
-# $DragonFly: src/sys/bus/usb/Attic/devlist2h.awk,v 1.4 2003/12/30 01:01:44 dillon Exp $
+#-
+#      $NetBSD: usb/devlist2h.awk,v 1.9 2001/01/18 20:28:22 jdolecek Exp $
+#  $FreeBSD: src/sys/tools/usbdevs2h.awk,v 1.7 2005/01/07 02:29:25 imp Exp $
+#  $DragonFly: src/sys/bus/usb/Attic/devlist2h.awk,v 1.5 2005/08/07 22:43:17 joerg Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
 # All rights reserved.
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-BEGIN {
-       nproducts = nvendors = 0
-       dfile="usbdevs_data.h"
-       hfile="usbdevs.h"
+
+function usage()
+{
+       print "usage: usbdevs2h.awk <srcfile> [-d|-h]";
+       exit 1;
 }
-NR == 1 {
-       printf("/*\n") > dfile
-       printf(" *\t\$DragonFly\$\n *\n") > dfile
-       printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
-           > dfile
-       printf(" *\n") > dfile
-       printf(" */\n") > dfile
 
-       printf("/*\n") > hfile
-       printf(" *\t\$DragonFly\$\n *\n") > hfile
+function header(file)
+{
+       if (os == "NetBSD")
+               printf("/*\t\$NetBSD\$\t*/\n\n") > file
+       else if (os == "FreeBSD")
+               printf("/* \$FreeBSD\$ */\n\n") > file
+       else if (os == "OpenBSD")
+               printf("/*\t\$OpenBSD\$\t*/\n\n") > file
+       else if (os == "DragonFly")
+               printf("/*\t\$DragonFly\$\t*/\n\n") > file
+       else
+               printf("/* ??? */\n\n") > file
+       printf("/*\n") > file
        printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
-           > hfile
-       printf(" *\n") > hfile
-       printf(" */\n") > hfile
+           > file
+       printf(" *\n") > file
+       printf(" * generated from:\n") > file
+       printf(" *\t%s\n", VERSION) > file
+       printf(" */\n") > file
 }
-$1 == "vendor" {
+
+function vendor(hfile)
+{
        nvendors++
 
        vendorindex[$2] = nvendors;             # record index for this name, for later.
        vendors[nvendors, 1] = $2;              # name
        vendors[nvendors, 2] = $3;              # id
-       printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
-           vendors[nvendors, 2]) > hfile
-
+       if (hfile)
+               printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
+                   vendors[nvendors, 2]) > hfile
        i = 3; f = 4;
 
        # comments
        ocomment = oparen = 0
        if (f <= NF) {
-               printf("\t/* ") > hfile
+               if (hfile)
+                       printf("\t/* ") > hfile
                ocomment = 1;
        }
        while (f <= NF) {
                if ($f == "#") {
-                       printf("(") > hfile
+                       if (hfile)
+                               printf("(") > hfile
                        oparen = 1
                        f++
                        continue
                }
                if (oparen) {
-                       printf("%s", $f) > hfile
-                       if (f < NF)
+                       if (hfile)
+                               printf("%s", $f) > hfile
+                       if (f < NF && hfile)
                                printf(" ") > hfile
                        f++
                        continue
                }
                vendors[nvendors, i] = $f
-               printf("%s", vendors[nvendors, i]) > hfile
-               if (f < NF)
+               if (hfile)
+                       printf("%s", vendors[nvendors, i]) > hfile
+               if (f < NF && hfile)
                        printf(" ") > hfile
                i++; f++;
        }
-       if (oparen)
+       if (oparen && hfile)
                printf(")") > hfile
-       if (ocomment)
+       if (ocomment && hfile)
                printf(" */") > hfile
-       printf("\n") > hfile
-
-       next
+       if (hfile)
+               printf("\n") > hfile
 }
-$1 == "product" {
+
+function product(hfile)
+{
        nproducts++
 
        products[nproducts, 1] = $2;            # vendor name
        products[nproducts, 2] = $3;            # product id
        products[nproducts, 3] = $4;            # id
-       printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
-           products[nproducts, 2], products[nproducts, 3]) > hfile
+       if (hfile)
+               printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", \
+                 products[nproducts, 1], products[nproducts, 2], \
+                 products[nproducts, 3]) > hfile
 
        i=4; f = 5;
 
        # comments
        ocomment = oparen = 0
        if (f <= NF) {
-               printf("\t/* ") > hfile
+               if (hfile)
+                       printf("\t/* ") > hfile
                ocomment = 1;
        }
        while (f <= NF) {
                if ($f == "#") {
-                       printf("(") > hfile
+                       if (hfile)
+                               printf("(") > hfile
                        oparen = 1
                        f++
                        continue
                }
                if (oparen) {
-                       printf("%s", $f) > hfile
-                       if (f < NF)
+                       if (hfile)
+                               printf("%s", $f) > hfile
+                       if (f < NF && hfile)
                                printf(" ") > hfile
                        f++
                        continue
                }
                products[nproducts, i] = $f
-               printf("%s", products[nproducts, i]) > hfile
-               if (f < NF)
+               if (hfile)
+                       printf("%s", products[nproducts, i]) > hfile
+               if (f < NF && hfile)
                        printf(" ") > hfile
                i++; f++;
        }
-       if (oparen)
+       if (oparen && hfile)
                printf(")") > hfile
-       if (ocomment)
+       if (ocomment && hfile)
                printf(" */") > hfile
-       printf("\n") > hfile
-
-       next
-}
-{
-       if ($0 == "")
-               blanklines++
-       print $0 > hfile
-       if (blanklines < 2)
-               print $0 > dfile
+       if (hfile)
+               printf("\n") > hfile
 }
-END {
-       # print out the match tables
 
+function dump_dfile(dfile)
+{
        printf("\n") > dfile
-
        printf("const struct usb_knowndev usb_knowndevs[] = {\n") > dfile
        for (i = 1; i <= nproducts; i++) {
                printf("\t{\n") > dfile
                printf("\t    USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
-                   products[i, 1], products[i, 1], products[i, 2]) \
-                   > dfile
+                   products[i, 1], products[i, 1], products[i, 2]) > dfile
                printf("\t    ") > dfile
                printf("0") > dfile
                printf(",\n") > dfile
@@ -192,10 +202,8 @@ END {
        }
        for (i = 1; i <= nvendors; i++) {
                printf("\t{\n") > dfile
-               printf("\t    USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
-                   > dfile
-               printf("\t    USB_KNOWNDEV_NOPROD,\n") \
-                   > dfile
+               printf("\t    USB_VENDOR_%s, 0,\n", vendors[i, 1]) > dfile
+               printf("\t    USB_KNOWNDEV_NOPROD,\n") > dfile
                printf("\t    \"") > dfile
                j = 3;
                needspace = 0;
@@ -213,3 +221,54 @@ END {
        printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
        printf("};\n") > dfile
 }
+
+BEGIN {
+
+nproducts = nvendors = 0
+# Process the command line
+for (i = 1; i < ARGC; i++) {
+       arg = ARGV[i];
+       if (arg !~ /^-[dh]+$/ && arg !~ /devs$/)
+               usage();
+       if (arg ~ /^-.*d/)
+               dfile="usbdevs_data.h"
+       if (arg ~ /^-.*h/)
+               hfile="usbdevs.h"
+       if (arg ~ /devs$/)
+               srcfile = arg;
+}
+ARGC = 1;
+line=0;
+
+while ((getline < srcfile) > 0) {
+       line++;
+       if (line == 1) {
+               VERSION = $0
+               gsub("\\$", "", VERSION)
+               if (dfile)
+                       header(dfile)
+               if (hfile)
+                       header(hfile)
+               continue;
+       }
+       if ($1 == "vendor") {
+               vendor(hfile)
+               continue
+       }
+       if ($1 == "product") {
+               product(hfile)
+               continue
+       }
+       if ($0 == "")
+               blanklines++
+       if (hfile)
+               print $0 > hfile
+       if (blanklines < 2 && dfile)
+           print $0 > dfile
+}
+
+# print out the match tables
+
+if (dfile)
+       dump_dfile(dfile)
+}
index 44d778e..b572b66 100644 (file)
@@ -1,9 +1,14 @@
+/*     $DragonFly: src/sys/bus/usb/Attic/usbdevs.h,v 1.12 2005/08/07 22:43:17 joerg Exp $      */
+
 /*
- *     $DragonFly: src/sys/bus/usb/Attic/usbdevs.h,v 1.11 2004/12/18 06:22:47 dillon Exp $
- *
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
+ * generated from:
+ *     DragonFly: src/sys/bus/usb/usbdevs,v 1.16 2005/08/07 22:37:54 joerg Exp 
  */
+/* $FreeBSD: src/sys/dev/usb/usbdevs,v 1.203 2004/09/20 04:56:13 sanpei Exp $ */
+/* $NetBSD: usbdevs,v 1.387 2004/10/27 07:02:47 augustss Exp $ */
+
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/dev/usb/usbdevs,v 1.203 2004/09/20 04:56:13 sanpei Exp $
- * $DragonFly: src/sys/bus/usb/Attic/usbdevs.h,v 1.11 2004/12/18 06:22:47 dillon Exp $
- * $NetBSD: usbdevs,v 1.387 2004/10/27 07:02:47 augustss Exp $
  */
 
 
 #define        USB_PRODUCT_JVC_GR_DX95 0x000a          /* GR-DX95 */
 
 /* JVC products */
+#define        USB_PRODUCT_JVC_MP_PRX1 0x3008          /* MP-PRX1 Ethernet */
 #define        USB_PRODUCT_JVC_MP_XP7250_WL    0x3009          /* MP-XP7250 Builtin WLAN */
 
 /* JRC products */
index 4536ea9..3b33c6c 100644 (file)
@@ -1,9 +1,14 @@
+/*     $DragonFly: src/sys/bus/usb/Attic/usbdevs_data.h,v 1.12 2005/08/07 22:43:17 joerg Exp $ */
+
 /*
- *     $DragonFly: src/sys/bus/usb/Attic/usbdevs_data.h,v 1.11 2004/12/18 06:22:47 dillon Exp $
- *
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
+ * generated from:
+ *     DragonFly: src/sys/bus/usb/usbdevs,v 1.16 2005/08/07 22:37:54 joerg Exp 
  */
+/* $FreeBSD: src/sys/dev/usb/usbdevs,v 1.203 2004/09/20 04:56:13 sanpei Exp $ */
+/* $NetBSD: usbdevs,v 1.387 2004/10/27 07:02:47 augustss Exp $ */
+
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/dev/usb/usbdevs,v 1.203 2004/09/20 04:56:13 sanpei Exp $
- * $DragonFly: src/sys/bus/usb/Attic/usbdevs_data.h,v 1.11 2004/12/18 06:22:47 dillon Exp $
- * $NetBSD: usbdevs,v 1.387 2004/10/27 07:02:47 augustss Exp $
  */
 
-
 const struct usb_knowndev usb_knowndevs[] = {
        {
            USB_VENDOR_3COM, USB_PRODUCT_3COM_HOMECONN,
@@ -2507,6 +2507,12 @@ const struct usb_knowndev usb_knowndevs[] = {
            "JVC",
            "GR-DX95",
        },
+       {
+           USB_VENDOR_JVC, USB_PRODUCT_JVC_MP_PRX1,
+           0,
+           "JVC",
+           "MP-PRX1 Ethernet",
+       },
        {
            USB_VENDOR_JVC, USB_PRODUCT_JVC_MP_XP7250_WL,
            0,