#
# Makefile for the kernel block device drivers.
#
# 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 definition is now inherited from the
# parent makefile.
#

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

#
# Note : at this point, these files are compiled on all systems. 
# In the future, some of these should be built conditionally.
#

OBJS := ll_rw_blk.o ramdisk.o genhd.o
SRCS := ll_rw_blk.c ramdisk.c genhd.c
BLOCK_MODULE_OBJS =

ifdef CONFIG_BLK_DEV_IDE
OBJS := $(OBJS) ide.o
SRCS := $(SRCS) ide.c
endif

ifdef CONFIG_AMIGA_Z2RAM
OBJS := $(OBJS) z2ram.o
SRCS := $(SRCS) z2ram.c
endif

ifdef CONFIG_BLK_DEV_FD
ifdef CONFIG_AMIGA
OBJS := $(OBJS) amiflop.o
SRCS := $(SRCS) amiflop.c
endif
ifdef CONFIG_ATARI
OBJS := $(OBJS) ataflop.o
SRCS := $(SRCS) ataflop.c
endif
else 
ifdef CONFIG_AMIGA
BLOCK_MODULE_OBJS += amiflop.o
endif
endif

ifdef CONFIG_ATARI_SLM
OBJS := $(OBJS) acsi_slm.o
SRCS := $(SRCS) acsi_slm.c
endif

ifdef CONFIG_ATARI_ACSI
OBJS := $(OBJS) acsi.o
SRCS := $(SRCS) acsi.c
endif

all: block.a

block.a: $(OBJS)
	rm -f block.a
	$(AR) rcs block.a $(OBJS)
	sync

dep:
	$(CPP) -M $(SRCS) > .depend
ifdef BLOCK_MODULE_OBJS
	$(CPP) -M -DMODULE $(BLOCK_MODULE_OBJS:.o=.c) >> .depend
endif

modules: $(BLOCK_MODULE_OBJS)
	echo $(BLOCK_MODULE_OBJS) > ../../modules/BLOCK_MODULES
ifdef BLOCK_MODULE_OBJS
	(cd ../../modules;for i in $(BLOCK_MODULE_OBJS); do ln -sf ../drivers/block/$$i .; done)
endif

dummy:

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