obj-m := spramfs.o
spramfs-y := super.o namei.o file.o store.o xattr.o comp.o sweep.o ctl.o persist.o image.o
ccflags-y := -O2 -Wall -DSPRAMFS_BUILD_TAG=\"$(BUILDTAG)\"

# Signature changes compat.h cannot see from the preprocessor: probe the headers
# rather than the version, since enterprise kernels backport under an old number.
# (GNU make counts parentheses inside $(shell ...): a pattern keeps them balanced.)
# fs.h is being split into include/linux/fs/*.h release by release: probe the family.
spr-inc := $(srctree)/include/linux
spr-fs  := $(spr-inc)/fs.h $(wildcard $(spr-inc)/fs/*.h)
ccflags-y += $(shell grep -qs 'const void \*freeze_owner' $(spr-fs) && echo -DSPR_HAVE_FREEZE_OWNER)
ccflags-y += $(shell grep -qs 'struct dentry \*(\*mkdir)' $(spr-fs) && echo -DSPR_HAVE_MKDIR_DENTRY)
ccflags-y += $(shell grep -qs 'void \*posix_acl_to_xattr' $(spr-inc)/posix_acl_xattr.h && echo -DSPR_HAVE_ACL_XATTR_ALLOC)
ccflags-y += $(shell grep -qs 'struct file_kattr' $(spr-inc)/fileattr.h && echo -DSPR_HAVE_FILE_KATTR)
