#   Makefile for Quicknet Linux Drivers 
#   Version 0.3.5 1/28/2000
#
#    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.
# 
#    Authors:   Greg Herlein <gherlein@quicknet.net>
#		Ed Okerson <eokerson@quicknet.net>    
#
VER:=$(shell uname -r)
KERNEL_DIR:=/usr/src/linux
include $(KERNEL_DIR)/.config
MODFLAGS:=
#
# Comment/uncomment the following line to enable/disable debugging
#DEBUG = y
#
# Change it here or specify it on the "make" commandline
INCLUDEDIR = /usr/include
#
ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DIXJ_DEBUG
else
  DEBFLAGS = -O2
endif
#
ifdef CONFIG_MODVERSIONS
MODFLAGS += -DMODVERSIONS -include $(KERNEL_DIR)/include/linux/modversions.h
endif
#
CFLAGS = -D__KERNEL__ -DMODULE -Wall $(DEBFLAGS) $(MODFLAGS) -I$(INCLUDEDIR)
#
all:	ixj-pnp
#
?:
	@echo -e "\n\nChoose either \"make ixj-pnp\" (for isapnp support) \
\nor \"make ixj-manual (manual card configuration required)\nor \
make ixj-cs (for CardService PCMCIA support)\neither will install the \
modules after they are built\n\n"

headers-install:
	install -c telephony.h /usr/src/linux/include/linux/
	install -c ixjuser.h /usr/src/linux/include/linux/
	install -c phonedev.h /usr/src/linux/include/linux/

ixj-pnp: headers-install phonedev.o isapnp ixj-w-isapnp install

ixj-manual: headers-install phonedev.o ixj-wo-isapnp install

ixj-cs: headers-install phonedev.o ixj_cs install_cs

ixj_cs : ixj.c ixj.h ixjuser.h
	${CC} ${CFLAGS} -o ixj_cs.o -c ixj.c -DCONFIG_PCMCIA

ixj-w-isapnp : ixj.c ixj.h ixjuser.h
	${CC} ${CFLAGS} -o ixj.o -c ixj.c -DCONFIG_ISAPNP

ixj-wo-isapnp : ixj.c ixj.h ixjuser.h
	${CC} ${CFLAGS} -o ixj.o -c ixj.c 

phonedev.o: phonedev.c phonedev.h
	${CC} ${CFLAGS} -DEXPORT_SYMTAB -o $@ -c phonedev.c


isapnp : ../isapnp/isapnp.o
	(cd ../isapnp ; ${MAKE} ; ${MAKE} install )

install:
	(./phone_dev_create)
	mkdir -p /lib/modules/$(VER)/misc /lib/modules/misc
	install -c phonedev.o /lib/modules/$(VER)/misc
	install -c ixj.o /lib/modules/$(VER)/misc
	depmod -av

install_cs:
	(./phone_dev_create)
	mkdir -p /lib/modules/$(VER)/misc /lib/modules/misc
	install -c ixj_cs.o /lib/modules/$(VER)/pcmcia
	install -c phonedev.o /lib/modules/$(VER)/misc
	depmod -a



clean:
	(cd ../isapnp ; ${MAKE} clean)
	rm -f *.o *~ core



