# $Id: Makefile,v 2.3 1996/11/20 20:24:23 i2c Exp i2c $
# $Log: Makefile,v $
# Revision 2.3  1996/11/20 20:24:23  i2c
# modified insmod to sort map-file
#
# Revision 2.2  1996/11/18 22:29:01  i2c
# Added PCF_ISA & fixed minor summary bug.
#
# Revision 2.1  1996/11/17 10:48:44  i2c
# New Makefile for updated module layout. Adapts to different
# adapter selections.
#
# Revision 1.5  1996/07/09 20:29:43  i2c
# added lppcf
#
# Revision 1.4  1996/03/28 21:22:56  i2c
# added dependancy information
#
# Revision 1.3  1996/03/28 20:34:31  i2c
#
# Revision 1.2  1996/03/28 19:29:24  i2c
# added multi-file support
#
# Revision 1.1  1996/03/15 08:59:24  root
# Initial revision
#

#
# uncomment any of the following:
#   
# --- BIT adapters 
BIT_LP		= "Philips style parallel port adapter"
# BIT_SER	= "Serial port version"
# 
PCF_ISA	= "PCF 8584 on ISA bus adapter (`a la Elektor)"
# PCF_LP 	= "PCF 8584 on parallel port"
# ... the other ones remain to be defined ...
#

# 

BITADAPS	= 0
PCFADAPS	= 0

#
# Now we define everything we need for the selected hardware adapters:
#
ifdef BIT_LP
BITADAPS	+= +1
IDX_B_LP	:= ($(BITADAPS))
HW_OPTS		+= -DBIT_LP -DIDX_B_LP="$(IDX_B_LP)"
HW_SRCS		+= bit-lp.c
endif

# example:
ifdef BIT_SER
BITADAPS	+= +1
IDX_B_SER	:= ($(BITADAPS))
HW_OPTS		+= -DBIT_SER -DIDX_B_SER="$(IDX_B_SER)"
HW_SRCS		+= bit-lp.c
endif

ifdef PCF_LP
PCFADAPS	+= +1
IDX_P_LP	:= ($(PCFADAPS))
HW_OPTS		+= -DPCF_LP -DIDX_P_LP="$(IDX_P_LP)"
HW_SRCS		+= pcf-lp.c
endif

ifdef PCF_ISA
PCFADAPS	+= +1
IDX_P_LP	:= ($(PCFADAPS))
HW_OPTS		+= -DPCF_ISA -DIDX_P_ISA="$(IDX_P_ISA)"
HW_SRCS		+= pcf-isa.c
endif


I2C_HOME	= ..

#----------------------------------------------------------------------------
HW_OPTS		+= 	-DBITADAPS=$(shell echo $$[$(BITADAPS)])	\
			-DPCFADAPS=$(shell echo $$[$(PCFADAPS)])
I2C_OPT         = -DVERIFY_HEADERS -DSLOW_STARTER
KERNEL_OPT      = -D__KERNEL__ -DKERNEL -DLINUX -DMODULE 
WARNINGS        = -Wall -Wstrict-prototypes
COMPILE         = -pipe -fomit-frame-pointer -m486 -O2 \
		  -I$(I2C_HOME)/include -I.
DEBUG           =

SRCS  		= i2c_main.c alg-illeg.c $(HW_SRCS)
INCLUDES	= i2c_priv.h
OBJS  		= $(SRCS:.c=.o)
HDRS		= i2c_priv.h
MOD   		= i2c

ifneq ($(BITADAPS),0)
SRCS		+= alg-bit.c
endif

ifneq ($(PCFADAPS),0)
SRCS		+= alg-pcf.c
endif

CFLAGS = $(DEBUG) $(WARNINGS) $(COMPILE) $(I2C_OPT) $(KERNEL_OPT) $(HW_OPTS)
SFLAGS = -fverbose-asm $(WARNINGS) $(COMPILE) $(PRT_OPT) $(KERNEL_OPT)

all: depend $(MOD).o
	@echo "---------------------------------------------------"
	@echo "built i2c driver for $$[$(BITADAPS)] bit- and $$[$(PCFADAPS)] pcf adapters"

$(MOD).o: $(OBJS) $(SRCS)
	ld -r $(OBJS) -o $(MOD).o

run: $(MOD).o
	-rmmod $(MOD)
	-insmod -m $(MOD) |sort|uniq>$(MOD).map

install: $(MOD).o
	cp $(MOD).o $(MODULE_DIR)

clean:
	-rm -f a.out $(OBJS) $(MOD).map core kernel-version.h .depend

tst:
	echo $(AA)

dep depend .depend: $(SRCS) $(INCLUDES)
	gcc $(CFLAGS) $(SRCS) -M >.depend
#
# include dependency files if they exist
#
ifeq ( .depend , $(wildcard .depend) )
include .depend
endif
