Re: FW: Making usb modules (quickly)

Michael Elizabeth Chastain (mec@shout.net)
Tue, 9 Nov 1999 15:39:54 -0600


Hi Randy,

I apologize for that null message.

First, your problem ...

> When building only USB modules (for development/debug/test),
> I sometimes use "make modules SUBDIRS=drivers/usb".
> This always builds all of the USB modules that I have
> enabled in {menu|x}config, not just any that have
> changed since the last build.

This is because drivers/usb/Makefile marks a whole bunch of object
modules as MIX_OBJS. They don't need to be. Only things that export
symbols need to be MIX_OBJS, which means only usb.o. Everything else
can be an MI_OBJS and that ought to fix your problem.

Compiling extraneous files is harmless (but annoying), so I give this a
low priority. I give a higher priority to fixing CONFIG_MODVERSIONS so
that there is no more X_OBJ distinction and the Makefiles automatically
figure out when to run genksyms.

Next, here is the story on mkdep, touch, and .PRECIOUS files:

Suppose the kernel has this #include hierarchy:

/* drivers/foo/foo.c */
#include <linux/bar.h>
#include <linux/baz.h>

/* include/linux/bar.h */
#include <linux/grob.h>

Then mkdep creates the following dependencies:

# drivers/foo/.depend
foo.o: \
/usr/src/linux/include/linux/bar.h \
/usr/src/linux/include/linuz/baz.h

# .hdepend:
/usr/src/linux/include/linux/bar.h: \
/usr/src/linux/include/linux/grob.h
@touch /usr/src/linux/include/linux/bar.h

This way, when grob.h gets edited, bar.h gets touched, and everything
that depends on bar.h gets recompiled. This "touching" scheme works
transitively for as many levels as the include files are nested.

This scheme has bad side-effects, such as unhappy interactions with
source control systems and an inability to make from read-only source.

Here is one of the side-effects: if the user interrupts the kernel build
during the middle of a "touch" command, make deletes the target file
(include/linux/bar.h in this case). The .PRECIOUS target protects against
that bug; it instructs "make" to refrain from deleting these files.
So everything that can be touched -- every .h file that includes other .h
files -- needs to be a dependency of .PRECIOUS.

.PRECIOUS does not cause the target to be remade even when it already
to exist. That is the function of .PHONY; and mkdep does not use .PHONY
(nor should it).

Whew. That's probably more than you wanted to know about mkdep, touch,
and .PRECIOUS. But the kernel cries out for
Documentation/kbuild/mkdep.txt,
so I thought I'd share some information.

Michael Elizabeth Chastain
<mailto:mec@shout.net>
"love without fear"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/