###############################################################################
#
#       Copyright (C) 1997 Claus Heine.
#
# 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: /homes/cvs/ftape-stacked/MCONFIG,v $
# $Revision: 1.44 $
# $Date: 1997/11/07 14:33:56 $
#
#     Compile time configuration for the QIC-40/80/3010/3020 ftape
#     driver for Linux
#
###############################################################################

###############################################################################
#
# Pathnames. These should work just fine.
#
# change the following to point to the start of your kernel source tree:
#

# IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT

LINUX_LOCATION = /usr/src/linux

#
# Ok. It looks ugly. It is ugly.
#

KERNEL_VERSION = $$(grep UTS_RELEASE $(LINUX_LOCATION)/include/linux/version.h|cut -d '"' -f 2)


#
# Change the following to point to the directory where you want the 
# modules to be installed.
#

MODULESDIR = /lib/modules/$(KERNEL_VERSION)/misc

#
# This is a path prefix prepended to the installation paths for the
# helper utilities and scripts.
#
# NOTE: This used to be /usr rather than /usr/local in previous
#       versions

PREFIX = /usr
# PREFIX = /usr/local

#
# Change the following to point to the directory where you want the 
# swapout, ftformat and vtblc utilities to be installed.
#
# NOTE: ftformat and vtblc and swapout used to be installed in /sbin
#       in previous versions.
#

SBINDIR = /sbin
# SBINDIR = $(PREFIX)/sbin

#
# Change the following to point to the directory where you want
# the mt program and the listtape scripts to be installed.
#

BINDIR = $(PREFIX)/bin

#
# IMPORTANT NOTE: if you don't like to install the documentation at
# all then please comment out the INFODIR and/or DOCDIR variables,
# i.e. add a `#' sign right at the beginning of the respective line.
#

#
# Change the following to point to the directory where you want the info 
# documentation to be installed in
#

INFODIR = $(PREFIX)/info

#
# The html and dvi version of the manual will be installed under the
# following directory:
#

DOCDIR = $(PREFIX)/doc/ftape

#
# The  manual pages (if any) will be installed below this directory:
#

MANDIR = $(PREFIX)/man

#
###############################################################################

###############################################################################
# IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT #
###############################################################################
#
# Get the configuration of the kernel ftape is compiled for.
#
# This will only work with a configured kernel, but we need a fully
# configured kernel anyways?? If `$(LINUX_LOCATION)/.config' DOESN'T
# exist you'll need to set the variables of the "else" part of the
# "ifeq" clause according to the configuration of the kernel you want
# ftape to use with. If `$(LINUX_LOCATION)/.config' exists you can
# skip this part and go on with the hardware configuration options
# below.
#
#

ifeq ($(LINUX_LOCATION)/.config,$(wildcard $(LINUX_LOCATION)/.config))
include $(LINUX_LOCATION)/.config
else

#
# If the file `$(LINUX_LOCATION)/.config' doesn't exists, then try to
# tune the parameters in this "else" part of the "ifeq" clause above
# to fit your setup. 
#
# If you attempt to use CONFIG_MODVERSIONS then make sure that
# `$(LINUX_LOCATION)/include/linux/modversions.h' REALLY
# EXISTS. Otherwise, don't use CONFIG_MODVERSIONS.
#
# You should also set the CONFIG_M386/486/586/686 according to your
# processor type. When running an DEC alpha then comment out the
# CONFIG_M486=y line and uncomment the CONFIG_ALPHA=y line.
#

#CONFIG_M386=y
CONFIG_M486=y
#CONFIG_M586=y
#CONFIG_M686=y
#CONFIG_MAMDK6
#CONFIG_ALPHA=y
#CONFIG_MODVERSIONS=y

#
# DON'T touch the following two lines! To enable/disable the procfs
# interface you should uncomment/comment out the CONFIG_FT_PROC_FS
# option below and leave the CONFIG_PROC_FS option ENABLED.
#

CONFIG_PROC_FS=y
CONFIG_MODULES=y

endif

#
###############################################################################

###############################################################################
# IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT #
###############################################################################
#
# You MUST uncomment the following line if you are running a SMP
# (multi-processor) system
#
#SMP = 1
#
###############################################################################

