Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Mar 2021 01:35:30 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Andrew Mitchell <andy_mitchell_fr@icloud.com>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Compiling a c program into .ko
Message-ID:  <CANCZdfqDEJL%2BcPgVkovDcZ_2YXO6E1oz-Z01jS4o7dt8D8m1gg@mail.gmail.com>
In-Reply-To: <79347B65-6929-4DDF-8528-06E31887F3CF@icloud.com>
References:  <79347B65-6929-4DDF-8528-06E31887F3CF@icloud.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 24, 2021 at 12:23 AM Andrew Mitchell via freebsd-drivers <
freebsd-drivers@freebsd.org> wrote:

> Hello,
> I haven=E2=80=99t been able for the last few weeks to understand why my f=
ile.c
> won=E2=80=99t compile into a file.ko.
> I include <bsd.kmod.mk> in Makefile, but make returns an error which I
> can=E2=80=99t explain. In all the documentation I have come across nothin=
g is said
> of SYSDIR, which is reported in the error message.
> If you have met with this problem and found a practical solution, please
> send me an answer so that I can unearth this arcana.
>

To build a kernel module, you need a copy of the kernel source. You can get
it from the 'src' git repo under sys. so if you cloned a work tree to
/foo/bar/FreeBSD/src/sys, you'd set SYSDIR to /foo/bar/FreeSBD/src/sys in
your shell environment, or type it each time on the make command line.
Alternatively, you can put your kernel sources in /usr/src/sys and it will
pick them up automatically.

This should be documented in the build(7) man page, but is conspicuous by
its absence.  I'll fix that shortly, but this should get you to the next
step.

Warner


> Cheers,
> Andy
>
>
>
> Envoy=C3=A9 de mon iPhone
> _______________________________________________
> freebsd-drivers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers
> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org=
"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfqDEJL%2BcPgVkovDcZ_2YXO6E1oz-Z01jS4o7dt8D8m1gg>