#
#       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.9d/RCS/Makefile,v $
# $Author: bas $
#
# $Revision: 1.16 $
# $Date: 1994/01/16 17:20:10 $
# $State: ALPHA $
#
#      Makefile for the QIC-40/80 floppy-tape driver for Linux.
#

# 
# Uncomment the following line if you used g++ to compile the kernel
# KERNEL_LANGUAGE_OPT = -DKERNEL_CPP_COMPILED -x c++

#  Valid ftape options are:
#       CONNER_BUG      - define if problems with Conner formatted tapes.
#       FDC_UNIT_SELECT - define if drive needs fdc unit select signal.
#       RETRY_HACK      - must allways be defined.
#       NO_TRACE        - if defined, only information and errors show up.
#       NO_TRACE_AT_ALL - if defined, no trace output shows up.
#       TESTING         - turn off if you get problems during writing.
FTAPE_OPT = -DRETRY_HACK -DTESTING

KERNEL_OPT = -D__KERNEL__ -DKERNEL -DLINUX
WARNINGS = -Wall -Wstrict-prototypes
COMPILE = -pipe -fomit-frame-pointer -m486 -O6 $(KERNEL_LANGUAGE_OPT)
DEBUG = 

CFLAGS = $(DEBUG) $(WARNINGS) $(COMPILE) $(FTAPE_OPT) $(KERNEL_OPT)

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

test: tecc Makefile
	sync
	tecc -a

all: driver test

ftape.o: ftape-rw.o kernel-interface.o fdc-io.o ecc.o ftape-io.o \
	calibr.o Makefile
	ld -r -o ftape.o kernel-interface.o ftape-rw.o fdc-io.o \
	ftape-io.o ecc.o calibr.o

fdc-io.o : fdc-io.c fdc-io.h Makefile \
        ftape-io.h ftape-rw.h kernel-interface.h 
	$(CC) $(CFLAGS) -c -o fdc-io.o fdc-io.c

ftape-io.o : ftape-io.c ftape-io.h Makefile \
        fdc-io.h qic117.h ftape-rw.h kernel-interface.h vendors.h
	$(CC) $(CFLAGS) -c -o ftape-io.o ftape-io.c

ecc.o : ecc.c ecc.h Makefile \
        fdc-io.h
	$(CC) $(CFLAGS) -c -o ecc.o ecc.c -DECC_SANITY_CHECK

ftape-rw.o : ftape-rw.c ftape-rw.h Makefile \
        fdc-io.h kernel-interface.h qic117.h ftape-io.h ecc.h
	$(CC) $(CFLAGS) -c -o ftape-rw.o ftape-rw.c

kernel-interface.o : kernel-interface.c kernel-interface.h Makefile \
        fdc-io.h ftape-io.h ftape-rw.h kernel-version.h
	$(CC) $(CFLAGS) -c -o kernel-interface.o kernel-interface.c

calibr.o : calibr.c calibr.h Makefile \
        fdc-io.h 
	$(CC) $(CFLAGS) -c -o calibr.o calibr.c

ecc-test.o : ecc.c ecc.h fdc-io.h Makefile
	$(CC) $(CFLAGS) -c -o $@ ecc.c -DTEST -DECC_PARANOID -DECC_SANITY_CHECK

tecc.o : tecc.c ecc.h fdc-io.h Makefile
	$(CC) $(CFLAGS) -c -o $@ tecc.c

tecc : tecc.o ecc-test.o Makefile 
	$(CC) $(CFLAGS) -o $@ tecc.o ecc-test.o

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

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