# $Id: Makefile.in,v 1.37 2000/05/14 02:29:40 assar Exp $

SHELL		= /bin/sh

srcdir		= @srcdir@
VPATH		= @srcdir@

KERNEL_CC	= @KERNEL_CC@
CC		= @CC@
LD		= ld
INSMOD		= insmod
RMMOD		= rmmod
MKDIR		= mkdir
RMDIR		= rmdir
LN_S		= @LN_S@
RM		= rm

INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS 	= @top_srcdir@/mkinstalldirs

prefix 		= @prefix@
exec_prefix 	= @exec_prefix@
libdir 		= @libdir@
libexecdir 	= @libexecdir@
bindir 		= @bindir@
transform	= @program_transform_name@
EXECSUFFIX	= @EXECSUFFIX@

XFS_BIN		= $(MODULE)

DEFS		= @DEFS@ @KERNEL_CFLAGS@ @KERNEL_CPPFLAGS@ -DDEBUG
INC		= -I$(srcdir)/../include \
		  -I../../include \
		  -I$(srcdir)/../../include
INCLUDES	= $(INC) @KRB4_INC_FLAGS@
CFLAGS		= -I. $(INCLUDES) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
KERNEL_LDFLAGS	= @KERNEL_LDFLAGS@

SUBDIRS		= bin

MODULE		= xfs.o

MODULE_SRCS	= xfs_load.c \
		  xfs_dev.c \
		  xfs_common.c \
		  xfs_vfsops.c \
		  xfs_node.c \
		  xfs_message.c \
		  xfs_inodeops.c \
		  xfs_deb.c \
		  xfs_syscalls.c

MODULE_OBJS	= $(MODULE_SRCS:.c=.o)

SHARED_LIBS	= libgetcwd.so

all:	$(MODULE) $(SHARED_LIBS)

$(MODULE):	$(MODULE_OBJS)
	$(LD) $(KERNEL_LDFLAGS) -r -o $(MODULE) $(MODULE_OBJS)

libgetcwd.so: getcwd.o
	$(LD) -shared -soname libgetcwd.so.0 -o $@ $<

load:	$(MODULE)
	$(INSMOD) -m xfs.o > xfs.map

unload:
	$(RMMOD) xfs

mount:
	mount -t xfs arla /afs

umount:
	umount /afs

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
	PROG_BIN='$(XFS_BIN)'; for x in $$PROG_BIN; do \
		f=`echo $$x | sed '$(transform)'`; \
		$(INSTALL_PROGRAM) $$x $(DESTDIR)$(bindir)/$$f; \
	done
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	PROG_LIB=$(SHARED_LIBS); for x in $$PROG_LIB; do \
		$(INSTALL_PROGRAM) $$x $(DESTDIR)$(libdir)/$$x.@VERSION@; \
	done
	cd bin && $(MAKE) $(MFLAGS) install

uninstall:
	PROG_BIN='$(XFS_BIN)'; for x in $$PROG_BIN; do \
		f=`echo $$x | sed '$(transform)'`; \
		rm -f $(DESTDIR)$(bindir)/$$f; \
	done
	PROG_LIB=$(SHARED_LIBS); for x in $$PROG_LIB; do \
		rm -f $(DESTDIR)$(libdir)/$$x.@VERSION@; \
	done
	cd bin && $(MAKE) $(MFLAGS) uninstall

.c.o:
	$(KERNEL_CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) $(CFLAGS) $<

getcwd.o: getcwd.c
	$(CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) $(CFLAGS) $<

Makefile: Makefile.in ../../config.status
	cd ../..; CONFIG_FILES=xfs/linux/Makefile CONFIG_HEADERS= $(SHELL) config.status

clean: doclean

# This is a workaround so subdirs can be made. 
# You can't have two command-sets for one target
doclean:
	$(RM) -f $(MODULE) *.o *~ libgetcwd.so

mostlyclean: clean

distclean: clean

realclean: distclean

all clean mostlyclean distclean realclean:
	SUBDIRS='$(SUBDIRS)'; \
	for i in $$SUBDIRS; \
	do (cd $$i && $(MAKE) $(MFLAGS) $@); done

.PHONY: all load clean mostlyclean distclean realclean install uninstall
