On Sat, Jun 28, 2008 at 3:33 AM, Shaz <shazalive@xxxxxxxxx> wrote: > On Sat, Jun 28, 2008 at 3:14 AM, Adrian Bunk <bunk@xxxxxxxxxx> wrote: >> On Sat, Jun 28, 2008 at 02:51:51AM +0500, Shaz wrote: >>> On Sat, Jun 28, 2008 at 2:32 AM, Adrian Bunk <bunk@xxxxxxxxxx> wrote: >>> > On Sat, Jun 28, 2008 at 02:16:14AM +0500, Shaz wrote: >>> >> Hi, >>> >> >>> >> Need to compile an external module as a kernel built-in module. Its >>> >> Makefile is set as obj-m meaning as a loadable module so it will be >>> >> kept on filesystem separately. This means I have to do obj-y to make >>> >> it built-in. But I wanted to know, before I just try it out, that the >>> >> Makefile of the kernel module is way too complex for me and there was >>> >> an install target which is creating files for miscilleneous functions >>> >> of the module and it had a /dev/<module-name>, which means its a >>> >> device driver. >>> >> >>> >> So what do I need to consider apart from the change obj-m to obj-y? >>> > >>> > It does not work this way. >>> >>> Are you sure because in kernel top-level Makefile contains SUBDIRS >>> symbol for external modules and if it contains a path then target all >>> becomes _all else _all becomes modules. Personally, I am not sure of >>> this behavior but I think if we can do obj-y instead of obj-m than >>> maybe this module is built-in. Sorry you already said it's not >>> possible but I am still curious why it doesn't in the light of >>> SUBDIRS. >> >> The reason is simple: >> When an external module gets built the kernel image is not rebuilt. > > Thats what I am trying to say. I am newbie but the following makes sense to me: > > If the SUBDIRS will take "make" to the external module by setting its > value to KBUILD_EXTMOD. Consider the following lines from kernel > Makefile: > > # If building an external module we do not care about the all: rule > # but instead _all depend on modules Oh, this is what you meant! I get it now that the kbuild does not allow external modules as built-in because the all target is not considered. > PHONY += all > ifeq ($(KBUILD_EXTMOD),) I misread this command, which means that if KBUILD_EXTMOD is equal to null string than _all depends on all. > _all: all > else > _all: modules > endif > > If the module's Makefile consists of obj-y instead of obj-y then its > should work. ...? > >> >>> By the way can you suggest how do I workout getting the code inside >>> the kernel source. >>> >>> Analyzing the following from module's Makefile: >>> >>> all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a >>> @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules >>> >>> I thought maybe if i replace "modules" with "all", it might have the >>> same effect as what I suggested in case of SUBDIRS for kernel >>> Makefile. >> >> Where can I find the source for this module? > > I am not sure what you mean by the source of the module? If you mean > source to the module Makefile then here it is: > > --------------------------------------------- > # kernel settings > KERNEL_RELEASE := $(shell uname -r) > KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build > MOD_SUBDIR := misc > > # GNU MP configuration > GMP_LIB := /usr/lib/libgmp.a > GMP_HEADER := /usr/include/gmp.h > > # sources and objects > src ?= . > DIRS := . crypto <MODULE_NAME> > SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) > OBJS := $(patsubst %.c, %.o, $(SRCS)) > SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) > DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS) > DISTDIR := > <MODULE_NAME>-$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_SUFFIX) > > # module settings > MODULE_NAME := <MODULE_NAME> > obj-m := $(MODULE_NAME).o > $(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a > > # do not print "Entering directory ..." > MAKEFLAGS += --no-print-directory > EXTRA_CFLAGS += -Wall -Werror -DDEBUG -I$(src) -I$(src)/crypto > -I$(src)/<MODULE_NAME> > > all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a > @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) all > > clean: > @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean > rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a $(src)/Modules.symvers > > install: > @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install > test -d /var/<MODULE_NAME> || mkdir /var/<MODULE_NAME> > test -c /dev/<MODULE_NAME> || mknod /dev/<MODULE_NAME> c 10 224 > depmod -a > > $(src)/crypto/libgmp.a: > test -e $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a > > # Note: We have to make sure that we use stack-based calling conventions > # when using GNU MP library functions > $(src)/crypto/gmp.h: > test -r $(src)/crypto/gmp.h || cat $(GMP_HEADER) | \ > sed -e "s/\(__GMP_DECLSPEC [^e].*\);/\1 __attribute__ ((regparm(0)));/" | \ > sed -e "s/^int$$/int __attribute__ ((regparm(0)))/" | \ > sed -e "s/^void$$/void __attribute__ ((regparm(0)))/" | \ > sed -e "s/^size_t$$/size_t __attribute__ ((regparm(0)))/" | \ > sed -e "s/^mp_limb_t$$/mp_limb_t __attribute__ ((regparm(0)))/" | \ > sed -e "s/^__GMP_EXTERN_INLINE void$$/__GMP_EXTERN_INLINE void > __attribute__ ((regparm(0)))/" | \ > sed -e "s/^unsigned long$$/unsigned long __attribute__ ((regparm(0)))/" | \ > sed -e "s/\(.* (\*__gmp_allocate_func) .*\);/\1 __attribute__ > ((regparm(0)));/" | \ > sed -e "s/\(.* (\*__gmp_reallocate_func) .*\);/\1 __attribute__ > ((regparm(0)));/" | \ > sed -e "s/\(.* (\*__gmp_free_func) .*\);/\1 __attribute__ ((regparm(0)));/" \ > > $(src)/crypto/gmp.h > > .PHONY: all clean install > > ------------------------------------------ >> >>> Thanks >> >> cu >> Adrian >> >> -- >> >> "Is there not promise of rain?" Ling Tan asked suddenly out >> of the darkness. There had been need of rain for many days. >> "Only a promise," Lao Er said. >> Pearl S. Buck - Dragon Seed >> >> > > > > -- > Shaz > -- Shaz -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