# Copyright (c) 2019, Sonos Inc.  All rights reserved.

KBUILD_CFLAGS_MODULE += -Werror

ccflags-y := -I$(src)/../include

# We rewrote this driver entirely during the 4.9.99 kernel migration.
TOTAL_KERNEL_VERSION := $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
ifeq ($(TOTAL_KERNEL_VERSION), 3.10.53)
  NEW_DRIVER :=
else ifeq ($(TOTAL_KERNEL_VERSION), 4.4.24)
  NEW_DRIVER :=
else
  NEW_DRIVER := 1
endif

ifdef CONFIG_MTD_UBI_GLUEBI
  # the module is always called virtual_block.ko ...
  obj-m := virtual_block.o
  # but with the new driver it is built from virtual_block_new.c instead
  ifdef NEW_DRIVER
    virtual_block-y := virtual_block_new.o
  endif
endif
