# AUFS Makefile for the Linux 2.6.16 - 2.6.24
# $Id: Makefile,v 1.45 2008/06/30 03:48:17 sfjro Exp $

# the environment variables are not inherited since 2.6.23
ifdef AUFS_EXTRA_CFLAGS
EXTRA_CFLAGS += ${AUFS_EXTRA_CFLAGS}
endif

########################################

ifdef CONFIG_AUFS_RR_SQUASHFS
# cf. squashfs3.2-r2 and sqlzma patch.
EXTRA_CFLAGS += -DSQUASHFS_MAGIC=0x73717368
EXTRA_CFLAGS += -DSQUASHFS_MAGIC_SWAP=0x68737173
EXTRA_CFLAGS += -DSQUASHFS_MAGIC_LZMA=0x71736873
EXTRA_CFLAGS += -DSQUASHFS_MAGIC_LZMA_SWAP=0x73687371
endif

ifdef CONFIG_AUFS_WORKAROUND_FUSE
# it isn't defined in a header file
fuse_f = ${srctree}/fs/fuse/inode.c
ifeq ($(strip $(shell test -e ${fuse_f} && echo t)),t)
fuse = $(shell grep '\#.*define.*FUSE_SUPER_MAGIC' ${fuse_f} | \
	head -n 1 | \
	awk '{print $$3}')
EXTRA_CFLAGS += -DFUSE_SUPER_MAGIC=${fuse}
else
$(warning Ignoring FUSE_SUPER_MAGIC)
endif
endif

ifdef CONFIG_XFS_FS
# it isn't defined in a header file
ifeq ($(strip $(shell test ${SUBLEVEL} -ge 24 && echo t)),t)
xfs_f=${srctree}/fs/xfs/xfs_sb.h
ifeq ($(strip $(shell test -e ${xfs_f} && echo t)),t)
xfs = $(shell grep '\#.*define.*XFS_SB_MAGIC' ${xfs_f} | \
	head -n 1 | \
	awk '{print $$3}')
EXTRA_CFLAGS += -DXFS_SB_MAGIC=${xfs}
else
$(warning Ignoring XFS_SB_MAGIC)
endif
endif
endif

ifdef CONFIG_TMPFS
# it isn't defined in a header file
tmpfs_f=${srctree}/mm/shmem.c
ifeq ($(strip $(shell test -e ${tmpfs_f} && echo t)),t)
tmpfs = $(shell grep '\#.*define.*TMPFS_MAGIC' ${tmpfs_f} | \
	head -n 1 | \
	awk '{print $$3}')
EXTRA_CFLAGS += -DTMPFS_MAGIC=${tmpfs}
else
$(warning Ignoring TMPFS_MAGIC)
endif
endif

ifdef CONFIG_SYSFS
# defined in ${srctree}fs/sysfs/mount.c
EXTRA_CFLAGS += -DSYSFS_MAGIC=0x62656572
endif

#$(warning ${EXTRA_CFLAGS})

########################################

obj-$(CONFIG_AUFS) += aufs.o
aufs-y := module.o super.o sbinfo.o xino.o \
	branch.o cpup.o whout.o plink.o wkq.o dcsub.o vfsub.o wbr_policy.o \
	opts.o \
	dentry.o dinfo.o \
	file.o f_op.o finfo.o \
	dir.o vdir.o \
	inode.o i_op.o i_op_add.o i_op_del.o i_op_ren.o iinfo.o \
	misc.o

#xattr.o
ifeq ($(strip $(shell test ${SUBLEVEL} -ge 19 && echo t)),t)
aufs-$(CONFIG_AUFS_BR_NFS) += br_nfs.o
endif
aufs-$(CONFIG_AUFS_BR_XFS) += br_xfs.o
aufs-$(CONFIG_AUFS_WORKAROUND_FUSE) += br_fuse.o

aufs-$(CONFIG_AUFS_DLGT) += dlgt.o
aufs-$(CONFIG_AUFS_SYSAUFS) += sysaufs.o
aufs-$(CONFIG_AUFS_HINOTIFY) += hinotify.o hin_or_dlgt.o
# dirty
ifndef CONFIG_AUFS_HINOTIFY
aufs-$(CONFIG_AUFS_DLGT) += hin_or_dlgt.o
endif
aufs-$(CONFIG_AUFS_EXPORT) += export.o
aufs-$(CONFIG_AUFS_ROBR) += robr.o
#aufs-$(CONFIG_DEBUGFS) += dbgfs.o
aufs-$(CONFIG_AUFS_DEBUG) += debug.o
aufs-$(CONFIG_AUFS_MAGIC_SYSRQ) += sysrq.o