###############################################################################
# IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT  IMPORTANT #
###############################################################################
#
# Hardware configuration for the floppy tape drive.
#
# You need to take care of the following options if you didn't connect
# your floppy tape to the standard floppy controller, i.e. if you
# didn't plugged the floppy tape into the floppy controller already
# contained in your computer system.
#
# Short description of available options
# (`FDC' stands for `Floppy Disk Controller')
#
#       PROBE_FC10      - if defined will look for a FC-10 (or FC-20)
#                         card at specified settings
#                         (FDC_BASE,FDC_IRQ,FDC_DMA) before using the
#                         standard fd controller.
#       FDC_BASE        - sets base address if using non-standard fdc
#       FDC_IRQ         - sets interrupt if FDC_BASE is defined
#       FDC_DMA         - sets dma channel if FDC_BASE is defined
#       MACH2           - Support for Mountain MACH-2 controller. You
#                         have to specify its base address (either
#                         0x1E0 or 0x3E0). 
#       CLK_48MHZ       - must be defined and set to 0 if your 82078
#                         is _not_ being run from a 48 Mhz clock
#                         oscillator. Normally you don't need to worry
#                         about it.
#
# If you're using a non-standard floppy disk controller for the tape
# drive, enable one (only!) of the following lines and set the
# FDC_BASE, FDC_IRQ and FDC_DMA parameters to the actual values.
#
# `enable' means: `uncomment one of the lines starting with
# "FDC_OPT = ..."'. `uncomment' means: remove the leading `#'
#
# The following values hopefully reflect the default settings for
# those controllers.
#
# Note1: A FC-10/FC-20 controller must use either of DMA 1, 2, or 3.
#        DMA 5 and 7 does NOT work!.
#
# Note2: IRQ 2 and IRQ 9 can be considered the same. When using IRQ 2
#        on a controller you must specify IRQ 9 here!
#
# For a Mountain MACH-2 controller, try
#
#FDC_OPT =	-DCONFIG_FT_MACH2		\
		-DCONFIG_FT_FDC_BASE=0x1E0	\
		-DCONFIG_FT_FDC_IRQ=6		\
		-DCONFIG_FT_FDC_DMA=2
#
# For Colorado CMS FC-10 or FC-20 controllers:
#
#FDC_OPT =	-DCONFIG_FT_PROBE_FC10		\
		-DCONFIG_FT_FDC_BASE=0x180	\
		-DCONFIG_FT_FDC_IRQ=9		\
		-DCONFIG_FT_FDC_DMA=3
#
# Secondary floppy disk controller:
# including Ditto Dash 2Mbps controller, ExaByte accelerator card,
# CTC-2Mb (Seagate) and hopefully any 82078 based FDC controller card.
#
#FDC_OPT =	-DCONFIG_FT_FDC_BASE=0x370	\
		-DCONFIG_FT_FDC_IRQ=6		\
		-DCONFIG_FT_FDC_DMA=2
#
# Maybe one of the following alternatives work if you have a Ditto
# Dash and the above setting doesn't work:
#
#FDC_OPT =	-DCONFIG_FT_FDC_BASE=0x370	\
		-DCONFIG_FT_FDC_IRQ=5		\
		-DCONFIG_FT_FDC_DMA=3
#FDC_OPT =	-DCONFIG_FT_FDC_BASE=0x370		\
		-DCONFIG_FT_FDC_IRQ=2			\
		-DCONFIG_FT_FDC_DMA=3 
#
###############################################################################

###############################################################################
#
# Generic ftape options.
#
# Valid ftape options are:
#
# GCC_2_4_5_BUG         - must be set if using gcc-2.4.5 to prevent
#                         bad assembler-code for the dma handling.
#
# CONFIG_FT_NR_BUFFERS  - Number of ftape DMA buffers (keep it at 3!)
#
# CONFIG_FT_ALPHA_CLOCK - must set to CPU clock frequency in Hz on
#                         Alpha's (this is a special type of computer
#                         as is an Intel 80x86 or a Sparc or a Mips
#                         something or ... )
#
# CONFIG_FT_PROC_FS     - enables proc interface (read-only) to provide
#                         information about kind of tape drive, data
#                         rate etc. Consumes about 2 kb of memory.
#                         Make sure to read the file `BUGS' before
#                         enabling this option. THIS WILL NOT WORK WITH
#                         1.2.13 (and older) kernels.
#
# BROKEN_FLOPPY_DRIVER  - leave this defined if you DON'T apply the patch
#                         `patches/2.x.x/floppy.c.dif' to the floppy
#                         driver of the standard kernel distribution.
#                         If you DON'T apply my patch, then you
#                         definitely need this switch if you want to
#                         create an emergency (rescue) disk with
#                         ftape.
#
# TESTING               - Guess what? Never use this for normal use !!!
#

FTAPE_OPT  = -DTHE_FTAPE_MAINTAINER=\"claus@momo.math.rwth-aachen.de\" \
	     -DCONFIG_FT_NR_BUFFERS=3
FTAPE_OPT += -DBROKEN_FLOPPY_DRIVER
#FTAPE_OPT += -DCONFIG_FT_PROC_FS

#
###############################################################################

###############################################################################
#
# Options that affect the amount of debugging messages printed to the
# system console (or kernel log files). Also reduces the size of the
# driver.
#
#  CONFIG_FT_NO_TRACE        - if defined, only information and errors
#                              show up.
#   
#  CONFIG_FT_NO_TRACE_AT_ALL - if defined, no trace output shows up.
#

