#
# Makefile for the kernel pcmcia subsystem (c/o David Hinds)
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definitions are now inherited from the
# parent makes..

SUB_DIRS     :=
MOD_SUB_DIRS := $(SUB_DIRS)
ALL_SUB_DIRS := $(SUB_DIRS)

obj-y		:=
obj-m		:=
list-multi	:=
export-objs	:=

SA1100_OBJS_y := sa1100_generic.o
SA1100_OBJS_$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o
SA1100_OBJS_$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o
SA1100_OBJS_$(CONFIG_SA1100_BITSY) += sa1100_bitsy.o
SA1100_OBJS_$(CONFIG_SA1100_CERF) += sa1100_cerf.o
SA1100_OBJS_$(CONFIG_SA1100_GRAPHICSCLIENT) += sa1100_graphicsclient.o
SA1100_OBJS_$(CONFIG_SA1100_XP860) += sa1100_xp860.o
SA1100_OBJS_$(CONFIG_SA1100_YOPY) += sa1100_yopy.o
SA1100_OBJS_$(CONFIG_SA1100_PANGOLIN) += sa1100_pangolin.o
BACKPACK_OBJS_$(CONFIG_MERCURY_BACKPAQ) +=h3600_backpaq.o

ifeq ($(CONFIG_PCMCIA),y)
  O_OBJS   := cistpl.o rsrc_mgr.o bulkmem.o
  OX_OBJS  := ds.o cs.o
  O_TARGET := pcmcia.o
  ifeq ($(CONFIG_CARDBUS),y)
    O_OBJS += cardbus.o
    OX_OBJS += cb_enabler.o yenta.o pci_socket.o
  endif
  ifeq ($(CONFIG_SA1100_PCMCIA),y)
    O_OBJS += $(SA1100_OBJS_y)
    O_OBJS += $(BACKPACK_OBJS_y)
  endif
else
  ifeq ($(CONFIG_PCMCIA),m)
     M_OBJS   := pcmcia_core.o 
     MX_OBJS  := ds.o
     MIX_OBJS  := cs.o
     CORE_OBJS := cistpl.o rsrc_mgr.o bulkmem.o cs.o
     ifeq ($(CONFIG_CARDBUS),y)
	M_OBJS += yenta_socket.o
	CORE_OBJS += cardbus.o
	CARDBUS_OBJS := pci_socket.o yenta.o
	OX_OBJS += pci_socket.o yenta.o
	MX_OBJS += cb_enabler.o
     endif
     ifeq ($(CONFIG_SA1100_PCMCIA),y)
        MI_OBJS = $(SA1100_OBJS_y)
        MIX_OBJS += sa1100_generic.o
        M_OBJS += sa1100_cs.o $(BACKPACK_OBJS_m)
     endif
  endif
endif

obj-$(CONFIG_I82365)		+= i82365.o
obj-$(CONFIG_TCIC)		+= tcic.o
obj-$(CONFIG_PCMCIA_CLPS6700)	+= clps6700.o

# Extract lists of the multi-part drivers.
# The 'int-*' lists are the intermediate files used to build the multi's.

multi-y         := $(filter $(list-multi), $(obj-y))
multi-m         := $(filter $(list-multi), $(obj-m))
int-y           := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs)))
int-m           := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))

# Files that are both resident and modular: remove from modular.

obj-m           := $(filter-out $(obj-y), $(obj-m))
int-m           := $(filter-out $(int-y), $(int-m))

# Take multi-part drivers out of obj-y and put components in.

obj-y           := $(filter-out $(list-multi), $(obj-y)) $(int-y)

# Translate to Rules.make lists.

O_OBJS          += $(filter-out $(export-objs), $(obj-y))
OX_OBJS         += $(filter     $(export-objs), $(obj-y))
M_OBJS          += $(sort $(filter-out $(export-objs), $(obj-m)))
MX_OBJS         += $(sort $(filter     $(export-objs), $(obj-m)))
MI_OBJS		+= $(sort $(filter-out $(export-objs), $(int-m)))
MIX_OBJS	+= $(sort $(filter     $(export-objs), $(int-m)))

include $(TOPDIR)/Rules.make

pcmcia_core.o:  $(CORE_OBJS)
	$(LD) $(LD_RFLAG) -r -o $@ $(CORE_OBJS)

sa1100_cs.o: $(SA1100_OBJS_y)
	$(LD) $(LD_RFLAG) -r -o $@ $(SA1100_OBJS_y)

yenta_socket.o: $(CARDBUS_OBJS)
	$(LD) $(LD_RFLAG) -r -o $@ yenta.o pci_socket.o
