#####################################################
#                                                   #
# User Definable area                               #
#                                                   #
# This is the place to change the port number       #
#  (0x378 is lp0, 0x278 is lp1)                     #
#                                                   #
# Also, comment out the -DBIDIR if you only have    #
# a uni-directional parallel port.                  #
#                                                   #
#####################################################

DATA = 0x378
MODE = -DBIDIR

####### Shouldn't need to change the rest of this, really...

####### If you want to try using a different compiler/linker (why?)
####### you can change the CC/LD definitions, and you'll probably have
####### to change the various flags too.

CC = gcc
LD = gcc

DEFS = -DDATA=$(DATA) $(MODE) -DMODVERSIONS -include /usr/include/linux/modversions.h -D__KERNEL__ -DMODULE
CFLAGS = -O3 -Wall -funsigned-char -ffast-math -fomit-frame-pointer -m386
LDFLAGS = -s
MODDIR = /lib/modules/`uname -r`/misc
MODMODE = 0644
VGALIB = -lvgagl -lvga

all: cam.o vidcam.o photo.o takepic.o camClient.class 

cam.o: cam.c cam.h 
	$(CC) $(CFLAGS) $(DEFS) -c cam.c -o $@
	install -o root -g root -m $(MODMODE) $@ $(MODDIR)
	depmod -a
	
vidcam.o: vidcam.c
	$(CC) $(CFLAGS) -c vidcam.c -o $@
	$(LD) $(LDFLAGS) $(VGALIB) $@ -o vidcam
	
photo.o: photo.c
	$(CC) $(CFLAGS) -c photo.c -o $@
	$(LD) $(LDFLAGS) $(VGALIB) $@ -o photo
	
takepic.o: takepic.c
	$(CC) $(CFLAGS) -c takepic.c -o $@
	$(LD) $(LDFLAGS) -ljpeg $@ -o takepic

camClient.class: camClient.java
	javac camClient.java
	
install:: all
	rm -f /dev/cam
	mknod /dev/cam c 60 0

clean:
	rm -f *.o photo vidcam takepic camClient.class

####### This one is really just for me, so I can see the asm output.	

asm:
	$(CC) -fverbose-asm -S $(CFLAGS) $(DEFS) cam.c
