Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Nov 2008 18:43:27 +0100
From:      Mel <fbsd.hackers@rachie.is-a-geek.net>
To:        freebsd-hackers@freebsd.org
Cc:        Nikola =?utf-8?q?Kne=C5=BEevi=C4=87?= <laladelausanne@gmail.com>
Subject:   Re: How to build kernel module spread on subdirectories?
Message-ID:  <200811301843.28564.fbsd.hackers@rachie.is-a-geek.net>
In-Reply-To: <2A1A4C21-8A2D-4151-BCA0-5FAE1D3BBE86@gmail.com>
References:  <711D7381-D852-4B6B-991A-84BA6DEFB679@gmail.com> <2A1A4C21-8A2D-4151-BCA0-5FAE1D3BBE86@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 29 November 2008 12:40:47 Nikola Kne=C5=BEevi=C4=87 wrote:
> On 25 Nov 2008, at 15:20 , Nikola Kne=C5=BEevi=C4=87 wrote:
> > I tried to move from OBJS into SRCS (main BSDmakefile now has: SRCS+=3D
> > $(ELEMENT_SRCS)), by using something like:
> > # subdir0
> > ELEMENT_SRCS__x =3D\
> > subdir1/file0.cc \
> > subdir1/file1.cc
> >
> > ...
> >
> > But this fails during the linking phase, because the linker is
> > called with subdir1/file0.o, instead of just file0.o.
> >
> > To make something clear, I didn't just rewrite the GNUmakefile to
> > BSDmakefile, I also followed some of the logic used to build kernel
> > modules. I'm including bsd.kmod.ko, list sources in SRCS, don't have
> > any explicit rule to build .o out of .cc/.c. There is no all:
> > target, as well.
>
> Hi,
>
> since there were no replies, I went into the various .mk's, and I
> found some inconsistencies when building modules. If you have a file
> in a different directory, below the directory where you BSDmakefile
> is, objects won't be linked nor cleaned properly.

The base of the FreeBSD build system, is that SRCS contains file names. Not=
=20
pathnames. Use .PATH directive if sources are elsewhere. This is the only=20
thing you cannot easily change and should not globally change. A simple=20
example of this is sbin/fsdb/Makefile which uses sources from sbin/fsck_ffs.

If you really need it, you should override compilation rules in your own=20
BSDmakefile, like so:
=2Ec.o:
        ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}

=2Ecpp.o:
        ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}


As a general rule, a directory should contain "one project", use bsd.subdir=
=2Emk=20
to descend.
Absolute paths in a Makefile only work on YOUR machine, so don't do it.
=2D-=20
Mel



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811301843.28564.fbsd.hackers>