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

include $(TOPDIR)/Preamble.make

else
# We are included by kbuild.

OUR_TOPDIR	:= $(M)/..

include $(OUR_TOPDIR)/Config.make
endif

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

ifdef BACKING_DEV_CAPABILITIES
EXTRA_CFLAGS += -DBACKING_DEV_CAPABILITIES
endif

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

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

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

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

VERSION_FILES = $(DLM_SOURCES) $(DLMFS_SOURCES) $(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)

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
