#
# modules/Makefile 1.44 1995/09/29 06:42:41 (David Hinds)
#

# Include site dependent options and kernel configuration
include ../config.out

ifndef CFLAGS
# Don't remove "-O2" or bad things will happen!
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -pipe
endif

CPPFLAGS = $(DEBUG) -D__KERNEL__ -DMODULE -I$(LINUX)/include -I$(LINUX)
LDFLAGS = -r -nostdlib
COFLAGS = -kv

# For files in kernel source tree, so that we can override config flags
XFLAGS = -D__KERNEL__ -I. -I$(LINUX)/include
ifdef CONFIG_MODVERSIONS
XFLAGS := $(XFLAGS) -DCONFIG_MODVERSIONS
endif

SRCS = \
	i82365.c tcic.c cs.c cistpl.c rsrc_mgr.c bulkmem.c ds.c \
	pcnet_cs.c 3c589_cs.c nmclan_cs.c serial_cs.c \
	qlogic_cs.c toaster_cs.c pcmem_cs.c memory_cs.c \
	ftl_cs.c sram_mtd.c iflash2_mtd.c iflash2+_mtd.c \
	# wavjamr_cs.c

MODULES = \
	i82365.o tcic.o pcmcia_core.o ds.o \
	serial_cs.o pcmem_cs.o memory_cs.o ftl_cs.o \
	sram_mtd.o iflash2_mtd.o iflash2+_mtd.o \
	# wavjamr_cs.o

EXTRA =

ifdef CONFIG_INET
MODULES := ${MODULES} pcnet_cs.o 3c589_cs.o nmclan_cs.o
EXTRA := ${EXTRA} 8390.o
endif

ifdef CONFIG_SCSI
MODULES := ${MODULES} qlogic_cs.o toaster_cs.o
# ifdef HAS_NCR53C400_SUPPORT
# SRCS := ${SRCS} t460_cs.c
# MODULES := ${MODULES} t460_cs.o
# endif
endif

all:	$(MODULES) $(EXTRA)

dep:	$(SRCS)
	$(CPP) -M $(CPPFLAGS) $(SRCS) > .depend

8390.o: $(LINUX)/drivers/net/8390.c
	$(CC) -c $(CFLAGS) $(XFLAGS) -DMODULE $<

qlogic.o: $(LINUX)/drivers/scsi/qlogic.c
	$(CC) -c $(CFLAGS) $(XFLAGS) -DPCMCIA $<

qlogic_cs.o: qlogic_cs.c qlogic.o
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o .$@
	$(LD) $(LDFLAGS) -o $@ .$@ qlogic.o
	rm -f .$@
	chmod -x qlogic_cs.o

aha152x.o: $(LINUX)/drivers/scsi/aha152x.c
	$(CC) -c $(CFLAGS) $(XFLAGS) -DPCMCIA $<

toaster_cs.o: toaster_cs.c aha152x.o
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o .$@
	$(LD) $(LDFLAGS) -o $@ .$@ aha152x.o
	rm -f .$@
	chmod -x toaster_cs.o

pcmcia_core.o: cs.o cistpl.o rsrc_mgr.o bulkmem.o
	$(LD) $(LDFLAGS) -o pcmcia_core.o cs.o cistpl.o rsrc_mgr.o bulkmem.o
	chmod -x pcmcia_core.o

clean:
	rm -f core core.* *.o .*.o *.a tmp_make *~
	for i in *.c;do rm -f `basename $$i .c`.s;done

MODDIR = $(PREFIX)/lib/modules/$(UTS_RELEASE)

install: $(MODULES) $(EXTRA)
	mkdir -p $(MODDIR)/pcmcia ;			\
	for i in $(MODULES); do				\
	    cp -p $$i $(MODDIR)/pcmcia ;		\
	done
	if [ -f 8390.o ] ; then				\
	    mkdir -p $(MODDIR)/net ;			\
	    cp -p 8390.o $(MODDIR)/net ;		\
	fi

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif

.c.s:
	$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
