# $Id: Makefile.in,v 1.4 1998/02/19 22:27:01 art Exp $

SHELL		= /bin/sh

srcdir		= @srcdir@
VPATH		= @srcdir@

CC		= @CC@
LD		= ld
SYMORDER	= @SYMORDER@
MODLOAD		= modload
MODUNLOAD	= modunload
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)

INCDEFS		= -I. -I$(srcdir) -I/usr/src/sys/arch -I/usr/src/sys \
		  -I../../include -I${srcdir}/../include \
		  -I@KRB_INC_DIR@

DEFS		= @DEFS@ $(INCDEFS) -DDEBUG -DDIAGNOSTIC \
		 -DKERNEL -D_KERNEL -DLKM -D_LKM -DACTUALLY_LKM_NOT_KERNEL
CFLAGS		= @CFLAGS@ -Wall -Wno-unused -O3

SYS		= /usr/src/sys

SUBDIRS		= bin

MODULE		= xfs_mod.o

MODULE_SRCS	= xfs_common.c			\
		  xfs_deb.c			\
		  xfs_dev.c			\
		  xfs_message.c			\
		  xfs_node.c			\
		  xfs_syscalls.c		\
		  xfs_vfsops.c			\
		  xfs_vnodeops.c		\
		  xfs_wrap.c

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

all:	vnode_if.h $(MODULE)

$(MODULE):	$(MODULE_OBJS)
	$(LD) -r -o tmp.o $(MODULE_OBJS)
	echo _xfs_mod > symb.tmp
	$(SYMORDER) -c symb.tmp tmp.o
	rm -f symb.tmp
	mv -f tmp.o xfs_mod.o

load:	$(MODULE)
	$(MODLOAD) -e xfs_mod -o /var/tmp/foo xfs_mod.o

unload:
	$(MODUNLOAD) -n xfs_mod

install: all
	$(MKINSTALLDIRS) $(bindir)
	PROG_BIN='$(XFS_BIN)'; for x in $$PROG_BIN; do \
		$(INSTALL_PROGRAM) $$x $(bindir)/`echo $$x | sed '$(transform)'`; \
	done
	cd bin && $(MAKE) $(MFLAGS) install


vnode_if.c: $(SYS)/kern/vnode_if.sh $(SYS)/kern/vnode_if.src
	$(SHELL) $(SYS)/kern/vnode_if.sh $(SYS)/kern/vnode_if.src
vnode_if.h: $(SYS)/kern/vnode_if.sh $(SYS)/kern/vnode_if.src
	-$(MKDIR) ../sys >/dev/null
	$(SHELL) $(SYS)/kern/vnode_if.sh $(SYS)/kern/vnode_if.src && \
	(test -f vnode_if.h || $(LN_S) ../sys/vnode_if.h vnode_if.h)

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

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 *~

mostlyclean: clean

distclean: clean

realclean: distclean

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

.PHONY: all load clean mostlyclean distclean realclean
