################################################################################
#
# File:		driver/Makefile
# Version:	$Id: Makefile,v 1.22 1995/08/07 05:56:37 burgaard Exp $	
#
# Project:      Roland MPU-401 Device driver for Linux 1.2.4 or higher.
# Authors:	Kim Burgaard, <burgaard@daimi.aau.dk>
# Copyrights:	Copyright (c) 1994, 1995 Kim Burgaard.
#
#		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, 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; see the file COPYING.  If not,
#		write to the Free Software Foundation, 675 Mass Ave, Cambridge,
#		MA 02139, USA.
#
################################################################################

SRCS      = mpu401.c mpuconfig.c mpuinfo.c
DRIVERS   = mpu401drv.o
SBINS     = mpuconfig mpuinfo 
MAN8	  = mpuconfig.8 mpuinfo.8

################################################################################

all:		version $(DRIVERS) $(SBINS)

mpuconfig:	mpuconfig.c ../include/*.h
		$(CC) $(CFLAGS) -DMPU_RC_FILE=$(RC_FILE) -o $@ $@.c

mpuinfo:	mpuinfo.c ../include/*.h
		$(CC) $(CFLAGS) -I/usr/include/ncurses $@.c -lncurses -o $@

mpu401.o:	mpu401.c ../include/*.h ../lib/midiqueue.c
		@echo "******************************************************************"
		@echo
		@echo "The next file may take a while to compile...                      "
		@echo
		@echo "******************************************************************"
		$(CC) $(CFLAGS) -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS \
			-DMPU_RC_FILE=$(RC_FILE) -DMPU_VERSION=$(VERSION) \
			-DMPU_SUBVERSION=$(SUBVERSION) -DMPU_REVISION=$(REVISION) \
			-c -o $@ $<

mpu401drv.o:	mpu401.o ../include/*.h ../lib/midiqueue.c
		$(LD) -r -o $@ mpu401.o ../lib/midiqueue.o

###############################################################################

clean:	
	-rm -f $(DRIVERS) $(SBINS) core *.o *.a *.s .version

install:	all
	install --directory --mode a+rx $(MODDIR)/`cat .version`/misc
	install --directory --mode u+rx $(SYSDIR)
	install --directory --mode a+rx $(MANDIR)/man8

	install --owner root --group sys --mode u+r $(DRIVERS) $(MODDIR)/`cat .version`/misc
	install --strip --owner root --group root --mode 700 $(SBINS) $(SYSDIR)
	install --mode a+r $(MAN8) $(MANDIR)/man8

	if test -e /dev/mpu401data; then rm -f /dev/mpu401data; else true; fi
	if test -e /dev/mpu401stat; then rm -f /dev/mpu401stat; else true; fi
	mknod --mode a+rw /dev/mpu401data c 31 0; chown root.sys /dev/mpu401data
	mknod --mode a+rw /dev/mpu401stat c 31 1; chown root.sys /dev/mpu401stat

	if [ ! -f $(RC_FN) ]; then mpuconfig; fi
	@sync
	@-modprobe -r mpu401drv
	depmod -a
	modprobe mpu401drv
	@mpuinfo

uninstall:	version
	cd $(MODDIR)/`cat .version`/misc && rm -f $(DRIVERS)
	cd $(SYSDIR) && rm -f $(SBINS)
	cd $(MANDIR)/man8 && rm -f $(MAN8)

################################################################################

version:
	echo -n `cat /usr/include/linux/version.h|grep UTS_RELEASE|cut -f 2 -d'"'` > .version

### End of File #################################################################
# Local variables:
#   fill-column: 81
# End:
