public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Becker <Joel.Becker@oracle.com>
To: murtuja bharmal <murtuja_bharmal@yahoo.com>
Cc: Sam Ravnborg <sam@ravnborg.org>,
	linux-kernel@vger.kernel.org,
	linux-kbuild <linux-kbuild@vger.kernel.org>
Subject: Re: Kbuild Makefile output
Date: Thu, 15 May 2008 13:58:40 -0700	[thread overview]
Message-ID: <20080515205840.GA814@mail.oracle.com> (raw)
In-Reply-To: <818830.6509.qm@web95109.mail.in2.yahoo.com>

On Thu, May 15, 2008 at 07:31:31PM +0100, murtuja bharmal wrote:
> But now the problem is lots of file included in kernel
> module, compiled twice or even more then twice for
> user space (whithou kernel flag set) and kernel space
> as well.
> 
> Previously in 2.4 we use to put all output object file
> in different directories for kernel module and user
> binaries based on their compilation Flags.
> 
> Now after attaching kbuild makefile with this system,
> kbuild make all object file in source directory itself
> becasue of that userspace makefiles not able to
> compile those file again. Because one object file is
> already there by kbuild. So I am not able create
> userspace binary.

Two solutions.

1) Have the build name the output files appropritately.  That is,
compile foo.c to foo-kernel.o and foo-userspace.o.  Then link as needed.
The makefile dependencies Just Work.

2) Better - create a kbuild symlink farm.  That is, lay out your sources
however you want, but in a single directory that is not the parent put
your kbuild makefile.  Have it symlink all .c files for kernel building
into this directory.

toplevel
	dir1
		Makefile
		foo.c
	dir2
		Makefile
		bar.c
	dir3
		Makefile
		baz.c
	kbuild
		Makefile

The kbuild/Makefile does something like:

obj-$(CONFIG_MYMODULE) += mymodule.o
mymodule-objs := foo.o bar.o baz.o
mymodule-sources = $(patsubst %.o,%.c,$(mymodule-objs))

obj-sources = $(foreach obj,$(mymodule-sources),$(wildcard ../*/$(obj)))

$(mymodule-sources): $(obj-sources)
	for f in $(obj-sources); do	\
	  -ln -s $$f .;			\
	done

Joel

-- 

Life's Little Instruction Book #232

	"Keep your promises."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

      reply	other threads:[~2008-05-15 21:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 17:37 Kbuild Makefile output murtuja bharmal
2008-05-15 17:42 ` Sam Ravnborg
2008-05-15 18:01   ` murtuja bharmal
2008-05-15 18:31   ` murtuja bharmal
2008-05-15 20:58     ` Joel Becker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515205840.GA814@mail.oracle.com \
    --to=joel.becker@oracle.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=murtuja_bharmal@yahoo.com \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox