On Tue, Jul 26, 2005 at 01:28:41PM -0500, Eric Sandeen wrote: > Christoph Hellwig started a thread a while ago about integrating kerntypes > builds into kbuild, but I'm not sure anything came of it. > > Unfortunately I have to build some kerntypes files nonetheless. :) > > I'm currently building the kerntypes file as a hostprog, and forcing it to > be built w/ kernel flags: > > # Kerntypes file > > # hostprogs-y, hostprogs-m, host-progs gyrations for older kbuild compat > hostprogs-$(subst m,y,$(CONFIG_FOO)) := $(KERNTYPES_NAME) > host-progs := $(hostprogs-y) > > $(KERNTYPES_NAME)-objs := kerntypes.o > > always := $(host-progs) > > # We compile/link it with kernelspace flags, even though it's not a > module... > HOSTCFLAGS_kerntypes.o := $(NOSTDINC_FLAGS) $(CPPFLAGS) $(CFLAGS) \ > $(EXTRA_CFLAGS) -g3 > # -r -nostdlib etc because kerntypes.c has no main() > HOSTLOADLIBES_$(KERNTYPES_NAME) += -r -nostdlib > > but this seems pretty hacky to me, at best. > > It seems like maybe declaring it as a lib-y might work too, but my > impression is that these libs are really only intended to be linked into > the kernel image itself. > > Any other suggestions on a clean way to do this with the existing kbuild > infrastructure?
The big issue with Kerntypes is that to be complete you need to link in files from different places. To create just a single Kerntypes.o file you can add the following to kernel/Makefile, drivers/Makefile or similar. It will not work if added in arch/$(ARCH)/Makefile! always += Kerntypes.o $(obj)/Kerntypes.o: $(src)/Kerntypes.c $(CC) $(c_flags) -c $< -o $@ I added it to drivers/Makefile and the following gcc command line was executed: gcc -m32 -Wp,-MD,drivers/.Kerntypes.o.d -nostdinc -isystem /usr/lib/gcc-lib/i586-pc-linux-gnu/3.3.5-20050130/include -D__KERNEL__ -Iinclude -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -pipe -msoft-float -mpreferred-stack-boundary=2 -march=i686 -Iinclude/asm-i386/mach-default -DKBUILD_BASENAME=Kerntypes -DKBUILD_MODNAME=Kerntypes -c drivers/Kerntypes.c -o drivers/Kerntypes.o I hope this helps a bit. PS. My example does not check for changes in dependencies end CONFIG options. That can be added if you like. You just have to use if_changed_dep. See documentation in Documentation/kbuild/makefiles.txt Sam ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ kbuild-devel mailing list kbuild-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kbuild-devel