Skip to contentSkip to conversation

better kbuild support for drivers spanning multiple directories?

DISCUSSION Jani Nikula 1 participant 1 message Jul 31, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi -

The drm/i915 [1][2] driver has grown quite big over the years: 400+ files with a total sloccount of 175k lines. A flat directory structure just wasn't manageable anymore, and we opted to add subdirectories, despite the general recommendation [3] not to do this.

Mostly, it works all right, with some quirks. For example, things like

	$ make drivers/gpu/drm/i915/<subdir>/<file>.o

do not work out of the box; we need to add subdir Makefiles to do things like:

	subdir-ccflags-y += -I$(srctree)/$(src)/..

and include them using obj-y += <subdir>/ in the top level Makefile.

But the main problem really is having to have a top level Makefile specifying everything, instead of being able to recurse into subdirectoris with, say, lib-y += <subdir>/, and having that build a lib within the subdirectory that gets linked into the parent level module.

Is there a better way? Could we have a better way?

BR,
Jani.

[1] drivers/gpu/drm/i915
[2] https://cgit.freedesktop.org/drm/drm-tip/tree/drivers/gpu/drm/i915
[3] Documentation/kbuild/modules.rst section 4.3

Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center