Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Dec 2014 15:13:43 -0600 (CST)
From:      Robert Bonomi <bonomi@mail.r-bonomi.com>
To:        freebsd-hackers@freebsd.org
Subject:   passing 'config' file data to a kernel loadable module ??
Message-ID:  <201412302113.sBULDhan082070@host203.r-bonomi.com>

next in thread | raw e-mail | index | archive | help

I'm hacking on an existing screen-saver module, and would like to set options
in the config file that are passed to the compiler when the module is built.

I can't find a decent description of the gory details of HOW 'config' works.
Chapter 2 of the SMM, "Building 4.4BSD Kernels with Config" has falsehoods --
  to wit: the example on page 10, under the 'options' keyword, given as
       'options -DFUNNY,-DHAHA'
  causes 'config' to abort with a fatal error.
Apparently an 'option' must be defined 'somewhere else', before config
recognizes it. <wry grin>

I've got an 'ugly' method -- "makeoptions CONF_CLFAGS+=-D{{NAME}}" -- that 
works for compiling the '.o' that gets linked into the kernel executable,
BUT that make variable is not passed to the (separate!!) compile stage for
building a.ko module.   Yes, the source-code is compiled _twice_, with the
resulting .o file in two separate locations, and the options passed to the
compiler are *NOT* identical in both instances -- they're 'close', but not
'exactly the same'.  Is there a good reason why they're different?

Is there an 'approved' way for getting a supplemental 'definition' from the
kernel config file passed to the compile of a loadable module?

Is there a 'less ugly' way than what I described above, to  get such a 
definition passed to compilation of a module that will be linked into the
kernel?

Ideally, is there a single means/method that will accomplish both tasks?

Wish-list: something that does _not_ require modifying other files in the
'magic data' that config uses?

Peripherally related thereunto, is there a cookbook or other example of 
making a 'port' for a kernel module, and what all needs to be in it?




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412302113.sBULDhan082070>