CC=gcc
#CFLAGS= -g -Wall -O3  -mcpu=pentium -march=pentium -funroll-loops -fexpensive-optimizations -finline
CFLAGS= -Wall -O3 -DMMX -mcpu=pentium -march=pentium -funroll-loops -fexpensive-optimizations -finline-functions

V4LDIR=/usr/src/linux/drivers/char/
COPTS=$(CFLAGS) -I$(V4LDIR)
COPTSRT= -O3 -Wall -DMMX -mcpu=pentium -funroll-loops -fexpensive-optimizations -finline-functions

all:   nuvplay nuvrec

strip: nuvrec nuvplay
	strip nuvrec nuvplay

RTjpegN.o: RTjpegN.c RTjpegN.h
	$(CC) -c $(COPTSRT) RTjpegN.c

XJ.o:	XJ.c
	$(CC) -c $(COPTS) XJ.c


soxfuncs.o: soxfuncs.c
	$(CC) $(COPTS) -O3 -funroll-loops -finline-functions -c soxfuncs.c


resample.o: resample.c
	$(CC) $(COPTS) -O3 -funroll-loops -finline-functions -c resample.c


minilzo.o: minilzo.c minilzo.h
	$(CC) $(COPTS) -O3 -fexpensive-optimizations -funroll-loops -finline-functions -c minilzo.c


yuv2rgb_mmx.o: yuv2rgb_mmx.c yuv2rgb.h
	$(CC) $(COPTS) -O3 -funroll-loops -finline-functions -c yuv2rgb_mmx.c

areaDeinterlace.o: areaDeinterlace.h areaDeinterlace.c
	$(CC) $(COPTS) -O3 -fexpensive-optimizations -funroll-loops -finline-functions -c areaDeinterlace.c

rtjpeg_plugin.o: rtjpeg_plugin.c rtjpeg_plugin.h
	$(CC) $(COPTS) -O3 -fexpensive-optimizations -funroll-loops -finline-functions -c rtjpeg_plugin.c

nuvrec:	nuvrec.c RTjpegN.h RTjpegN.o minilzo.o
	$(CC) $(COPTS) -o nuvrec minilzo.o RTjpegN.o nuvrec.c

nuvplay:nuvplay.c RTjpegN.h areaDeinterlace.o RTjpegN.o XJ.o minilzo.o yuv2rgb_mmx.o rtjpeg_plugin.o resample.o soxfuncs.o
	$(CC) $(COPTS) -L/usr/X11R6/lib -lm -lXext -o nuvplay RTjpegN.o yuv2rgb_mmx.o \
	minilzo.o areaDeinterlace.o XJ.o soxfuncs.o resample.o rtjpeg_plugin.o nuvplay.c

static: rec-s nuvplay

rec-s:	nuvrec.c RTjpegN.h RTjpegN.o minilzo.o
	$(CC) $(COPTS) -static -o nuvrec minilzo.o RTjpegN.o nuvrec.c

install: nuvrec nuvplay
	 strip nuvrec nuvplay
	 install -m 755 nuvrec nuvplay nuvedit nuv2mpg nuv2vbr /usr/local/bin

clean:	
	rm -f *.o nuvplay nuvrec 
