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

include $(TOPDIR)/Preamble.make
else
# We are included by kbuild.

OUR_TOPDIR	:= $(M)/..

include $(OUR_TOPDIR)/Config.make

CPPFLAGS := -I$(OUR_TOPDIR)/include $(CPPFLAGS)
endif

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

ifdef OCFS_DEBUG
EXTRA_CFLAGS += -g
EXTRA_CFLAGS += -DDEBUG
endif

EXTRA_CFLAGS += -DCATCH_BH_JBD_RACES -DOCFS2_ORACORE_WORKAROUNDS

ifdef JOURNAL_ACCESS_WITH_CREDITS
EXTRA_CFLAGS += -DJOURNAL_ACCESS_WITH_CREDITS
endif

ifdef NEW_FOLLOW_LINK_API
EXTRA_CFLAGS += -DNEW_FOLLOW_LINK_API
endif

EXTRA_CFLAGS += -DOCFS2_DELETE_INODE_WORKAROUND
EXTRA_CFLAGS += -DOCFS2_CDSL

#
# Since SUBDIRS means something to kbuild, define them safely.  Do not
# include trailing slashes.
#
SAFE_SUBDIRS = cluster dlm

SOURCES =			\
	aio.c 			\
	alloc.c 		\
	aops.c 			\
	buffer_head_io.c	\
	dcache.c 		\
	dir.c 			\
	dlmglue.c 		\
	extent_map.c 		\
	file.c 			\
	heartbeat.c 		\
	inode.c 		\
	journal.c 		\
	localalloc.c 		\
	mmap.c 			\
	namei.c 		\
	proc.c 			\
	slot_map.c 		\
	suballoc.c 		\
	super.c 		\
	symlink.c 		\
	sysfile.c 		\
	uptodate.c		\
	ver.c 			\
	vote.c

HEADERS = 			\
	ocfs2_fs.h		\
	ocfs1_fs_compat.h	\
	ocfs2_lockid.h		\
	ocfs2.h			\
	buffer_head_io.h	\
	aio.h			\
	alloc.h			\
	dcache.h		\
	dir.h			\
	dlmglue.h		\
	endian.h		\
	extent_map.h		\
	file.h			\
	heartbeat.h		\
	inode.h			\
	journal.h		\
	localalloc.h		\
	mmap.h			\
	namei.h			\
	proc.h			\
	slot_map.h		\
	suballoc.h		\
	super.h			\
	symlink.h		\
	sysfile.h		\
	uptodate.h		\
	ver.h			\
	vote.h

OBJECTS = $(subst .c,.o,$(SOURCES))
VERSION_FILES = $(SOURCES) $(HEADERS)
VERSION_SRC = ver.c
VERSION_PREFIX = OCFS2

INSTALL_MOD_DIR := fs/ocfs2

obj-m := ocfs2.o

ocfs2-objs := $(OBJECTS)

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

obj-m += $(addsuffix /,$(SAFE_SUBDIRS))
endif

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

DIST_FILES = $(SOURCES) $(HEADERS)

ALL_RULES = stamp-md5 build-modules

CLEAN_RULES = clean-modules

INSTALL_RULES = install-modules

# Traverse subdirs via Makebo for "make dist"
ifeq ($(MAKECMDGOALS),dist-all)
SUBDIRS = $(SAFE_SUBDIRS)
endif

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
