From owner-freebsd-arch@FreeBSD.ORG Wed Aug 29 00:13:59 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 702BE106564A; Wed, 29 Aug 2012 00:13:59 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id 369978FC1A; Wed, 29 Aug 2012 00:13:58 +0000 (UTC) Received: by dadr6 with SMTP id r6so3690837dad.13 for ; Tue, 28 Aug 2012 17:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=FTOL9enOulzESx3HzAUNJZmrzfbS0l0UbgMhPxpaTu8=; b=ecbru9QO5TYf74auFBfehelitMgVt4PZGFTEsadKMpNoQmIZhlKXoeZb9ejIyNF/yL Zj46/wtByEI/zrwVlR3FuL+eCJ7eHQOCepgvhpi0I5uc0x5pN0Zo4ULl+mDP3Paj/U0c IwdR7riBwM19sj3NiUewR0Wv0xnqBG8SPFTDW6uCvk+N8P/bHHw5DjpX792sz8J6+6Ff xAQ+399F5nj35K+GHiHBr09SoQ2mqJsvzmCClvRZbSa4s4v66JWJSX5ps0tU8UbWC9kz y2JYJbW57kpmp5c+5CBdC9b/rvp9nQmMwZOvKxTCw6hAqcEa0jzT2eTIdAmLluFR1rOZ wlFA== MIME-Version: 1.0 Received: by 10.68.236.102 with SMTP id ut6mr398584pbc.113.1346199238677; Tue, 28 Aug 2012 17:13:58 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.68.36.106 with HTTP; Tue, 28 Aug 2012 17:13:58 -0700 (PDT) In-Reply-To: References: <15285562-E9BA-431B-A2C1-D0547DFB2663@bsdimp.com> <201201030924.44493.jhb@freebsd.org> Date: Tue, 28 Aug 2012 17:13:58 -0700 X-Google-Sender-Auth: 0AsSXsv1kjFUvEa2_teLFHYXWg0 Message-ID: From: Adrian Chadd To: Warner Losh Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-arch@freebsd.org 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: Wed, 29 Aug 2012 00:13:59 -0000 On 3 January 2012 15:31, Warner Losh wrote: > > On Jan 3, 2012, at 12:06 PM, Adrian Chadd wrote: > >> On 3 January 2012 10:56, Warner Losh wrote: >> >>>> So how about we do up say, the KERNOPTS field first, which would be a >>>> big win. Then KERNDEVICES too, if that's possible? >>> >>> I'd only planned on doing KERNOPTS :) >> >> KERNOPTS would be fine for now. That at least gets me out of my >> initial issues with wlan/ath building and the fun in handling options. > > Please find enclosed a proposed patch. This will not build, of course, since there's no file in the tree mesh_baby.c, so if you have IEEE80211_SUPPORT_MESH defined, it won't work. It keys off the actual define. > > It even works with devices (which define DEV_xxx), but only if you have it in the options file like isa (eg, you need to tell config to generate it). > > Comments? Hiya, I'm now facing this particular issue again for embedded builds. I now understand what you're describing. I wonder though if it's worth doing a slightly larger scale re-architecture. Ie: * teach configure to write out opt_.mk, which sets up the makefile options the same as the .h file options; * split kmod.mk into kmod-pre.mk and kmod-post.mk; * teach kmod-pre.mk to walk a list (say, OPT_MKSRCS?) and link them in as needed, as well as linking in the opt_.mk file as well; * .. then have it include the contents of each one as needed. That way kmod-pre.mk could pre-populate the options early on. If patching config is scary, we could do what you've suggested in kmod-pre.mk for now; just as long as I can populate another list (say OPT_SRCS) of opt_*.h files for it to extract options out of. What do you think? Adrian > > Warner > > Index: conf/kmod.mk > =================================================================== > --- conf/kmod.mk (revision 229436) > +++ conf/kmod.mk (working copy) > @@ -324,7 +324,16 @@ > ${_src}: > ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET} > .endif > +.if exists(${KERNBUILDDIR}/${_src}) > +_opts!=cut -d' ' -f 2 ${KERNBUILDDIR}/${_src} > +.for _o in ${_opts} > +KERNOPT_${_o}=1 > +.if defined(SRCS_${_o}) > +SRCS+=${SRCS_${_o}} > +.endif > .endfor > +.endif > +.endfor > .else > .for _src in ${SRCS:Mopt_*.h} > CLEANFILES+= ${_src} > Index: modules/ath/Makefile > =================================================================== > --- modules/ath/Makefile (revision 229436) > +++ modules/ath/Makefile (working copy) > @@ -41,6 +41,7 @@ > SRCS+= ah_osdep.c ah.c ah_regdomain.c ah_eeprom_v3.c > SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ath.h opt_ah.h opt_wlan.h > > +SRCS_IEEE80211_SUPPORT_MESH=mesh_baby.c > # > # AR5210 support; these are first generation 11a-only devices. > # >