# $Id: Makefile.in,v 1.5 2000/03/04 18:21:36 map Exp $

SHELL		= /bin/sh

srcdir		= @srcdir@
VPATH		= @srcdir@

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

MODULE		= xfs_reloc
MODULE_NAME	= xfs
MODULE_INSTANCE	= xfs_instance
MODULE_LOADABLE	= xfs_loadable

INCDEFS		= -I. -I$(srcdir) -I/usr/src/sys/arch -I/usr/src/sys \
		  -I../../include -I$(srcdir)/../../include \
		  -I/System/Library/Frameworks/Kernel.framework/Headers \
		  -I$(srcdir)/../include @KRB4_INC_FLAGS@

DEFS		= @DEFS@ $(INCDEFS) -DDEBUG -DDIAGNOSTIC -DUSE_SELECT \
		 -DKERNEL -D_KERNEL -DMACH_USER_API \
		 -DKERNEL_SERVER_INSTANCE=${MODULE_INSTANCE}

CFLAGS		= @CFLAGS@ -fno-common -Wno-format -pipe -finline \
		 -fno-keep-inline-functions -force_cpusubtype_ALL \
		 -msoft-float -mlong-branch -static
		 

SUBDIRS		= bin

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_info.c		\
		  xfs_wrap.c

MODULE_OBJC_SRCS	= xfs_instance.m

MODULE_OBJS	= $(MODULE_SRCS:.c=.o) # $(MODULE_OBJC_SRCS:.m=.o)

all:	$(MODULE)

$(MODULE):	$(MODULE_OBJS)
	$(LD) -r -lcc -o $(MODULE) \
		${MODULE_OBJS}

load:	$(MODULE)
	$(MODLOAD) -o xfs.debug $(MODULE)

unload:
	$(MODUNLOAD) $(MODULE_NAME)

mount:
	./bin/mount_xfs /dev/xfs0 /afs

umount:
	./bin/umount_xfs /afs

device:
	mknod /dev/xfs0 c 1 0

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

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

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

Makefile: Makefile.in ../../config.status
	cd ../.. ; CONFIG_FILES=xfs/rhapsody/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_LOADABLE) $(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
