
#
# Makefile for Lava EtherSerial link driver
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Author: Eduard G. Kromskoy <ed1k@lavalink.com>
# Company: Lava Computer Mfg Inc. 
#
# This Makefile seems to reflect the directory tree (the kernel
# source and modules location) for all Red Hat distributions.
# Please correct pathes if it doesn't work for your installation.
#
# Alternatively you may want to compile this module by adding
# the source to the linux kernel source tree.
# 

KERNELVER = $(shell uname -r | sed 's/[a-zA-Z]//g')
SHORTVER = $(shell uname -r | sed 's/-.*//')
SMPSTR = $(shell uname -v | sed -n '/SMP/p')
HEADERS = /lib/modules/$(KERNELVER)/build/include
ARCH= $(shell uname -m)

CFLAGS = -D__KERNEL__ -DLINUX -Dlinux -I$(HEADERS) -O2 -Wall -Wstrict-prototypes -march=$(ARCH) -DMODULE -DMODVERSIONS
DEBUG=
CC=gcc
LDFLAGS=
HDR=
SRC=esl.c
LIBS=

ifneq "$(SMPSTR)" ""
CFLAGS += -D__SMP__ -DSMP
SMPSTR =
# If you have different directories to keep SMP version of modules
# and uniprocessor modules (Red Hat distro behaviour), you may want
# to uncomment the line below (see install section)
#SMPSTR = smp
endif

all: esl.o

esl.o: $(SRC) $(HDR)
	$(CC) $(CFLAGS) -c $(SRC) $(LDFLAGS) $(LIBS) 2>error.log

install: 
	cp esl.o /lib/modules/$(KERNELVER)$(SMPSTR)/kernel/drivers/char
	rm -f /dev/ttyES*
	mknod /dev/ttyES0 c 247 0
	mknod /dev/ttyES1 c 247 1
	mknod /dev/ttyES2 c 247 2
	mknod /dev/ttyES3 c 247 3
	mknod /dev/ttyES4 c 247 4
	mknod /dev/ttyES5 c 247 5
	mknod /dev/ttyES6 c 247 6
	mknod /dev/ttyES7 c 247 7
	chmod 666 /dev/ttyES*
	depmod -a
	
clean:
	rm -f error.log
	rm -f esl.o
	