#/*******************************************************************
# * This file is part of the Emulex Linux Device Driver for         *
# * Fibre Channel Host Bus Adapters.                                *
# * Copyright (C) 2003-2005 Emulex.  All rights reserved.           *
# * EMULEX and SLI are trademarks of Emulex.                        *
# * www.emulex.com                                                  *
# *                                                                 *
# * This program is free software; you can redistribute it and/or   *
# * modify it under the terms of version 2 of the GNU General       *
# * Public License as published by the Free Software Foundation.    *
# * This program is distributed in the hope that it will be useful. *
# * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
# * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
# * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
# * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
# * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
# * more details, a copy of which can be found in the file COPYING  *
# * included with this package.                                     *
# *******************************************************************/
######################################################################

#$Id: Makefile 2912 2006-04-15 23:15:36Z sf_support $

ifeq (,$(KERNELVERSION))
   KERNELVERSION := $(shell uname -r)
endif

ifeq (,$(BASEINCLUDE))
   BASEINCLUDE := /lib/modules/$(KERNELVERSION)/build
endif

ifneq ($(GCOV),)
  EXTRA_CFLAGS += -fprofile-arcs -ftest-coverage
  EXTRA_CFLAGS += -O0
  export EXTRA_CFLAGS
endif

ifeq ($(OS),RHEL)
  EXTRA_CFLAGS += -DRHEL_FC
  # later RHEL 4 (Update 3) kernels have some changes to the FC tranport
  # which we check for here
  TRANS_FC_FILE := ${BASEINCLUDE}/include/scsi/scsi_transport_fc.h
  ifneq (,$(shell grep "issue_fc_host_lip" ${TRANS_FC_FILE}))
    EXTRA_CFLAGS += -DRHEL_U3_FC_XPORT
  endif

  # later RHEL 4 kernels have diskdump changes
  DISK_DUMP_FILE := ${BASEINCLUDE}/include/linux/diskdump.h
  ifneq (,$(shell grep "spin_unlock_irq_dump" ${DISK_DUMP_FILE}))
    EXTRA_CFLAGS += -DDISKDUMP_FC
  endif
else
ifeq ($(OS),SLES)
  EXTRA_CFLAGS += -DSLES_FC
else
ifneq ($(OS),)
  $(error Error: either "make OS=RHEL" or "make OS=SLES" must be specified !!!)
else
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),install)
  $(error Error: either "make OS=RHEL" or "make OS=SLES" must be specified !!!)
endif
endif
endif
endif

  export EXTRA_CFLAGS
endif


obj-$(CONFIG_SCSI_LPFC) := lpfc.o

lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o \
lpfc_hbadisc.o lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o lpfc_scsiport.o \
lpfc_fcp.o

# Building for 2.6 kernel

clean-files := *.o *.ko *.mod.o *.mod.c .*.cmd .*.flags .tmp_versions

build:
	$(MAKE) -C $(BASEINCLUDE) SUBDIRS=`pwd` CONFIG_SCSI_LPFC=m modules 

install:
	@rm -f /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc.ko
	install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc
	install -c lpfc.ko /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc
	depmod -a

clean:
#	$(MAKE) -C $(BASEINCLUDE) SUBDIRS=$(PWD) CONFIG_SCSI_LPFC=m clean
	rm -rf $(clean-files) 
