Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 May 2003 00:18:15 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        arch@freebsd.org
Subject:   Moving the generation of foodevs.h to build time
Message-ID:  <20030513.001815.55840081.imp@bsdimp.com>

next in thread | raw e-mail | index | archive | help
OK.  Here's a start at moving it.  First, we have to move
devlist2h.awk out of tools back to dev/mii/devlist2h.awk.  It
shouldn't be in tool if it only generates MII code, and it is hard to
merge all the devlist2h.awks in the tree because their requirements
are so differnet (at least on the surface).  Second, apply the
following patch.  Third, we have to get rid of the special cases mii
that were foisted onto kern.post.mk and come up with a more generic
way to cope with the problem:

-.if !exists(.depend)
-acphy.o amphy.o bmtphy.o brgphy.o dcphy.o e1000phy.o exphy.o if_bge.o if_tx.o \
-inphy.o lxtphy.o nsgphy.o nsphy.o pnaphy.o pnphy.o qsphy.o rlphy.o tdkphy.o \
-tlphy.o xmphy.o: miidevs.h
-.endif

because listing every .o that has these things is duplicating 'make
depend' needlessly.

We'd also have to hack all the drivers in the tree to include
"foodevs.h" rather than <dev/foo/foodevs.h>, and accept that some of
them will have ifdefs for 4.x (since bus front ends are still trivial
to share between 4.x and 5.0).  I've not included this task in these
initial patches.

Personally, I think it just isn't worth the pain to deal.  However,
I'd be willing to go along with it if we can work up a complete set of
patches that don't break anything that works now.

Also, my checklist for a 'working' solution is:

1) Allow out of tree builds of a single module w/o any sys/module/*
   built (eg build ~imp/fred/usb_blob with SYSDIR set
   ~imp/FreeBSD/src/sys).
2) kernel and modules work, both built together and modules built
   directly in sys/modules.
3) This doesn't mess up dependencies.  The mii migration messed them up for
   me and sometimes bad things still happen (but it may be a generic
   make depends bug).
4) Works with and without a objdir
5) doesn't add significantly to the build time.
6) Passes the 'I can build one module' test (eg, doesn't require other
   modules to be built before a client driver can be built).

Warner


Index: conf/kmod.mk
===================================================================
RCS file: /home/ncvs/src/sys/conf/kmod.mk,v
retrieving revision 1.137
diff -u -r1.137 kmod.mk
--- conf/kmod.mk	3 Mar 2003 22:51:22 -0000	1.137
+++ conf/kmod.mk	13 May 2003 06:06:30 -0000
@@ -286,15 +286,16 @@
 .endif
 .endfor
 
-.if ${SRCS:Mmiidevs.h} != ""
-CLEANFILES+=	miidevs.h
+.for _dev in mii usb pccard
+.if ${SRCS:M${_dev}devs.h} != ""
+CLEANFILES+=	${_dev}devs.h
 .if !exists(@)
 miidevs.h: @
 .endif
 .if exists(@)
-miidevs.h: @/tools/devlist2h.awk @/dev/mii/miidevs
+miidevs.h: @/tools/devlist2h.awk @/dev/${_dev}/${_dev}devs
 .endif
-	${AWK} -f @/tools/devlist2h.awk @/dev/mii/miidevs
+	${AWK} -f @/dev/${_dev}/devlist2h.awk @/dev/${_dev}/${_dev}devs
 .endif
 
 regress:
Index: dev/mii/devlist2h.awk
===================================================================
RCS file: dev/mii/devlist2h.awk
diff -N dev/mii/devlist2h.awk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dev/mii/devlist2h.awk	13 May 2003 06:06:30 -0000
@@ -0,0 +1,147 @@
+#! /usr/bin/awk -f
+#	$NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
+#
+# Copyright (c) 1998 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#        This product includes software developed by the NetBSD
+#        Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+#    contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# 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.
+#
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This model includes software developed by Christopher G. Demetriou.
+#      This model includes software developed by Christos Zoulas
+# 4. The name of the author(s) may not be used to endorse or promote models
+#    derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN 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/tools/devlist2h.awk,v 1.4 2003/01/19 02:59:34 obrien Exp $
+#
+function collectline(f, line) {
+	oparen = 0
+	line = ""
+	while (f <= NF) {
+		if ($f == "#") {
+			line = line "("
+			oparen = 1
+			f++
+			continue
+		}
+		if (oparen) {
+			line = line $f
+			if (f < NF)
+				line = line " "
+			f++
+			continue
+		}
+		line = line $f
+		if (f < NF)
+			line = line " "
+		f++
+	}
+	if (oparen)
+		line = line ")"
+	return line
+}
+BEGIN {
+	nmodels = nouis = 0
+	hfile="miidevs.h"
+}
+NR == 1 {
+	VERSION = $0
+	gsub("\\$", "", VERSION)
+
+	printf("/* \$FreeBSD\$ */\n\n") > hfile
+	printf("/*\n") > hfile
+	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
+	    > hfile
+	printf(" *\n") > hfile
+	printf(" * generated from:\n") > hfile
+	printf(" *\t%s\n", VERSION) > hfile
+	printf(" */\n") > hfile
+
+	next
+}
+$1 == "oui" {
+	nuios++
+
+	ouiindex[$2] = nouis;		# record index for this name, for later.
+
+	ouis[nouis, 1] = $2;		# name
+	ouis[nouis, 2] = $3;		# id
+	printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
+	    ouis[nouis, 2]) > hfile
+	ouis[nouis, 3] = collectline(4, line)
+	printf("/* %s */\n", ouis[nouis, 3]) > hfile
+	next
+}
+$1 == "model" {
+	nmodels++
+
+	models[nmodels, 1] = $2;		# oui name
+	models[nmodels, 2] = $3;		# model id
+	models[nmodels, 3] = $4;		# id
+
+	printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
+	    models[nmodels, 2], models[nmodels, 3]) > hfile
+
+	models[nmodels, 4] = collectline(5, line)
+
+	printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
+	    models[nmodels, 1], models[nmodels, 2],
+	    models[nmodels, 4]) > hfile
+
+	next
+}
+{
+	print $0 > hfile
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030513.001815.55840081.imp>