#
# Makefile 1.5.1   April 30, 2002
#
#
# 1. To make UP version of ISP2200 driver
#  make qla2200.o 
#
# 2. To make UP version of ISP2300 driver
#  make qla2300.o 
#
# 3. To make UP version of ISP2200 and ISP2300 drivers
#  make all 
#or 
#  make 
#
# To make SMP version of any of the above drivers
# append SMP=1 to one of the (3) make command lines above. 
#  make ... SMP=1
#
# To make a new firmware file (FILE must be a *.c file of the fw object)
#  make fw FILE2=2200tp.c
#

DRIVER=qla2200.o qla2300.o 

FILE2=2200tp.h
FILE3=2300tp.h

HOSTTYPE := $(shell uname -m)

#
# f/W include files
FWFILE2=ql2200_fw.h
FWFILE3=ql2300_fw.h
FWFILE2IP=ql2200ip_fw.h
FWFILE3IP=ql2300ip_fw.h

# Comment/uncomment the following line to enable/disable debugging
DEBUGFLAG=y
HSG80=n

QL_DEBUG=0x6

OSVER=linux-2.4

# Change it here or specify it on the "make" commandline
#(new)INCLUDEDIR = /lib/modules/`uname -r`/build/include
INCLUDEDIR = /usr/src/$(OSVER)/include

ifeq ($(DEBUGFLAG),y)
  DEBFLAGS = -O -g -DUDEBUG -DLINUX -Dlinux
else
  DEBFLAGS = -O2 -DLINUX -Dlinux
endif

CFLAGS = -D__KERNEL__ -DMODULE -Wall $(DEBFLAGS) -DINTAPI
#CFLAGS = -D__KERNEL__ -DMODULE -Wall $(DEBFLAGS)

ifeq ($(HSG80),y)
CFLAGS += -DCOMPAQ
endif


# set MODVERSIONS if the kernel uses it
VERSUSED = $(shell grep 'define CONFIG_MODVERSIONS' \
           $(INCLUDEDIR)/linux/autoconf.h | wc -l | sed 's/ //g')
VERSUSED = 1

ifeq ($(VERSUSED),1)
CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
endif

CFLAGS += -I$(INCLUDEDIR) -I$(INCLUDEDIR)/../drivers/scsi

ifeq ($(HOSTTYPE),i386)
CFLAGS += -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe -malign-loops=2 -malign-jumps=2 -malign-functions=2 \
-DCONFIG_X86_LOCAL_APIC -fno-strict-aliasing -fno-common \
-mpreferred-stack-boundary=2 -march=i386
endif

ifeq ($(HOSTTYPE),i486)
CFLAGS += -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe -malign-loops=2 -malign-jumps=2 -malign-functions=2 \
-DCONFIG_X86_LOCAL_APIC -fno-strict-aliasing -fno-common \
-mpreferred-stack-boundary=2 -march=i486
endif

ifeq ($(HOSTTYPE),i586)
CFLAGS += -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe -malign-loops=2 -malign-jumps=2 -malign-functions=2 \
-DCONFIG_X86_LOCAL_APIC -fno-strict-aliasing -fno-common \
-mpreferred-stack-boundary=2 -march=i586
endif

ifeq ($(HOSTTYPE),i686)
CFLAGS += -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe -malign-loops=2 -malign-jumps=2 -malign-functions=2 \
-DCONFIG_X86_LOCAL_APIC -fno-strict-aliasing -fno-common \
-mpreferred-stack-boundary=2 -march=i686
endif

ifeq ($(HOSTTYPE),ia64)
CFLAGS += -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe -DWORD_FW_LOAD
endif

ifeq ($(HOSTTYPE),alpha)
CFLAGS += -D__alpha__ \
-Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce \
-pipe  -fno-strict-aliasing -mno-fp-regs -ffixed-8 -mcpu=ev56 -Wa,-mev6
endif

ifeq ("1","$(IP)")
CFLAGS += -DFC_IP_SUPPORT  
endif

ifeq ("1","$(SMP)")
CFLAGS += -D__SMP__  -DCONFIG_SMP  
endif

COFLAGS = -kv

MPATH = /lib/modules

SRC_FILES=qla_settings.h qla2x00.h qla2x00.c qla_cfg.c qla_cfg.h qla_cfgln.c \
qla_fo.h qla_fo.c qla_dbg.h qla_def.h qlfo.h qla2x00_ioctl.c qla_inioct.c \
qla_mbx.c qla_mbx.h qla_debug.h	makefile


#
# Where is all starts..
#
# -- default is always first.
default: $(DRIVER)

all:	$(DRIVER)

clean: 
	rm -f $(DRIVER)

install: $(DRIVER) 
	REL=`uname -r | \
	  sed -e 's/.*\"\(.*\)\".*/\1/'` ; \
	cp -p $(DRIVER) /lib/modules/$$REL/kernel/drivers/scsi

fw:
	mv $(FILE2) $(FWFILE2)
	mv $(FILE3) $(FWFILE3)

qla2200.o  : $(SRC_FILES) $(FWFILE2)
	$(CC) $(CFLAGS) -c qla2200.c -o $@

qla2300.o  : $(SRC_FILES) $(FWFILE3)
	$(CC) $(CFLAGS) -c qla2300.c -o $@

# @echo "Editing file to produce -> [isp_fw.h]"
# sh do_fw.sh $(FILE) cvtfw
# @echo "Editing file to produce -> [isp1_fw.h]"
# sh do_fw.sh $(FILE2) cvtfw22
