Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Feb 2013 09:34:46 +0100
From:      =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= <jean-sebastien.pedron@dumbbell.fr>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Building a program to be used only during make buildkernel
Message-ID:  <512B2226.4070402@dumbbell.fr>
In-Reply-To: <20130222165548.GM2598@kib.kiev.ua>
References:  <5127746A.6060702@dumbbell.fr> <20130222165548.GM2598@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



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