# Makefile.in for kernel module

SHELL = /bin/sh
INSTALL = @INSTALL@
mkdir_p = mkdir -p
majver = @majver@
VERSION = @PACKAGE_VERSION@

DISTFILES = Makefile.in configure.ac configure config.h.in ../install-sh \
	dev.c dir.c file.c inode.c fuse_i.h fuse_kernel.h
COMPATDISTFILES = compat/parser.c compat/parser.h

fusemoduledir = @kmoduledir@/kernel/fs/fuse

ifeq ($(majver), 2.4)
fusemodule := fuse.o
else
fusemodule := fuse.ko
endif

all: all-@ENABLE_FUSE_MODULE@
install: install-@ENABLE_FUSE_MODULE@
uninstall: uninstall-@ENABLE_FUSE_MODULE@

all-n:
install-n:
uninstall-n:

all-y: all-spec

install-y: all
	$(mkdir_p) $(DESTDIR)$(fusemoduledir)
	$(INSTALL) -m 644 $(fusemodule) $(DESTDIR)$(fusemoduledir)/$(fusemodule)
	-/sbin/depmod -a

uninstall-y:
	rm -f $(DESTDIR)$(fusemoduledir)/$(fusemodule)
	-/sbin/depmod -a

clean:
	-rm -f $(fusemodule) *.o .*.cmd *.mod.c *.ko *.s */*.o

distclean: clean
	rm -f Makefile
	rm -f config.h config.log config.status config.cache
	rm -rf .tmp_versions

maintainer-clean: distclean

distdir: $(DISTFILES) $(COMPATDISTFILES)
	cp -p $(DISTFILES) $(distdir)
	mkdir $(distdir)/compat
	cp -p $(COMPATDISTFILES) $(distdir)/compat

ifeq ($(majver), 2.4)

CC = gcc
LD = ld
CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe 
CPPFLAGS = -I@kernelsrc@/include -I. -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DFUSE_VERSION=\"$(VERSION)\" @KERNELCPPFLAGS@

fuse_objs = dev.o dir.o file.o inode.o compat/parser.o

SUFFIXES = .c .o .s

all-spec: fuse.o

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

fuse.o: $(fuse_objs)
	$(LD) -r -o fuse.o $(fuse_objs)

fuse_headers = fuse_i.h fuse_kernel.h

dev.o: $(fuse_headers)
dir.o: $(fuse_headers)
file.o: $(fuse_headers)
inode.o: $(fuse_headers)

else

EXTRA_CFLAGS += -DFUSE_VERSION=\"$(VERSION)\"

obj-m := fuse.o
fuse-objs := dev.o dir.o file.o inode.o

all-spec:
	$(MAKE) -C @kernelsrc@ SUBDIRS=$(PWD) @KERNELMAKE_PARAMS@ modules
endif
