We don't really have a nice way to say "compile this when CONFIG_FOO
is y, don't otherwise".
Alternatives are:
obj-$(subst m,,$(CONFIG_FOO)) := foo.o
or
obj-$(CONFIG_FOO) := foo.o
obj-m :=
or
obj-y := do_foo.o
do_foo-$(CONFIG_FOO) := foo.o
I chose the last one, though I'm not particularly happy with either.
# Makefile for the linux kernel.
#
-obj-y := main.o version.o do_mounts.o initramfs.o
-obj-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
-obj-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
-obj-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
+obj-y := main.o version.o mounts.o initramfs.o
+mounts-y := do_mounts.o
+mounts-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
+mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
+mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
# files to be removed upon make clean
clean-files := ../include/linux/compile.h