* Re: Kbuild Makefile output [not found] <339763.26248.qm@web95104.mail.in2.yahoo.com> @ 2008-05-15 17:42 ` Sam Ravnborg 2008-05-15 18:01 ` murtuja bharmal 2008-05-15 18:31 ` murtuja bharmal 0 siblings, 2 replies; 8+ messages in thread From: Sam Ravnborg @ 2008-05-15 17:42 UTC (permalink / raw) To: murtuja bharmal; +Cc: linux-kernel, linux-kbuild On Thu, May 15, 2008 at 11:07:19PM +0530, murtuja bharmal wrote: > Hello All. > I want to collect all my object file in onedirectory and then want to create a kernel module. > For example: This my directory structure. > dir > | > -------------------------------------- > | | | | > dir1 dir2 dir3 dir4 > This is my makefile in 'dir'. > obj-m := test.o > test-objs += \ > dir1/test1.o \ > dir2/test2.o \ > dir3/test3.o > all: > make -C /usr/src/linux M=`pwd` modules > > Now I want to save all output objectfile test1.o test2.o test3.o in one directory > called 'dir4' not in source directory. 'test.o' should look all this object file in 'dir4' for linking, not in the source directory and 'test.ko' should also be create in 'dir4'. > Can any one tell me, what is require changes in Kernel Makefile for the same. Do not do that... If you really need to do so - please explain why so we can understand the rationale. There are ~2000 modules that does not need this so what makes your maodule so special? [Added kbuild@vger to cc as you also asked there] Sam ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-15 17:42 ` Kbuild Makefile output Sam Ravnborg @ 2008-05-15 18:01 ` murtuja bharmal 2008-05-15 18:31 ` murtuja bharmal 1 sibling, 0 replies; 8+ messages in thread From: murtuja bharmal @ 2008-05-15 18:01 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel, linux-kbuild Hello Sam, Thanks for reply. Actually Problem is. As I told you I have near near about 1000 file that compiles for single module creation which spread in multiple directies in 2.4 with lots of makefile. Now I have created single makefile to compile all this file and able to create kernel module. 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 and this userspace binary is not a part of kbuild makefile. Previously in 2.4 we use to put all output object file in different directories for kernel module and user binaries based in 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. Now either solution is generate kbuild object file in different directory not in source directory as per our previous design or make a copy of exsisting file with some other name. One for kernel and one for user space. So I thought lets check the possibility of generating all kernel related object file in some other directory not in source directory. Thanks Murtuja --- Sam Ravnborg <sam@ravnborg.org> wrote: > On Thu, May 15, 2008 at 11:07:19PM +0530, murtuja > bharmal wrote: > > Hello All. > > I want to collect all my object file in > onedirectory and then want to create a kernel > module. > > For example: This my directory structure. > > dir > > | > > -------------------------------------- > > | | | | > > dir1 dir2 dir3 dir4 > > This is my makefile in 'dir'. > > obj-m := test.o > > test-objs += \ > > dir1/test1.o \ > > dir2/test2.o \ > > dir3/test3.o > > all: > > make -C /usr/src/linux M=`pwd` modules > > > > Now I want to save all output objectfile test1.o > test2.o test3.o in one directory > > called 'dir4' not in source directory. 'test.o' > should look all this object file in 'dir4' for > linking, not in the source directory and 'test.ko' > should also be create in 'dir4'. > > Can any one tell me, what is require changes in > Kernel Makefile for the same. > > Do not do that... > > If you really need to do so - please explain why so > we can understand the rationale. > There are ~2000 modules that does not need this so > what makes your maodule so special? > > [Added kbuild@vger to cc as you also asked there] > > Sam > Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-15 17:42 ` Kbuild Makefile output Sam Ravnborg 2008-05-15 18:01 ` murtuja bharmal @ 2008-05-15 18:31 ` murtuja bharmal 2008-05-15 20:58 ` Joel Becker 1 sibling, 1 reply; 8+ messages in thread From: murtuja bharmal @ 2008-05-15 18:31 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel, linux-kbuild --- Sam Ravnborg <sam@ravnborg.org> wrote: > On Thu, May 15, 2008 at 11:07:19PM +0530, murtuja > bharmal wrote: > > Hello All. > > I want to collect all my object file in > onedirectory and then want to create a kernel > module. > > For example: This my directory structure. > > dir > > | > > -------------------------------------- > > | | | | > > dir1 dir2 dir3 dir4 > > This is my makefile in 'dir'. > > obj-m := test.o > > test-objs += \ > > dir1/test1.o \ > > dir2/test2.o \ > > dir3/test3.o > > all: > > make -C /usr/src/linux M=`pwd` modules > > > > Now I want to save all output objectfile test1.o > test2.o test3.o in one directory > > called 'dir4' not in source directory. 'test.o' > should look all this object file in 'dir4' for > linking, not in the source directory and 'test.ko' > should also be create in 'dir4'. > > Can any one tell me, what is require changes in > Kernel Makefile for the same. > > Do not do that... > > If you really need to do so - please explain why so > we can understand the rationale. > There are ~2000 modules that does not need this so > what makes your maodule so special? > > [Added kbuild@vger to cc as you also asked there] > > Sam > Hello Sam, Thanks for reply. Actually Problem is. As I told you I have near near about 1000 file that compiles for single module creation which spread in multiple directies in 2.4 with lots of makefile. Now I have created single makefile to compile all this file and able to create kernel module. 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. Now either solution is generate kbuild object file in different directory not in source directory as per our previous design or make a copy of exsisting file with some other name. One for kernel and one for user space but this is also not a good approach. So I thought lets check the possibility of generating all kernel related object file in some other directory not in source directory. So I just want to know whether it is possible or not and if possible how. Thanks Murtuja Forgot the famous last words? Access your message archive online at http://in.messenger.yahoo.com/webmessengerpromo.php ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-15 18:31 ` murtuja bharmal @ 2008-05-15 20:58 ` Joel Becker 2008-05-16 6:03 ` murtuja bharmal 0 siblings, 1 reply; 8+ messages in thread From: Joel Becker @ 2008-05-15 20:58 UTC (permalink / raw) To: murtuja bharmal; +Cc: Sam Ravnborg, linux-kernel, linux-kbuild 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-15 20:58 ` Joel Becker @ 2008-05-16 6:03 ` murtuja bharmal 2008-05-16 9:32 ` Joel Becker 0 siblings, 1 reply; 8+ messages in thread From: murtuja bharmal @ 2008-05-16 6:03 UTC (permalink / raw) To: Joel Becker; +Cc: linux-kbuild --- Joel Becker <Joel.Becker@oracle.com> wrote: > 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. > Thanks Joel, In case of Solution 1. what changes required in Makefile. I mean how to build foo-kernel.c from foo.c using kbuild makefile. Suppose this is my makefile obj-m := mymodule.o mymodule-objs += \ dir1/foo.o \ dir2/bar.o all: make -C /usr/src/linux M=`pwd` modules. I only want to change name for foo.c to foo-kernel.o, not for bar.c. Thanks Murtuja Best Jokes, Best Friends, Best Food and more. Go to http://in.promos.yahoo.com/groups/bestofyahoo/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-16 6:03 ` murtuja bharmal @ 2008-05-16 9:32 ` Joel Becker 2008-05-16 11:36 ` murtuja bharmal 0 siblings, 1 reply; 8+ messages in thread From: Joel Becker @ 2008-05-16 9:32 UTC (permalink / raw) To: murtuja bharmal; +Cc: linux-kbuild On Fri, May 16, 2008 at 07:03:55AM +0100, murtuja bharmal wrote: > > --- Joel Becker <Joel.Becker@oracle.com> wrote: > > > 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. > > > > Thanks Joel, > In case of Solution 1. > what changes required in Makefile. > I mean how to build foo-kernel.c from foo.c using > kbuild makefile. I still prefer solution 2, but for solution 1, you could do multiple things. You could leave them as them foo.o and foo-userspace.o. That is, build the kernel drivers without a rename. Whatever you do, you're going to hvae to be consistent. So... > Suppose this is my makefile > > obj-m := mymodule.o > > mymodule-objs += \ > dir1/foo.o \ > dir2/bar.o > > all: > make -C /usr/src/linux M=`pwd` modules. > > I only want to change name for foo.c to foo-kernel.o, > not for bar.c. Why would you do that? bar.c is part of the kernel driver, so it should be bar-kernel.o if you are renaming. You don't have to rename, of course. You could use 'foo.o' for kernel objects and 'foo-userspace.o' for userspace objects. Joel -- "People with narrow minds usually have broad tongues." Joel Becker Principal Software Developer Oracle E-mail: joel.becker@oracle.com Phone: (650) 506-8127 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-16 9:32 ` Joel Becker @ 2008-05-16 11:36 ` murtuja bharmal 2008-05-16 16:02 ` Joel Becker 0 siblings, 1 reply; 8+ messages in thread From: murtuja bharmal @ 2008-05-16 11:36 UTC (permalink / raw) To: Joel Becker; +Cc: linux-kbuild > On Fri, May 16, 2008 at 07:03:55AM +0100, murtuja > bharmal wrote: > > > > --- Joel Becker <Joel.Becker@oracle.com> wrote: > > > > > 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. > > > > > > > Thanks Joel, > > In case of Solution 1. > > what changes required in Makefile. > > I mean how to build foo-kernel.c from foo.c using > > kbuild makefile. > > I still prefer solution 2, but for solution 1, you > could do > multiple things. You could leave them as > them foo.o and foo-userspace.o. That is, build the > kernel drivers > without a rename. Whatever you do, you're going to > hvae to be > consistent. So... > > > Suppose this is my makefile > > > > obj-m := mymodule.o > > > > mymodule-objs += \ > > dir1/foo.o \ > > dir2/bar.o > > > > all: > > make -C /usr/src/linux M=`pwd` modules. > > > > I only want to change name for foo.c to > foo-kernel.o, > > not for bar.c. > > Why would you do that? bar.c is part of the kernel > driver, so > it should be bar-kernel.o if you are renaming. You > don't have to > rename, of course. You could use 'foo.o' for kernel > objects and > 'foo-userspace.o' for userspace objects. > Actaually foo.c is common file for kernel space and user space and bar.c is only a part of kernel space. Anyway if we can change object file name for all source file without changing source file name, then also no issue but I just want to know whether it is possible or not. I tried to hard to find out way to put object file in differnet directory not in source directory, to change a name of individual object file or all object file, other then source name. But didn't find any clear idea in internet or kbuild documentation. I think in case of 2.4 lots things is possible because we are using it as normal makefile. Thanks Murtuja Chocoholics' paradise! Enter here - http://in.search.yahoo.com/search?&fr=na_onnetwork_mail_taglines&ei=UTF-8&rd=r1&p=chocolates ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kbuild Makefile output 2008-05-16 11:36 ` murtuja bharmal @ 2008-05-16 16:02 ` Joel Becker 0 siblings, 0 replies; 8+ messages in thread From: Joel Becker @ 2008-05-16 16:02 UTC (permalink / raw) To: murtuja bharmal; +Cc: linux-kbuild On Fri, May 16, 2008 at 12:36:30PM +0100, murtuja bharmal wrote: > Actaually foo.c is common file for kernel space and > user space and bar.c is only a part of kernel space. > Anyway if we can change object file name for all > source file without changing source file name, then > also no issue but I just want to know whether it is > possible or not. In general, kbuild wants to find a source file with the same name as the object file. That you can't change. It also expects to build object files in the same directory as their source files. This is why I suggested a special directory where you symlink all the required sources for a kernel build, then let kbuild do the rest. To sum up - pick the names you want for the files in a kernel build. Set them in mymodule-objs. Then if those names are different than your actual source file, come up with a rule to change the name. Joel -- "It is not the function of our government to keep the citizen from falling into error; it is the function of the citizen to keep the government from falling into error." - Robert H. Jackson Joel Becker Principal Software Developer Oracle E-mail: joel.becker@oracle.com Phone: (650) 506-8127 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-05-16 16:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <339763.26248.qm@web95104.mail.in2.yahoo.com>
2008-05-15 17:42 ` Kbuild Makefile output Sam Ravnborg
2008-05-15 18:01 ` murtuja bharmal
2008-05-15 18:31 ` murtuja bharmal
2008-05-15 20:58 ` Joel Becker
2008-05-16 6:03 ` murtuja bharmal
2008-05-16 9:32 ` Joel Becker
2008-05-16 11:36 ` murtuja bharmal
2008-05-16 16:02 ` Joel Becker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox