config/drivers.conf: which drivers are compiled in
y or n per optional driver (virtio-gpu, stdvga, e1000, rtl8139, native r8169, AC'97, AHCI, NVMe), all y except the native r8169, overridable with make DRV_X=n. Only drivers nothing else calls can be optional; the registry #ifdefs them and the Makefile leaves their objects out. Built with every one off (links, none of their symbols present), with r8169 on, and by default. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EVRhxi9zpdW2uDUN4FVcao
This commit is contained in:
parent
f94d19ae47
commit
1334f446cc
6 changed files with 139 additions and 16 deletions
36
Makefile
36
Makefile
|
|
@ -38,17 +38,34 @@ KERN_DEV = $(addprefix $(BUILD)/kernel/dev/, \
|
|||
# already eight files with four called usb_something, and each driver added made
|
||||
# the directory harder to read. The compile rule uses `mkdir -p $(dir $@)`, so
|
||||
# the depth costs nothing.
|
||||
# Which of them are compiled in is config/drivers.conf: y or n per driver, y by
|
||||
# default, overridable on the command line (make DRV_E1000=n). Only the drivers
|
||||
# that nothing else calls can be left out; the rest are always linked.
|
||||
-include config/drivers.conf
|
||||
DRV_LIST = VGA_PCI VIRTIO_GPU E1000 RTL8139 R8169 AC97 AHCI NVME
|
||||
DRV_DEFAULT_R8169 = n
|
||||
$(foreach d,$(DRV_LIST),$(eval DRV_$(d) ?= $(if $(DRV_DEFAULT_$(d)),$(DRV_DEFAULT_$(d)),y)))
|
||||
$(foreach d,$(DRV_LIST),$(if $(filter y n,$(DRV_$(d))),,$(error config/drivers.conf: DRV_$(d) must be y or n, not '$(DRV_$(d))')))
|
||||
DRV_DEFS = $(foreach d,$(DRV_LIST),$(if $(filter y,$(DRV_$(d))),-DCONFIG_DRV_$(d)=1))
|
||||
# Rewritten only when the choice changes, so registry.o is rebuilt then and not otherwise.
|
||||
DRV_STAMP = $(BUILD)/kernel/drivers/.config
|
||||
$(DRV_STAMP): FORCE
|
||||
@mkdir -p $(dir $@)
|
||||
@echo '$(DRV_DEFS)' | cmp -s - $@ || echo '$(DRV_DEFS)' > $@
|
||||
$(BUILD)/kernel/drivers/registry.o: $(DRV_STAMP)
|
||||
$(BUILD)/kernel/drivers/registry.o: CFLAGS += $(DRV_DEFS)
|
||||
|
||||
KERN_DRIVERS = $(BUILD)/kernel/drivers/registry.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/gpu/vga/vga_pci.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/gpu/vga/vga_fb.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/gpu/virtio_gpu/virtio_gpu.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/net/e1000/e1000.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/net/r8169/r8169.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/net/rtl8139/rtl8139.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/audio/ac97.o
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_VGA_PCI)),$(BUILD)/kernel/drivers/gpu/vga/vga_pci.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_VIRTIO_GPU)),$(BUILD)/kernel/drivers/gpu/virtio_gpu/virtio_gpu.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_E1000)),$(BUILD)/kernel/drivers/net/e1000/e1000.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_R8169)),$(BUILD)/kernel/drivers/net/r8169/r8169.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_RTL8139)),$(BUILD)/kernel/drivers/net/rtl8139/rtl8139.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_AC97)),$(BUILD)/kernel/drivers/audio/ac97.o)
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/bus/xhci/xhci.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/storage/ahci/ahci.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/storage/nvme/nvme.o
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_AHCI)),$(BUILD)/kernel/drivers/storage/ahci/ahci.o)
|
||||
KERN_DRIVERS += $(if $(filter y,$(DRV_NVME)),$(BUILD)/kernel/drivers/storage/nvme/nvme.o)
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/usb/core/usb.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/usb/hid/usb_hid.o
|
||||
KERN_DRIVERS += $(BUILD)/kernel/drivers/usb/storage/usb_storage.o
|
||||
|
|
@ -1825,3 +1842,6 @@ distclean: clean
|
|||
# build output: Alpine's usr/lib/sysctl.d is a directory, and including it
|
||||
# stopped every make with "Is a directory".
|
||||
-include $(shell find $(BUILD) \( -path $(BUILD)/aroot -o -path $(BUILD)/iso -o -path $(BUILD)/ports \) -prune -o -type f -name '*.d' -print 2>/dev/null)
|
||||
|
||||
FORCE:
|
||||
.PHONY: FORCE
|
||||
|
|
|
|||
Loading…
Reference in a new issue