TOP	= ..
HDRS	= $(TOP)/crash.h $(TOP)/def.h
CSRCS	= table.c clean_sched.c clean_size.c clean_module.c clean_sem.c\
	  clean_fs.c clean_buffer.c buffer.c inode.c file.c\
	  operations.c clean_slab.c slab.c clean_mm.c page.c clean_mmzone.c\
	  block_device.c clean_route.c route.c clean_ext2.c\
	  ext2.c timer_vec.c clean_usb.c usb.c clean_neigh.c neighbour.c\
	  clean_blkdev.c blkdev.c clean_namespace.c namespace.c vfsmount.c\
	  clean_net.c socket.c dentry.c vm.c clean_vm.c clean_binfmts.c\
	  binfmts.c clean_swap.c swap.c clean_timer.c clean_nfs.c nfs.c\
	  clean_mempool.c mempool.c clean_bio.c bio.c clean_device.c\
	  device.c signal.c clean_tty.c tty.c user.c clean_genhd.c

include	$(TOP)/Rules.make

OBJS	= $(CSRCS:.c=.o)
INCLUDE	= -I$(TOP) -I$(INCDIR) -I$(KERNELDIR)
ifeq ($(ARCH),i386)
INCLUDE	+= -I$(KERNELDIR)/include/asm/mach-default
endif
CFLAGS	= $(CDEBUG) $(INCLUDE)
TARGET	= libmcrash.a
DEPFILE	= Makefile.dep

GENHEAD	= slab.h flags_fs.h flags_mm.h flags_sched.h flags_vmalloc.h\
	  flags_gfp.h flags_nfs_fs.h flags_nfs_fs_sb.h flags_nfs_mount.h\
	  flags_signal.h flags_genhd.h flags_socket.h

all:	$(GENHEAD) $(TARGET)

$(TARGET): $(OBJS)
	$(AR) cr $(TARGET) $(OBJS)

$(OBJS): $(HDRS)

slab.h:
	$(TOP)/script/gethead $(KERNELDIR)/mm/slab.c > slab.h

flags_fs.h:
	$(TOP)/script/bitname sflags:MS_ fsflags:FS_ flflags:FL_ istate:I_ $(KERNELDIR)/include/linux/fs.h > $@

flags_mm.h:
	$(TOP)/script/bitname pgflags:PG_:1 $(KERNELDIR)/include/linux/page-flags.h > $@

flags_sched.h:
	$(TOP)/script/bitname tsflags:PF_ $(KERNELDIR)/include/linux/sched.h > $@

flags_vmalloc.h:
	$(TOP)/script/bitname vsflags:VM_ $(KERNELDIR)/include/linux/vmalloc.h > $@

flags_gfp.h:
	$(TOP)/script/bitname gfpbit:__GFP_ $(KERNELDIR)/include/linux/gfp.h > $@

flags_nfs_fs.h:
	$(TOP)/script/bitname nflags:NFS_INO_ $(KERNELDIR)/include/linux/nfs_fs.h > $@

flags_nfs_fs_sb.h:
	$(TOP)/script/bitname $(KERNELDIR)/include/linux/nfs_fs_sb.h > $@

flags_nfs_mount.h:
	$(TOP)/script/bitname mflags:NFS_MOUNT_ $(KERNELDIR)/include/linux/nfs_mount.h > $@

flags_signal.h:
	$(TOP)/script/bitname saflags:SA_ $(KERNELDIR)/include/asm/signal.h > $@

flags_genhd.h:
	$(TOP)/script/bitname gdflags:GENHD_FL_ $(KERNELDIR)/include/linux/genhd.h > $@

flags_socket.h:
	$(TOP)/script/bitname soflags:SO_:1 $(KERNELDIR)/include/asm/socket.h > $@

clean:
	/bin/rm -f $(OBJS) $(TARGET) $(DEPFILE) *~ *.swp $(GENHEAD)

depend:
	makedepend -f- $(INCLUDE) $(CSRCS) > $(DEPFILE)

ifeq ($(wildcard $(DEPFILE)),$(DEPFILE))
include $(DEPFILE)
endif
