#    tpuart -- A TP-UART driver 
#
#
#    Copyright (C) 2004 Reinhold Buchinger <e0125124@student.tuwien.ac.at> 
#                       University of Technology Vienna
#
#    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.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place--Suite 330, Boston, MA
#    02111-1307, USA.
#
#

# set this to y to enable debugging
DEBUG = y

MODULE_NAME = tpuart

TPUART_VERSION = 0.03a0

INSTALL_PATH = /lib/modules/`uname -r`/kernel/drivers/char

TESTS = writetest recvtest busmontest

ifeq ($(DEBUG),y)
#	DEBFLAGS = -O2 -fstrict-prototypes -DTPUART_DEBUG
	DEBFLAGS = -O2 -DTPUART_DEBUG

else
#	DEBFLAGS = -O2 -fstrict-prototypes -fomit-frame-pointer
	DEBFLAGS = -O2 -fomit-frame-pointer

endif


EXTRA_CFLAGS += -Wall $(DEBFLAGS) -DMODULE_VERSION_TPUART=\"$(TPUART_VERSION)\"
#extra-y = 




ifneq ($(KERNELRELEASE),)
	obj-m += $(MODULE_NAME).o
	$(MODULE_NAME)-objs :=  bmrecv.o transmit.o rxstm.o utility.o tpuart_main.o deque.o heartbeat.o  
else
	KDIR:= /lib/modules/$(shell uname -r)/build
	PWD := $(shell pwd)

all:	module tests

module:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules


tests:	$(TESTS)

writetest: writetest.c
	$(CC) -O3 -Wall -o $@ $<

recvtest: recvtest.c
	$(CC) -O3 -Wall -o $@ $<

busmontest: busmontest.c
	$(CC) -O3 -Wall -o $@ $<

install:
	install -m 644 -o root -g root $(MODULE_NAME).ko $(INSTALL_PATH)

clean:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
	rm -f $(TESTS)

endif
