# Makefile for the Linux iSCSI driver
# Copyright (C) 2001 Cisco Systems, Inc.
#
# 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 of the License, 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.
#
# See the file COPYING included with this distribution for more details.

# All of the (potential) objects that export symbols.
# This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
export-objs	:=

EXTRA_CFLAGS	+= -I. -I$(TOPDIR)/drivers/scsi -I include -I driver/include \
			-I common/auth -I common/login -I misc/include \
			 -DLINUX -DUSE_SPINLOCK_HOST_LOCK

# Simple targets to be included in main kernel
O_TARGET	:=

# Targets that can be compiled either into the kernel or as modules
obj-$(CONFIG_SCSI_ISCSI) := iscsi_mod.o

# Multipart targets
list-multi	:= iscsi_mod.o
iscsi_mod-objs	:= driver/iscsi.o driver/iscsi-probe.o common/login/iscsi-login.o \
		   common/auth/iscsiAuthClient.o common/auth/iscsiAuthClientGlue.o \
		   misc/md5.o driver/iscsi-crc.o

# Set some flags depending on kernel - in case we upgrade the COS
ifeq ($(wildcard $(TOPDIR)/kernel/ksyms.c),$(TOPDIR)/kernel/ksyms.c)
  # check for the presence of certain kernel symbols, and compile accordingly

  SET_USER_NICE:=$(shell $(TC_GREP) '^[ \t]*EXPORT_SYMBOL(set_user_nice)' $(TOPDIR)/kernel/ksyms.c 2>/dev/null )
  ifneq ($(SET_USER_NICE),)
    EXTRA_CFLAGS  += -DHAS_SET_USER_NICE=1
  endif

  REPARENT_TO_INIT:=$(shell $(TC_GREP) '^[ \t]*EXPORT_SYMBOL(reparent_to_init)' $(TOPDIR)/kernel/ksyms.c 2>/dev/null )
  ifneq ($(REPARENT_TO_INIT),)
    EXTRA_CFLAGS += -DHAS_REPARENT_TO_INIT=1
  endif
endif

# Module parts in subdirectories that needs to be build first
mod-subdirs	:= 

include $(TOPDIR)/Rules.make

clean:
	rm -f core *.o *.a *.s *.d *.dep

# Link rules for multi-part drivers.

# link the iSCSI kernel module
iscsi_mod.o: $(iscsi_mod-objs)
	$(LD) -r -o $@ $(iscsi_mod-objs)
