CC    = gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE \
        -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h \
        -DEXPORT_SYMTAB
FLAG1 = -fomit-frame-pointer -O2
FLAG2 = -O6 -m486 -fdefer-pop -finline-functions -fomit-frame-pointer \
	-fstrength-reduce -fthread-jumps -funroll-loops -fcse-follow-jumps \
	-frerun-cse-after-loop -fexpensive-optimizations

all: cx5x86.o bogo.o

cx5x86.o: cx5x86.c cx5x86.h
	$(CC) $(OPT) -c cx5x86.c $(FLAG1)

bogo.o:   bogo.c
	$(CC) $(OPT) -c bogo.c $(FLAG2)

install: cx5x86.o bogo.o
	{ MODLIB="`head -3 /usr/src/linux/Makefile|grep VERSION|\
	cut -f3 -d' '`.`head -3 /usr/src/linux/Makefile|\
	grep PATCHLEVEL|cut -f3 -d' '`.`head -3 /usr/src/linux/Makefile|\
	grep SUBLEVEL|cut -f3 -d' '`"; \
	if [ ! -d /lib/modules/$$MODLIB ]; \
	then mkdir /lib/modules/$$MODLIB; \
	fi; \
	if [ ! -d /lib/modules/$$MODLIB/misc ]; \
	then mkdir /lib/modules/$$MODLIB/misc; \
	fi; \
	cp cx5x86.o bogo.o /lib/modules/$$MODLIB/misc; \
	}
	
tgz:
	{ DIRNAME="`basename $$PWD`" ; \
	cd .. ; \
	tar cvfz $$DIRNAME.tgz \
	$$DIRNAME/cx5x86.c \
	$$DIRNAME/cx5x86.h \
	$$DIRNAME/bogo.c \
	$$DIRNAME/Makefile \
	$$DIRNAME/rc.cx5x86 \
	$$DIRNAME/README \
	$$DIRNAME/cx5x86mod_1.0c.lsm \
	}

clean:
	rm -f cx5x86.o bogo.o
