#
#       Copyright (C) 1993 Bas Laarhoven.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# $Source: /usr/src/distr/ftape-1.13b/RCS/Makefile,v $
# $Author: bas $
#
# $Revision: 1.31 $
# $Date: 1994/06/30 18:38:59 $
# $State: Beta $
#
#      Makefile for the QIC-40/80 floppy-tape driver for Linux.
#

#  Valid ftape options are:
#       CONNER_BUG      - set if using tapes formatted with Conner's DOS tool.
#       NO_TRACE        - if defined, only information and errors show up.
#       NO_TRACE_AT_ALL - if defined, no trace output shows up.
#       GCC_2_4_5_BUG   - must be set if using gcc-2.4.5 to prevent
#                         bad code being generated.
#       SLOW_STARTER    - set if motor start/stop timing is long causing
#                         no_data errors when starting tape.
#       VERIFY_HEADERS  - if set the headers segments are verified after
#                         being written.
#       FAST_SEEK       - if set will use the fast seek algorithm
#       PROBE_FC10      - if defined will look for a FC-10 card at specified
#                         settings (FDC_BASE,FDC_IRQ,FDC_DMA) before using
#                         the standard fd controller.
#       FDC_BASE        - set base address (only!) if using non-standard fdc
#       FDC_IRQ         - set interrupt if FDC_BASE defined
#       FDC_DMA         - set dma channel if FDC_BASE defined
#       FLOPPY_HACK     - must be set if floppy.c code isn't patched to
#                         release dma and irq when not in use.
#       DATA_RATE       - the driver will select the highest available rate
#                         this can be overruled by setting DATA_RATE to 0..3
#                         corresponding with 2000,1000,500 and 250 Kbps.
#
# 
FTAPE_OPT       = -DVERIFY_HEADERS -DFAST_SEEK
# enable if tape drive on CMS FC-10 controller:
FDC_OPT         = -DPROBE_FC10 -DFDC_BASE=0x180 -DFDC_IRQ=9 -DFDC_DMA=5
# enable if tape drive on secondary floppy disk controller:
#FDC_OPT         = -DFDC_BASE=0x370 -DFDC_IRQ=6 -DFDC_DMA=2

KERNEL_OPT      = -D__KERNEL__ -DKERNEL -DLINUX
WARNINGS        = -Wall -Wstrict-prototypes
COMPILE         = -pipe -fomit-frame-pointer -m486 -O6
DEBUG           = -g

CFLAGS = $(DEBUG) $(WARNINGS) $(COMPILE) $(FTAPE_OPT) $(FDC_OPT) $(KERNEL_OPT)
SFLAGS = -fverbose-asm $(WARNINGS) $(COMPILE) $(FTAPE_OPT) $(FDC_OPT) $(KERNEL_OPT)

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

.c.s:
	$(CC) $(SFLAGS) -S $<

SRCS  = kernel-interface.c fdc-io.c fdc-isr.c ftape-rw.c tracing.c \
        ftape-read.c ftape-write.c ftape-io.c ftape-eof.c calibr.c \
        ecc.c fc-10.c

OBJS  = $(SRCS:.c=.o)

TST_SRCS = tecc.c ecc.c
TST_OBJS = tecc.o tst-ecc.o

driver: dep ftape.o Makefile
	sync
	- rmmod ftape
	insmod ftape.o

test:   tecc Makefile
	sync
	tecc -a

depend: dep

dep:	kernel-version.h .depend

.depend:	
	$(CPP) -M $(SRCS) > .depend

clean:
	- rm -f a.out *.o core *~ gen_test tecc kernel-version.h .depend

all:    driver test

ftape.o: $(OBJS) Makefile .depend
	ld -r -o $@ $(OBJS)

tst-ecc.o: ecc.c ecc.h ftape.h Makefile
	$(CC) $(CFLAGS) -DTEST -c -o $@ ecc.c

tecc:   tecc.c tst-ecc.o ftape.h Makefile
	$(CC) $(CFLAGS) -DTEST -o $@ tecc.c tst-ecc.o

kernel-version.h: Makefile
	echo "char kernel_version[] = \"`cat /proc/version | \
	cut -d" " -f3`\";" >kernel-version.h

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