From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 30 18:02:13 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73E27106564A for ; Sun, 30 Nov 2008 18:02:13 +0000 (UTC) (envelope-from fbsd.hackers@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 431238FC13 for ; Sun, 30 Nov 2008 18:02:12 +0000 (UTC) (envelope-from fbsd.hackers@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id 8786EAFC1C6; Sun, 30 Nov 2008 08:43:31 -0900 (AKST) From: Mel To: freebsd-hackers@freebsd.org Date: Sun, 30 Nov 2008 18:43:27 +0100 User-Agent: KMail/1.9.7 References: <711D7381-D852-4B6B-991A-84BA6DEFB679@gmail.com> <2A1A4C21-8A2D-4151-BCA0-5FAE1D3BBE86@gmail.com> In-Reply-To: <2A1A4C21-8A2D-4151-BCA0-5FAE1D3BBE86@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200811301843.28564.fbsd.hackers@rachie.is-a-geek.net> Cc: Nikola =?utf-8?q?Kne=C5=BEevi=C4=87?= Subject: Re: How to build kernel module spread on subdirectories? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Nov 2008 18:02:13 -0000 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