TRACE_FLAGS = # -DCONFIG_FT_NO_TRACE # -DCONFIG_FT_NO_TRACE_AT_ALL

#
###############################################################################

###############################################################################
#
# Compiler options for your architecture
#
# ... in case you need any special options ...
#

# ARCH_OPT = 

#
###############################################################################

###############################################################################
#
#  Don't change anything below this point!!!!
#  
#  Unless you know what you are doing. Don't expect me to help you.
#

ifeq ($(CONFIG_MODULES),n)
ERROR_RULE:
	@echo
	@echo "*************************************************"
	@echo
	@echo "Please reconfigure your kernel to support runtime"
	@echo "loadable modules. Retry making ftape afterwards."
	@echo
	@echo "*************************************************"
	@echo
	exit 1
endif

#
# MODVERSIONS and MODULES stuff
#
MAKING_MODULES  = 1
MODULE_OPT      = -DMODULE
ifeq ($(CONFIG_MODVERSIONS),y)
MODULE_OPT     += -DMODVERSIONS
MODULE_OPT     += -include $(LINUX_LOCATION)/include/linux/modversions.h
MODULE_OPT     += -include $(TOPDIR)/include/linux/modversions.h
GENKSYMS        = /sbin/genksyms
endif

#
# assemble the compile time options 
#
CONFIG_OPT := $(FTAPE_OPT) $(FDC_OPT) $(TRACE_FLAGS) 
CONFIG_OPT += -DCONFIG_FTAPE_MODULE
CONFIG_OPT += -DCONFIG_ZFTAPE_MODULE
CONFIG_OPT += -DCONFIG_ZFT_COMPRESSOR_MODULE
override CONFIG_FTAPE          := m
override CONFIG_ZFTAPE         := m
override CONFIG_ZFT_COMPRESSOR := m
ifneq ($(findstring, CONFIG_FT_PROC_FS,$(FTAPE_OPT)),"")
CONFIG_FT_PROC_FS              := y
endif

#
# options needed to compile kernel source
#
INCLUDE_PATH   := -I. -I$(TOPDIR)/include -I$(LINUX_LOCATION)/include
KERNEL_OPT     := -D__KERNEL__ $(INCLUDE_PATH)
ifdef SMP
KERNEL_OPT     += -D__SMP__
endif
#
# processor specific options.
#
ifdef CONFIG_M386
KERNEL_OPT     += -m386 -DCPU=386
endif
ifdef CONFIG_M486
KERNEL_OPT     += -m486 -DCPU=486
endif
ifdef CONFIG_M586
KERNEL_OPT     += -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=586
endif
ifdef CONFIG_M686
KERNEL_OPT     += -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686
endif
ifdef CONFIG_MAMDK6
KERNEL_OPT     += -mamdk6 -frisc
endif

WARNINGS        = -Wall -Wstrict-prototypes
COMPILE         = -O2 $(ARCH_OPT) -fomit-frame-pointer -fno-strength-reduce
LD_OPT	        = -r -S

ifdef CONFIG_ALPHA
#
#  The -dc flag is needed when using BFD insmod on an alpha !
#  You should probably also remove -m486 when compiling on the alpha.
#
LD_OPT         += -dc
endif

CC              = gcc

#
# these are the flags referred to by the make rules in Rules.make.
# 
GKSFLAGS  = $(CONFIG_OPT) $(KERNEL_OPT) $(EXTRA_CFLAGS)
CPPFLAGS  = $(CONFIG_OPT) $(MODULE_OPT) $(KERNEL_OPT) $(EXTRA_CFLAGS)
CFLAGS    = $(WARNINGS) $(COMPILE) $(CPPFLAGS)
SFLAGS    = -fverbose-asm $(CFLAGS)
EXTRA_LDFLAGS = $(LD_OPT)

INSTALL  = install -c -o root -g root

#
#  end of MCONFIG
#
################################################################################ 
# LocalWords:  cvs ftape MCONFIG QIC Linux usr src linux Ok UTS ifeq config FS
# LocalWords:  wildcard MODVERSIONS modversions PROC MAMDK endif MODULESDIR lib
# LocalWords:  misc swapout kdtime SBINDIR sbin INFODIR DOCDIR html dvi doc SMP
# LocalWords:  MANDIR FDC FC IRQ DMA fd fdc dma CLK Mhz DCONFIG CMS Mbps CTC Mb
# LocalWords:  ExaByte GCC gcc NR Sparc Mips proc kb dif DTHE claus momo rwth
# LocalWords:  aachen DBROKEN DMODULE DMODVERSIONS TOPDIR GENKSYMS genksyms ZFT
# LocalWords:  ZFTAPE ifneq findstring ifdef DCPU mamdk frisc Wstrict fomit fno
# LocalWords:  LD dc BFD insmod CC GKSFLAGS CFLAGS CPPFLAGS SFLAGS fverbose asm
# LocalWords:  LDFLAGS ftformat procfs LocalWords
