# to compile the program under linux you need root privilegs
# if the automatic detection of the system doesn't work define 'linux' if
# compiling under linux and don't define it if compiling under dos
ifndef GO32
linux	= 1
endif

# define this if you want to save your pics as JPG and have the libjpeg 6
#jpeg	= 1
# must be gcc. BorlandC or MicrosoftC will not work
CC	= gcc
ifdef linux
RM	= rm -f
LIB	= -lvga
else
RM	= del
LIB	= -lpc
endif

CFLAGS	= -O2 -Wall -m486

ifdef jpeg
LIB	:= $(LIB) -L/usr/local/graphics/libjpeg-6a -ljpeg
INC	:= -I/usr/local/graphics/libjpeg-6a
CFLAGS	:= $(CFLAGS) -DJPEG
endif

all: video

video:	v_access.o vid_main.o
	$(CC) -o video vid_main.o v_access.o $(LIB)
ifndef linux
	coff2exe video
	$(RM) video
else
	chmod a+s video
endif

video_sw:	v_access.o vid_sw.o timer_m.o
	$(CC) -o video_sw vid_sw.o v_access.o timer_m.o $(LIB)
ifndef linux
	coff2exe video_sw
	$(RM) video_sw
else
	chmod a+s video_sw
endif

record:	v_access.o record.o timer_m.o
	$(CC) -o record record.o v_access.o timer_m.o $(LIB)
ifndef linux
	coff2exe record
	$(RM) record
else
	chmod a+s record
endif

video_x:	v_access.o vid_x.o timer_m.o
	$(CC) -o video_x vid_x.o v_access.o timer_m.o -lXext -lX11
	chmod a+s video_x

v_access.o:	v_access.c v_access.h
	$(CC) $(CFLAGS) -c v_access.c

vid_main.o:	vid_main.c v_access.h
	$(CC) $(CFLAGS) $(INC) -c vid_main.c

vid_sw.o:	vid_sw.c v_access.h timer_m.h
	$(CC) $(CFLAGS) -c vid_sw.c

record.o:	record.c record.h v_access.h timer_m.h
	$(CC) $(CFLAGS) -c record.c

vid_x.o:	vid_x.c v_access.h timer_m.h
	$(CC) $(CFLAGS) -c vid_x.c

timer_m.o:	timer_m.c timer_m.h
	$(CC) $(CFLAGS) -c timer_m.c
	
clean:
	$(RM) v_access.o
	$(RM) vid_main.o
ifndef linux
	$(RM) video.exe
else
	$(RM) video
endif

lib:	v_access.o
	ar rc libvideo.a v_access.o
	ranlib libvideo.a
