
ifeq ($(KERNELRELEASE),)
TOPDIR = ../../..

include $(TOPDIR)/Preamble.make

else
# We are included by kbuild.

OUR_TOPDIR	:= $(M)/..

include $(OUR_TOPDIR)/Config.make
endif

COMPAT_SOURCES =
COMPAT_HEADERS =
DLM_SOURCES =
DLMFS_SOURCES =
HEADERS =

EXTRA_CFLAGS += -I$(OUR_TOPDIR)/fs/ocfs2

EXTRA_CFLAGS += -DCONFIG_OCFS2_DEBUG_MASKLOG

ifdef NO_DELAYED_WORK_STRUCT
EXTRA_CFLAGS += -DNO_DELAYED_WORK_STRUCT
endif

ifdef NO_F_PATH_IN_STRUCT_FILE
EXTRA_CFLAGS += -DNO_F_PATH_IN_STRUCT_FILE
endif

ifdef KMEM_CACHE_CREATE_DTOR
EXTRA_CFLAGS += -DKMEM_CACHE_CREATE_DTOR
endif

ifdef STRUCT_SUBSYSTEM_DEFINED
EXTRA_CFLAGS += -DSTRUCT_SUBSYSTEM_DEFINED
endif

ifdef SOP_IS_NOT_CONST
EXTRA_CFLAGS += -DSOP_IS_NOT_CONST
endif

ifdef IOP_IS_NOT_CONST
EXTRA_CFLAGS += -DIOP_IS_NOT_CONST
endif

ifdef FOP_IS_NOT_CONST
EXTRA_CFLAGS += -DFOP_IS_NOT_CONST
endif

ifdef NO_VFSMOUNT_IN_GET_SB_BDEV
EXTRA_CFLAGS += -DNO_VFSMOUNT_IN_GET_SB_BDEV
endif

ifdef NO_SYSTEM_UTSNAME
EXTRA_CFLAGS += -DNO_SYSTEM_UTSNAME
endif

ifdef NO_I_PRIVATE
EXTRA_CFLAGS += -DNO_I_PRIVATE
endif

ifdef NO_KMEM_CACHE_ZALLOC
EXTRA_CFLAGS += -DNO_KMEM_CACHE_ZALLOC
endif

DLM_SOURCES +=			\
	dlmast.c		\
	dlmconvert.c		\
	dlmdebug.c		\
	dlmdomain.c		\
	dlmlock.c		\
	dlmmaster.c		\
	dlmrecovery.c		\
	dlmthread.c		\
	dlmunlock.c		\
	dlmver.c

DLMFS_SOURCES += \
	userdlm.c		\
	dlmfs.c			\
	dlmfsver.c

HEADERS += 			\
	dlmapi.h		\
	dlmcommon.h		\
	dlmconvert.h		\
	dlmdebug.h		\
	dlmdomain.h		\
	dlmfsver.h		\
	dlmver.h		\
	userdlm.h

DLM_OBJECTS = $(subst .c,.o,$(DLM_SOURCES))
DLMFS_OBJECTS = $(subst .c,.o,$(DLMFS_SOURCES))

VERSION_FILES = $(DLM_SOURCES) $(DLMFS_SOURCES) $(HEADERS) $(COMPAT_SOURCES) $(COMPAT_HEADERS)
VERSION_SRC = dlmver.c dlmfsver.c
VERSION_PREFIX = DLM

INSTALL_MOD_DIR := fs/ocfs2

obj-m := ocfs2_dlm.o ocfs2_dlmfs.o

ocfs2_dlm-objs := $(DLM_OBJECTS)

ocfs2_dlmfs-objs := $(DLMFS_OBJECTS)

ifneq ($(KERNELRELEASE),)
#
# Argh, Versioning.make has ordering requirements, so we put this here
#
STAMP_DIR       := $(OUR_TOPDIR)/fs/ocfs2/dlm
include $(OUR_TOPDIR)/Versioning.make
endif

# This has to be outside a conditional, because of a bug in make
# It's harmless in the regular make case, as VERSION_OBJ will be empty
$(foreach objfile,$(VERSION_OBJ),$(eval CFLAGS_$(objfile) += $(VERDEFS)))

ifeq ($(KERNELRELEASE),)
#
# Called from a regular "make". Just forward to kbuild.
#

DIST_FILES = $(DLM_SOURCES) $(DLMFS_SOURCES) $(HEADERS) $(COMPAT_SOURCES) $(COMPAT_HEADERS)

ALL_RULES = stamp-md5 build-modules

CLEAN_RULES = clean-modules

INSTALL_RULES = install-modules

build-modules:
	$(MAKE) -C $(TOPDIR)/fs build-modules

install-modules:
	$(MAKE) -C $(TOPDIR)/fs install-modules

clean-modules:
	$(MAKE) -C $(TOPDIR)/fs clean-modules

include $(TOPDIR)/Postamble.make

endif
