From owner-freebsd-arch@FreeBSD.ORG Tue Jan 3 16:23:48 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC569106566B; Tue, 3 Jan 2012 16:23:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id C209E8FC16; Tue, 3 Jan 2012 16:23:48 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 6792846B2A; Tue, 3 Jan 2012 11:23:48 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id EC373B944; Tue, 3 Jan 2012 11:23:47 -0500 (EST) From: John Baldwin To: freebsd-arch@freebsd.org Date: Tue, 3 Jan 2012 09:24:44 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p8; KDE/4.5.5; amd64; ; ) References: <15285562-E9BA-431B-A2C1-D0547DFB2663@bsdimp.com> In-Reply-To: <15285562-E9BA-431B-A2C1-D0547DFB2663@bsdimp.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201201030924.44493.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 03 Jan 2012 11:23:48 -0500 (EST) Cc: Adrian Chadd Subject: Re: Request for help: how do teach module building about kernel options? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2012 16:23:49 -0000 On Saturday, December 31, 2011 8:52:29 pm Warner Losh wrote: > > On Dec 31, 2011, at 4:39 PM, Adrian Chadd wrote: > > > Hi, > > > > I need a bit of a hand with this. > > > > I'd like to be able to make the wlan and ath modules aware of kernel > > configuration options. > > > > For example, a kernel configuration with IEEE80211_SUPPORT_TDMA won't > > build a wlan module that'll run successfully, as wlan/Makefile doesn't > > know to suck in ieee80211_tdma.c . I could just wrap the whole file up > > in an #ifdef, but I'd like to try and instead only build / link that > > object in if it's needed. > > > > Similarly, the ath module currently builds everything, regardless of > > what options are currently enabled in the kernel configuration file. > > So it'll always build ar5210, ar5211, ar5212, ar5416, ar9001, ar9002 > > support, along with ath_rate_sample. Instead, I'd like to be able to > > specify which HAL objects to link in, much like how you can do this > > with "device ath_rfX" for the RF backends and "device ath_arX" for the > > chipset support. For the integrated SoC stuff, it'd be nice to only > > build a HAL which supports the relevant hardware, rather than having > > to suck it _all_ in. > > > > So, what kinds of evil ways can people dream up to achieve this? :) > > Build the kernel modules with the kernel and the kernel options will be picked up. > > However, that only works for the opt_xxx.h files. There's not an (easy) way to selectively include for modules with our current module system. > > The easy way to "work around" this is to always include the _tdma file, and have a big ifdef around it. > > The 'harder' way would be to have a Makefile variable that will set all the options in opt_foo.h as Makefile variables so you could .if based on them. However, making that automated starts to get messy, due to the order of inclusion. > > Working off the cuff, I'd propose the following API: > > KERNOPTS=foo baz > SRC_FOO = foo.c > SRC_BAZ = baz.c > SRC= a.c b.c d.c > > And have the magic needed to conditionally add SRC_FOO and SRC_BAZ to SRC in bsd.kern.mk. Not only that, but it would be nice if the list of modules to be built could be tailored to what options are enabled. For example, if I build a kernel that doesn't have inet or inet6 then it shouldn't try to build ipfw, etc. -- John Baldwin