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 build >> of a kernel module? And what if the driver is built into the kernel instead? > > Look at the genasssym program, used by the kernel and several ABI modules > 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<--- .PATH: ${.CURDIR}/../../../dev/drm2/radeon (...) MKREGTABLE= ./mkregtable REG_SRCS_DIR= ${.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= \ 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. -- Jean-Sébastien Pédron
signature.asc
Description: OpenPGP digital signature