#
# Makefile for the linux nfs-filesystem routines.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile...


CFLAGS = -Wall -Wstrict-prototypes -O2 -DMODULE -fomit-frame-pointer \
         -DDEBUG_SMB=1 -DDEBUG_SMB_MALLOC
#         -DDEBUG_SMB_MALLOC

CC     = gcc -D__KERNEL__ -I.
AS     = as
ARCH   = i386

.c.s:
	$(CC) $(CFLAGS) -S $<
.c.o:
	$(CC) $(CFLAGS) -c $<
.s.o:
	$(AS) -o $*.o $<

OBJS=	inode.o dir.o file.o proc.o sock.o mmap.o ioctl.o

all: smbfs.o smbmount smbumount

smbfs.o: $(OBJS)
	$(LD) -r -o smbfs.o $(OBJS)

smbmount: smbmount.o
	gcc -o smbmount smbmount.o

smbmount.o: smbmount.c
	gcc -c -g smbmount.c -Wall -I.

smbumount: smbumount.o
	gcc -o smbumount smbumount.o 

smbumount.o: smbumount.c
	gcc -c -g smbumount.c -Wall -I.

dep:
	$(CPP) -M *.c > .depend

install: all
	REL=`grep UTS_RELEASE /usr/include/linux/version.h | \
	sed -e 's/.*\"\(.*\)\".*/\1/'` ; \
	mkdir -p /lib/modules/$$REL; \
	install -d -o root -g root -m 755 /lib/modules/$$REL; \
	install -o root -g root -m 755 smbfs.o /lib/modules/$$REL; \
	install -o root -g root -m 755 smbmount /sbin; \
	install -o root -g root -m 444 smbmount.8 /usr/man/man8 \
	install -o root -g root -m 755 smbumount /sbin; \
	install -o root -g root -m 444 smbumount.8 /usr/man/man8

SRCPATH=$(shell pwd)
SRCDIR=$(shell basename $(SRCPATH))
DISTFILE=$(SRCDIR).tgz
BACKUPFILE=ksmbfs02.tgz
HOME=/home/me

clean:
	rm -f *.o *~

realclean: clean
	rm -fr smbmount smbumount .depend $(DISTFILE) mnt

modules: smbfs.o

backup: 
	(rm -f $(DISTFILE); cd ..; tar cvf - $(SRCDIR) | gzip -1 \
          > $(HOME)/tarz/backup/$(BACKUPFILE))
	(cd $(HOME)/tarz/backup; ls -l $(BACKUPFILE); mcopy $(BACKUPFILE) a:)

dist: realclean
	(cd ..; \
         mv $(SRCDIR)/RCS .; \
         tar cvf - $(SRCDIR) | \
            gzip -9 > $(DISTFILE); \
         mv RCS $(SRCDIR); \
         mv $(DISTFILE) $(SRCDIR))

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
