#
#       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-0.9.10/RCS/Makefile,v $
# $Author: bas $
#
# $Revision: 1.23 $
# $Date: 1994/02/20 15:26:55 $
# $State: Alpha $
#
#      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.
#FTAPE_OPT       = -DGCC_2_4_5_BUG -DVERIFY_HEADERS -DSLOW_STARTER
FTAPE_OPT       = -DVERIFY_HEADERS -DSLOW_STARTER
KERNEL_OPT      = -D__KERNEL__ -DKERNEL -DLINUX
WARNINGS        = -Wall -Wstrict-prototypes
COMPILE         = -pipe -fomit-frame-pointer -m486 -O6
DEBUG           = 

CFLAGS = $(DEBUG) $(WARNINGS) $(COMPILE) $(FTAPE_OPT) $(KERNEL_OPT)
SFLAGS = -fverbose-asm $(WARNINGS) $(COMPILE) $(FTAPE_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
OBJS  = $(SRCS:.c=.o)

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

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

test:   tecc Makefile
	sync
	tecc -a

dep:	.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 .depend
	$(CC) $(CFLAGS) -o $@ tecc.c tst-ecc.o

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

.depend: kernel-version.h
	$(CPP) -M $(SRCS) > .depend

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