#
#   muscan - scanner driver for Mustek Paragon scanners
#   6000CX and 6000CZ
#
#   Copyright (C) 1995 Torsten Eichner
#
#   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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#   email: 	eichner@rhrk.uni-kl.de
#   papermail:	Torsten Eichner, Kampshardtweg 1, D-57587 Birken-Honigsessen, Germany
#

#   Modify this to your needs

MACHINE	   = LINUX
#MACHINE   = FREEBSD
# Uncomment your machine type

XAWLIB	   = Xaw
#XAWLIB     = Xaw3d
# Use of Xaw3d recommended

DEVICE     = /dev/scanner

INSTXBINDIR= /usr/local/bin/X11
INSTBINDIR = /usr/local/bin
INSTMANDIR = /usr/local/man/man1
INSTAPPDIR = /usr/lib/X11/app-defaults

#   Don't modify below this line

ifeq "$(MACHINE)" "FREEBSD"
ROOTGROUP=bin
EXTRALIBS= -lscsi
EXTRAXLIBS= -lXmu
else
ifeq "$(MACHINE)" "LINUX"
ROOTGROUP=root
EXTRALIBS=
EXTRAXLIBS=
else
error:
	@echo "Unknown machine $(MACHINE)"
endif
endif

SRC1 = muscan.c
OBJ1 = muscan.o

SRC2 = xmuscan.c
OBJ2 = xmuscan.o

CFLAGS = -O2 -Wall -m486 -I/usr/X11R6/include\
	 -DDEVICE="\"$(DEVICE)\"" -D$(MACHINE)\
         -DUSER="\"`whoami`\"" -DHOST="\"`hostname`\"" -DVERSION="\"2.0.6\""

all:	msg muscan xmuscan
	@echo Compilation completed!

msg:
	@echo Creating muscan package for $(MACHINE)...

muscan: $(OBJ1)
	@echo linking muscan
	@$(CC) $(CFLAGS) -o muscan $(OBJ1) $(EXTRALIBS)
	@strip muscan

xmuscan:$(OBJ2)
	@echo linking xmuscan
	@$(CC) $(CFLAGS) -o xmuscan $(OBJ2) -L/usr/X11R6/lib -l$(XAWLIB) $(EXTRAXLIBS) -lXt -lX11
	@-xrdb -merge Xmuscan.ad
	@strip xmuscan

.c.o:
	@echo compiling $<
	@$(CC) $(CFLAGS) -c $<

clean:
	@echo cleaning directory
	@rm -f $(OBJ) core muscan.tar muscan.tar.gz muscan.tar.z Makefile.bak *.o

allclean: clean
	@echo cleaning directory
	@rm -f muscan xmuscan

install: all
	@echo Now installing muscan package...
	@install -g $(ROOTGROUP) -o root -m 644 muscan.1 $(INSTMANDIR)/muscan.1
	@install -g $(ROOTGROUP) -o root -m 644 xmuscan.1 $(INSTMANDIR)/xmuscan.1
	@install -g bin -o bin -m 755 muscan $(INSTBINDIR)/muscan
	@install -g bin -o bin -m 755 xmuscan $(INSTXBINDIR)/xmuscan
	@install -g bin -o bin -m 755 tkmuscan $(INSTXBINDIR)/tkmuscan
	@install -g $(ROOTGROUP) -o root -m 644 Xmuscan.ad $(INSTAPPDIR)/Xmuscan
	@echo Installation completed!

indent:
	@indent $(SRC1) $(SRC2)
	@rm -f *~

dist:	 indent allclean
	@echo creating distribution
	@cd ..; tar -cvf muscan.tar muscan
	@mv ../muscan.tar .
	@gzip muscan.tar
