From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 25 08:34:55 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 506E2820 for ; Mon, 25 Feb 2013 08:34:55 +0000 (UTC) (envelope-from jean-sebastien.pedron@dumbbell.fr) Received: from mail.made4.biz (unknown [IPv6:2001:41d0:1:7018::1:3]) by mx1.freebsd.org (Postfix) with ESMTP id E964E6A1 for ; Mon, 25 Feb 2013 08:34:54 +0000 (UTC) Received: from [2001:1b48:10b:cafe:225:64ff:febe:589f] (helo=viking.yzserv.com) by mail.made4.biz with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1U9tWM-00071A-71 for freebsd-hackers@freebsd.org; Mon, 25 Feb 2013 09:34:53 +0100 Message-ID: <512B2226.4070402@dumbbell.fr> Date: Mon, 25 Feb 2013 09:34:46 +0100 From: =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130220 Thunderbird/17.0.3 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: Re: Building a program to be used only during make buildkernel References: <5127746A.6060702@dumbbell.fr> <20130222165548.GM2598@kib.kiev.ua> In-Reply-To: <20130222165548.GM2598@kib.kiev.ua> X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2NSFMRSTKONEULXPKWPUT" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Feb 2013 08:34:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2NSFMRSTKONEULXPKWPUT Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 22.02.2013 17:55, Konstantin Belousov wrote: > On Fri, Feb 22, 2013 at 02:36:42PM +0100, Jean-S?bastien P?dron wrote: >> Hello, >> >> During the build of the "radeon" DRM driver in Linux, a C program is >> first built to generate headers included by the driver. The program is= >> not meant to be installed. >> >> In FreeBSD, how would one build and use such a program during the buil= d >> of a kernel module? And what if the driver is built into the kernel in= stead? >=20 > Look at the genasssym program, used by the kernel and several ABI modul= es > for exactly this use. Thanks for the hint! I looked at sys/modules/linux/Makefile. If I understand it correctly, there's no special magic in there, just regular Makefile targets/rules, right? Here's what I did: ---8<--- =2EPATH: ${.CURDIR}/../../../dev/drm2/radeon (...) MKREGTABLE=3D ./mkregtable REG_SRCS_DIR=3D ${.CURDIR}/../../../dev/drm2/radeon/reg_srcs ${MKREGTABLE}: mkregtable.c @ ${CC} -o $@ @/dev/drm2/radeon/mkregtable.c rn50_reg_safe.h: ${REG_SRCS_DIR}/rn50 ${MKREGTABLE} ${MKREGTABLE} ${REG_SRCS_DIR}/rn50 > $@ (...) CLEANFILES=3D \ rn50_reg_safe.h \ ... \ ${MKREGTABLE} ---8<--- It's working for me, but I don't know if it's correct. In particular: o I'm not sure "${MKREGTABLE}" should depend on "@". One target in modules/linux/Makefile has it, and I blindly copied it... o I needed to use the full path to mkregtable.c (@/dev/drm2/radeon/mkregtable.c). I thought I could use ${.IMPSRC} or "mkregtable.c" and the source would have been found magically. I haven't tried to build the module into the kernel yet. --=20 Jean-S=E9bastien P=E9dron ------enig2NSFMRSTKONEULXPKWPUT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlErIioACgkQa+xGJsFYOlOjPwCfeaF11XPAjd4B/vHYZRS3Nklm fQAAnjNUL0Kr13oM6KWTIEf7gpShelI4 =ZQxt -----END PGP SIGNATURE----- ------enig2NSFMRSTKONEULXPKWPUT--